Skip to main content

GItlab mounting

GItlab installation

  1. Install relevant U dependencies
    $ yum -y install policycoreutils openssh-clients postfix

2、Start the ssh service & set it to boot

    $ systemctl enable sshd & sudo systemctl start sshd

3、Setting up postfix to boot itself up and start, postfix supports gitlab sending mail function

    $ systemctl enable postfix && systemctl start postfix

4、Open the ssh and http services and reload the firewall list.

    $ firewall-cmd --add-service=ssh --permanent
$ firewall-cmd --add-service=http --permanent
$ firewall-cmd --reload

5、Download the gitlab package and install it

    $ wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el6/gitlab-ce-12.4.2-ce.0.el6.x86_64.rpm 
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el6/gitlab-ce-13.6.7-ce.0.el6.x86_64.rpm

$ rpm -i gitlab-ce-12.4.2-ce.0.el6.x86_64.rpm

6、Modify the gitlab configuration

vi /etc/gitlab/gitlab.rb

Modify the gitlab access address and port, the default is 80, we change it to 82

    external_url'http://192.168.66.100:82'
nginx['listen_port']=82 #This line is commented out, just open it directly

7、Reload configuration and start gitlab

    gitlab-ctl reconfigure
gitlab-ctl restart
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 the status of the service;
gitlab-ctl reconfigure # Start the service;
vim /etc/gitlab/gitlab.rb # Modify the default configuration file;
gitlab-rake gitlab:check SANITIZE=true --trace # Check gitlab;
gitlab-ctl tail # View Log.

**There was an error running gitlab-ctl reconfigure.

Error: There was an error running gitlab-ctl reconfigure.
ruby_block[authorize Grafana with [Gitlab](/search?q=Gitlab)] (monitoring::grafana line 92) had an error: NoMethodError : undefined method 'zero?' for nil:NilClass

Solutions (monitoring::grafana line 92) had an error.

Allocate 2G of space

sudo dd if=/dev/zero of=/root/swapfile bs=1M count=1500;

Make file and take effect

sudo mkswap /root/swapfile
sudo swapon /root/swapfile

Set up bootup
sudo vim /etc/fstab Add it on the last line.

/root/swapfile swap swap defaults 0 0

Finally free -m to see if it takes effect.
After it takes effect, re-execute gitlab-ctl reconfigure and you're done!

  1. Add the port to the firewall
    firewall-cmd --zone=public --add-port=82/tcp --permanent
firewall-cmd --reload

After successful startup, visit: xxxx:82 to see the page to change the administrator root password, change the password and log in.

Gitlab installation problems

**403 "Forbidden" occurs when accessing Gitlab.

Problem cause analysis:

The problem may be caused by ** more concurrent access is denied, Gitlab use rack_attack to do the concurrent access limit! **

Solution:

Open the file /etc/gitlab/gitlab.rb and look for the gitlab_rails['rack_attack_git_basic_auth'] keyword, uncomment it, and

Modify the ip_whitelist whitelist attribute to include the IP address of the Gitlab deployment.

    [root@gitlab ~]# vim /etc/gitlab/gitlab.rb
......
gitlab_rails['rack_attack_git_basic_auth'] = {
'enabled' => true,
'ip_whitelist' => ["127.0.0.1","172.16.60.222"], // Add the gitlab server IP address to the
'maxretry' => 10,
'findtime' => 60,
'bantime' => 3600
}  

Then reconfigure

    [root@gitlab ~]``# gitlab-ctl reconfigure

**2. Gitlab access appears as 502 **

Gitlab access appeared: Whoops, GitLab is taking too much time to respond.

Problem cause analysis:

(1) unicorn original 8080 default port has been occupied by other processes in the container, must be adjusted to not used!
2) gitlab's timeout setting is too small, the default is 60

