GitLab

GitLab official website address

Demand configuration

GitLab officially has certain requirements for server configuration, such as recommended 4-core CPU and 4G memory

Resources: Official requirements configuration

The installation

Ubuntu

Resources: Ubuntu official website installation address

Version GitLab 13.12.4 – ee

  1. Install and configure necessary dependencies
sudo apt-get update
sudo apt-get install -y curl openssh-server ca-certificates tzdata perl
Copy the code

If you need to send notification email

sudo apt-get install -y postfix
Copy the code
  1. Add the GitLab package repository and install it
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.deb.sh | sudo bash
# installation
apt-get install gitlab-ee
Copy the code

Start the

  1. Start the
gitlab-ctl start
Copy the code
  1. See the log
gitlab-ctl tail
Copy the code

We found several service errors

The Prometheus port is occupied

==> /var/log/gitlab/prometheus/state <==

==> /var/log/ gitlab/Prometheus/current < = = 2021-06-23 _01: thus. 41663 level = info ts = 2021-06-23 T01: thus, 416 zcaller=web.go:532 component=web msg="Start listening for connections"Address = localhost: 9090 2021-06-23 _01: thus. 41702 level = error ts = 2021-06-23 T01: thus. 416 zcaller=main.go:608 msg="Unable to start web listener" err="listen tcp 127.0.0.1:9090: bind: address already in use"


The ## [nginx] port is occupied
==> /var/log/gitlab/nginx/error.log <==
2021/06/22 18:48:54 [emerg] 8157#0: invalid port in "*:" of the "listen" directive in /var/opt/gitlab/nginx/conf/gitlab-http.conf:36

==> /var/log/gitlab/nginx/state <==

==> /var/log/gitlab/nginx/current <==
2021-06-23_01:20:41.06646 2021/06/23 09:20:40 [emerg] 28393#0: Bind () to 0.0.0.0:80 failed (98: Address already in use)


## [grafana] The port is occupied
==> /var/log/gitlab/grafana/current <==
2021-06-23_01:20:46.39111 failed to open listener on address localhost:3000: listen tcp 127.0.0.1:3000: bind: address already in use
Copy the code
  1. Modify the corresponding port in the configuration file
vi /etc/gitlab/gitlab.rb

#external_url 'GENERATED_EXTERNAL_URL'
external_url 'http://192.168.0.200'

# nginx['listen_port'] = nil
nginx['listen_port'] = 10001

# prometheus['listen_address'] = 'localhost:9090'
prometheus['listen_address'] = 'localhost:10002'

# grafana['http_port'] = 3000
grafana['http_port'] = 10003
Copy the code

When modifying nginx [‘ listen_port] = 10001, perform gitlab – CTL reconfigure will modify/var/opt/gitlab/nginx/conf/gitlab – HTTP. Conf

server {
  listen *:10001;

  server_name 192.168.0.200;
  #...
}
Copy the code

Resources: Official configuration address

  1. Reload the configuration file and restart the service
gitlab-ctl reconfigure
gitlab-ctl restart
Copy the code
  1. To access the page

Go to http://yourIp:yourNginxPort log in. It may take a while, but it will take a few seconds for the service to start.

The file path

# GitLab
/etc/gitlab/gitlab.rb               # GitLab configuration file
/opt/gitlab                         # GitLab and all component configuration
/var/opt/gitlab/git-data            # GitLab Repository
/var/opt/gitlab/backups             # GitLab backup directory
/var/log/gitlab                     # GitLab component log directory

# PostgreSQL components
/var/opt/gitlab/postgresql          # PostgreSQL installation directory
/var/log/gitlab/postgresql          # PostgreSQL log directory
/var/log/gitlab/postgres-exporter   # PostgreSQL- Run log directory
/var/opt/gitlab/postgresql/data     # PostgreSQL data directory

# Redis components
/var/opt/gitlab/redis # Redis installation directory
/var/log/gitlab/redis # Redis log directory
Copy the code

Common commands

gitlab-ctl reconfigure Reload the configuration items
gitlab-ctl start       Start all GitLab components
gitlab-ctl stop        # Stop all GitLab components
gitlab-ctl restart     Restart all GitLab components
gitlab-ctl status      Check service status
gitlab-ctl show-config Check gitlab configuration
cat /opt/gitlab/embedded/service/gitlab-rails/VERSION Check the version number
Copy the code

Checking and Locating faults

  1. View the status of all services
gitlab-ctl status
run: alertmanager: (pid 13574) 15s; run: log: (pid 10640) 151513s
run: gitaly: (pid 13615) 14s; run: log: (pid 10013) 151616s
run: gitlab-exporter: (pid 13667) 13s; run: log: (pid 10544) 151529s
down: gitlab-workhorse: 1s, normally up, want up; run: log: (pid 10447) 151548s
run: grafana: (pid 13693) 12s; run: log: (pid 11246) 151456s
run: logrotate: (pid 13716) 12s; run: log: (pid 9932) 151626s
run: node-exporter: (pid 13802) 12s; run: log: (pid 10524) 151535s
run: postgres-exporter: (pid 13840) 11s; run: log: (pid 11073) 151507s
run: postgresql: (pid 13851) 11s; run: log: (pid 10169) 151608s
run: prometheus: (pid 13876) 10s; run: log: (pid 10593) 151519s
run: puma: (pid 13905) 9s; run: log: (pid 10358) 151560s
run: redis: (pid 13930) 9s; run: log: (pid 9962) 151620s
run: redis-exporter: (pid 13936) 9s; run: log: (pid 10562) 151525s
run: sidekiq: (pid 13996) 6s; run: log: (pid 10381) 151554s
Copy the code
  1. Location problem

Gitlab-workhorse is in down state, that is, the service is stopped. Check error logs.

gitlab-ctl tail gitlab-workhorse
Copy the code