Solution:

  1. Close the gitlab service
    [root@gitlab ~]``# gitlab-ctl stop

  1. Select a port that is not occupied by the system as a unicorn port, such as port 8877 (lsof -i:8877 to confirm that this port is not occupied)
    [root@gitlab ~]# vim /etc/gitlab/gitlab.rb
unicorn['port'] = 8877
gitlab_workhorse['auth_backend'] = "http://localhost:8877"

3)Regenerate the configuration and perform a reboot.

    [root@gitlab ~]# gitlab-ctl reconfigure
[root@gitlab ~]# gitlab-ctl restart

**3, Gitlab startup failure, or reinstallation of the card state **

Problem phenomenon: in the uninstallation of gitlab and then install again to execute sudo gitlab-ctl reconfigure will often appear: ruby_block [supervise_redis_sleep] action run, will always be stuck can not proceed down the line!

Solution:

  1. Press ctrl + c to force an end.
  2. Execute the command "systemctl restart gitlab-runsvdir".
  3. Then execute "gitlab-ctl reconfigure".

If the Gitlab server restarts and the "gitlab-ctl start" fails, the solution is the same.

    [root@gitlab ~]# systemctl restart gitlab-runsvdir
[root@gitlab ~]# gitlab-ctl reconfigure
[root@gitlab ~]# gitlab-ctl start

**4, Gitlab abnormal shutdown, resulting in gitlab startup failure! gitlab-runsvdir way to start unresponsive (zombie state) **

Problem phenomenon: Gitlab deployment of the server abnormal power outage, the machine restarted, try to start the gitlab service, startup failure! Through the gitlab-runsvdir way to start has been unresponsive! It keeps lagging! The log also has no task input!

    Executing the following startup command reports an error:
[root@gitlab ~]# gitlab-ctl start // or "gitlab-ctl restart"
fail: alertmanager: runsv not running
fail: gitaly: runsv not running
fail: gitlab-monitor: runsv not running
fail: gitlab-workhorse: runsv not running
fail: logrotate: runsv not running
fail: nginx: runsv not running
fail: node-exporter: runsv not running
fail: postgres-exporter: runsv not running
fail: postgresql: runsv not running
fail: prometheus: runsv not running

Then try to start gitlab by means of the supervisor process and find that it keeps lagging and doesn't respond at all!

    [root@gitlab ~]# systemctl restart gitlab-runsvdir

Looking at the logs, I see that there is no task startup information printed to the logs either (the logs are all from before)

    [root@gitlab ~]``# /usr/bin/gitlab-ctl tail

gitlab-runsvdir starts in lag, and the gitlab service isn't up either

    root@gitlab ~]# cat /etc/systemd/system/multi-user.target.wants/gitlab-runsvdir.service
[Unit]
Description=GitLab Runit supervision process
After=multi-user.target

[Service]
ExecStart=/opt/gitlab/embedded/bin/runsvdir-start # Finally started Gitlab with this command.
Restart=always

[Install]
WantedBy=multi-user.target

Executing the following startup does not affect the startup of the gitlab service, although it is found that this one also stutters all the time.
[root@gitlab ~]# /opt/gitlab/embedded/bin/runsvdir-start

Reopen a terminal window and find that new log messages have been typed into gitlab, and the gitlab service has been started
[root@gitlab ~]# /usr/bin/gitlab-ctl tail
[root@gitlab ~]# ps -ef|grep gitlab

This time, you close the stuttering terminal window of "/opt/gitlab/embedded/bin/runsvdir-start", and find that gitlab is still up (ps -ef|grep gitlab).
[root@gitlab ~]# ps -ef|grep gitlab
[root@gitlab ~]# lsof -i:80
[root@gitlab ~]# gitlab-ctl status
run: alertmanager: (pid 29804) 1640s; run: log: (pid 29789) 1640s
run: gitaly: (pid 29795) 1640s; run: log: (pid 29781) 1640s
run: gitlab-monitor: (pid 29799) 1640s; run: log: (pid 29785) 1640s
run: gitlab-workhorse: (pid 29794) 1640s; run: log: (pid 29780) 1640s
run: logrotate: (pid 29798) 1640s; run: log: (pid 29783) 1640s
run: nginx: (pid 29800) 1640s; run: log: (pid 29786) 1640s
run: node-exporter: (pid 29802) 1640s; run: log: (pid 29788) 1640s
run: postgres-exporter: (pid 29805) 1640s; run: log: (pid 29790) 1640s
run: postgresql: (pid 29796) 1640s; run: log: (pid 29782) 1640s
run: prometheus: (pid 29797) 1640s; run: log: (pid 29784) 1640s
run: redis: (pid 29818) 1640s; run: log: (pid 29793) 1640s
run: redis-exporter: (pid 29817) 1640s; run: log: (pid 29792) 1640s
run: sidekiq: (pid 29801) 1640s; run: log: (pid 29787) 1640s
run: unicorn: (pid 29807) 1640s; run: log: (pid 29791) 1640s

Checking the logs also writes new information, so everything is fine!
[root@gitlab ~]# /usr/bin/gitlab-ctl tail 

5、Gitlab was reinstalled and the following error occurred during the "gitlab-ctl reconfigure" configuration session:

    [root@gitlab ~]# gitlab-ctl reconfigure
.........
.........
STDERR: sysctl: cannot open "/etc/sysctl.d/90-omnibus-gitlab-kernel.sem.conf": No such file or directory
sysctl: cannot open "/etc/sysctl.d/90-omnibus-gitlab-net.core.somaxconn.conf": No such file or directory
---- End output of sysctl -e --system ----
Ran sysctl -e --system returned 255

Problem Cause Analysis:
Missing these two configuration files in the error report, I went into the /etc/sysctl.d directory and found that both files were linked to the /opt/gitlab/embedded/etc/ directory via a link to the /opt/gitlab/embedded/etc/ directory.
However /opt/gitlab/embedded/etc/ really doesn't have these two files.

    [root@gitlab ~]# ll /etc/sysctl.d/
total 0
lrwxrwxrwx 1 root root 58 Nov 10 22:23 90-omnibus-gitlab-kernel.sem.conf -> /opt/gitlab/embedded/etc/90-omnibus-gitlab-kernel.sem.conf
lrwxrwxrwx 1 root root 61 Nov 10 22:23 90-omnibus-gitlab-kernel.shmall.conf -> /opt/gitlab/embedded/etc/90-omnibus-gitlab-kernel.shmall.conf
lrwxrwxrwx 1 root root 61 Nov 10 22:23 90-omnibus-gitlab-kernel.shmmax.conf -> /opt/gitlab/embedded/etc/90-omnibus-gitlab-kernel.shmmax.conf
lrwxrwxrwx 1 root root 66 Nov 10 22:25 90-omnibus-gitlab-net.core.somaxconn.conf -> /opt/gitlab/embedded/etc/90-omnibus-gitlab-net.core.somaxconn.conf
lrwxrwxrwx. 1 root root 14 Oct 30 09:13 99-sysctl.conf -> ../sysctl.conf

[root@gitlab ~]# ll /opt/gitlab/embedded/etc
total 12
-rw-r--r-- 1 root root 24 Apr 12 23:18 90-omnibus-gitlab-kernel.shmall.conf
-rw-r--r-- 1 root root 28 Apr 12 23:17 90-omnibus-gitlab-kernel.shmmax.conf
-rwxr-xr-x 1 root root 196 Apr 12 23:16 gitconfig

[root@gitlab ~]# ll /opt/gitlab/embedded/etc/90-omnibus-gitlab-kernel.sem.conf
ls: cannot access /opt/gitlab/embedded/etc/90-omnibus-gitlab-kernel.sem.conf: No such file or directory
[root@gitlab ~]# ll /opt/gitlab/embedded/etc/90-omnibus-gitlab-net.core.somaxconn.conf
ls: cannot access /opt/gitlab/embedded/etc/90-omnibus-gitlab-net.core.somaxconn.conf: No such file or directory

Solution one:
Copy the two files back from another backup machine (or reinstall it on another machine and generate the two files after "gitlab-ctl reconfigure")!

Solution two:
[root@gitlab ~]# vim /etc/gitlab/gitlab.rb
# unicorn['port'] = 8080
Modify to:
unicorn['port'] = 8090

After that, reload the configuration file
[root@gitlab ~]# gitlab-ctl reconfigure

Again, you will get an error, and then modify /etc/gitlab/gitlab.rb to the original configuration
[root@gitlab ~]# vim /etc/gitlab/gitlab.rb
# unicorn['port'] = 8080

Reload the config file again and it's OK!
[root@gitlab ~]# gitlab-ctl reconfigure

Checking again, I see that the two files that reported the error in the configuration above already exist
[root@gitlab ~]# ll /opt/gitlab/embedded/etc/
total 20
-rw-r--r-- 1 root root 30 Apr 12 23:33 90-omnibus-gitlab-kernel.sem.conf
-rw-r--r-- 1 root root 24 Apr 12 23:18 90-omnibus-gitlab-kernel.shmall.conf
-rw-r--r-- 1 root root 28 Apr 12 23:17 90-omnibus-gitlab-kernel.shmmax.conf
-rw-r--r-- 1 root root 26 Apr 12 23:35 90-omnibus-gitlab-net.core.somaxconn.conf
-rwxr-xr-x 1 root root 196 Apr 12 23:16 gitconfig
[root@gitlab ~]# ll /opt/gitlab/embedded/etc/90-omnibus-gitlab-kernel.sem.conf
-rw-r--r-- 1 root root 30 Apr 12 23:33 /opt/gitlab/embedded/etc/90-omnibus-gitlab-kernel.sem.conf
[root@gitlab ~]# ll /opt/gitlab/embedded/etc/90-omnibus-gitlab-net.core.somaxconn.conf
-rw-r--r-- 1 root root 26 Apr 12 23:35 /opt/gitlab/embedded/etc/90-omnibus-gitlab-net.core.somaxconn.conf

Finally, start gitlab again
[root@gitlab ~]# gitlab-ctl start

6、Gitlab Changes Default Nginx

Replace the Nginx that comes with gitlab and use self-compiled Nginx to manage the gitlab service.

    Self-compiled nginx service and gitlab on the same machine
1) Edit the gitlab configuration file to disable the self-compiled Nignx server
[root@gitlab ~]# vim /etc/gitlab/gitlab.rb
...
# Set nginx to false, disable self Nginx
nginx['enable'] = false
...

2) Check the default nginx configuration file and migrate it to the new Nginx service (i.e., migrate the following two gitlab nginx configuration files to the new nginx configuration compiled by yourself)
/var/opt/gitlab/nginx/conf/nginx.conf #nginx configuration file, including gitlab-http.conf file
/var/opt/gitlab/nginx/conf/gitlab-http.conf #gitlab core nginx configuration file

[root@gitlab ~]# cp /var/opt/gitlab/nginx/conf/nginx.conf /etc/nginx/conf.d/
[root@gitlab ~]# cp /var/opt/gitlab/nginx/conf/gitlab-http.conf /etc/nginx/conf.d/

3) Restart the gitlab service
[root@gitlab ~]# gitlab-ctl reconfigure
[root@gitlab ~]# gitlab-ctl restart

Restart the self-compiled nginx service
[root@gitlab ~]# service nginx restart

If you get a 502, the reason is that the nginx user cannot access the gitlab user's socket file.
Restarting gitlab requires reauthorization
[root@gitlab ~]# chmod -R o+x /var/opt/gitlab/gitlab-rails