Gitlab private warehouse is deployed again (3)

Reference article

GitLab download and installation_GitLab latest Chinese basic version download and installation-Jihu GitLab

Gitlab warehouse construction (detailed version)

Completely uninstall gitlab on CentOS_51CTO blog_centos uninstall

Simple and easy! Tutorial for installing GitLab Community Edition on CentOS 7_Justice Chaplin’s Blog-CSDN Blog

MobaXterm connects to the remote server and uses the Linux command line to upload and download files_mobaxerm connects to the server-CSDN blog Gitlab initialization is stuck_ruby_block[wait for redis service socket] action r-CSDN blog

Initial default password for Linux initial installation of gitlab_linux gitlab configuration initialization password-CSDN Blog

Install gitlab_gitlab unicorn under docker without -CSDN Blog

Centos7 gitlab installation_centos7 remote connection gitlab_25 years of blog – CSDN blog

This article mainly records the operation process of deploying Gitlab private warehouse on Centos7 on 2023/11/8, as well as the handling of problems in the process.

[root@gitlab ~]# hostnamectl
   Static hostname: gitlab
         Icon name: computer-vm
           Chassis: vm
        Machine ID: df82112c37d742c8a559f34d1de7fe71
           Boot ID: b4c33ccad67c4d8e9fd06cc71bf7e3b6
    Virtualization: vmware
  Operating System: CentOS Linux 7 (Core)
       CPE OS Name: cpe:/o:centos:centos:7
            Kernel: Linux 3.10.0-1160.el7.x86_64
      Architecture: x86-64

1. Download the gitlab CE package from the Tsinghua University open source software mirror station, and then upload it to Linux. Centos7 is used here.

Note: Different packages EL6, EL7, EL8 are seen during the download process

ELis the abbreviation of Red Hat Enterprise Linux (EL).

  • EL6 is a download for Red Hat 6.x, CentOS 6.x, and CloudLinux 6.x.
  • EL5 is a download for Red Hat 5.x, CentOS 5.x and CloudLinux 5.x.
  • EL7 is a download for Red Hat 7.x, CentOS 7.x, and CloudLinux 7.x.

Enter the directory of the file (folder) that needs to be copied on this machine, right-click “open MobaXterm terminal here”

Enter the command in the MobaXterm terminal

08/11/2023   15:25.23   /drives/c/Users/joy/Downloads  scp gitlab-ce-16.5.1-ce.0.el7.x86_64.rpm [email protected]: /root
gitlab-ce-16.5.1-ce.0.el7.x86_64.rpm 100% 1232MB 11.3MB/s 01:49

View uploaded files on the server

[root@gitlab ~]# ll
Total usage 2519352
-rw-------. 1 root root 1259 October 20 13:50 anaconda-ks.cfg
-rwx------. 1 root root 1288441378 November 7 13:04 gitlab-ce-16.3.6-ce.0.el7.x86_64.rpm
-rwx------. 1 root root 1291368668 November 8 15:27 gitlab-ce-16.5.1-ce.0.el7.x86_64.rpm

2. Install relevant dependencies and enable HTTP, HTTPS and SSH access in the system firewall

sudo yum install -y curl policycoreutils-python openssh-server perl
sudo systemctl enable sshd
sudo systemctl start sshd

sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --permanent --add-service=https
sudo systemctl reload firewalld

3. (Optional) Next, install Postfix to send email notifications. If you want to use another solution to send emails, skip this step and configure an external SMTP server after installing GitLab.

sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix

4. Installation. It took 3 consecutive installations before it was successful. The first 2 times a warning message popped up and it ended.

[root@gitlab ~]# rpm -i gitlab-ce-16.5.1-ce.0.el7.x86_64.rpm
Warning: gitlab-ce-16.5.1-ce.0.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, Key ID f27eab47: NOKEY
It looks like GitLab has not been configured yet; skipping the upgrade script.

       *. *.
      *** ***
     ***** *****
    .****** *******
    ******** ********
   ,,,,,,,,,****************,,,,,,,,,
  ,,,,,,,,,,,,********,,,,,,,,,,,,
  .,,,,,,,,,,,,*******,,,,,,,,,,,,,
      ,,,,,,,,,*****,,,,,,,,,.
         ,,,,,,,****,,,,,,
            .,,,***,,,,
                ,*,.



     _______ __ __ __
    / ____(_) /_/ / ____ _/ /_
   / / __/ / __/ / / __ `/ __ \
  / /_/ / / /_/ /___/ /_/ / /_/ /
  \____/_/\__/_____/\__,_/_.___/


Thank you for installing GitLab!
GitLab was unable to detect a valid hostname for your instance.
Please configure a URL for your GitLab instance by setting `external_url`
configuration in /etc/gitlab/gitlab.rb file.
Then, you can start your GitLab instance by running the following command:
  sudo gitlab-ctl reconfigure

For a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md

Help us improve the installation experience, let us know how we did with a 1 minute survey:
https://gitlab.fra1.qualtrics.com/jfe/form/SV_6kVqZANThUQ1bZb?installation=omnibus & amp;release=16-5

5. Modify gitlab configuration

vi /etc/gitlab/gitlab.rb 

Modify the gitlab access address to the server’s IP

external_url 'http://192.168.4.107:90'

Port: nginx[listen_port’] defaults to 80, we changed it to 90

nginx['listen_port'] = 90

6. Reload configuration and startup. It will get stuck here.

gitlab-ctl reconfigure // Execution here will be stuck

If it gets stuck in the following place (the previous installation and uninstallation were incomplete)

ruby_block[wait for redis service socket] action run

Liberation method: Re-open a port and execute the following command

/opt/gitlab/embedded/bin/runsvdir-start

After execution, the original window continues to move down until the following information is displayed, indicating that this step is successfully completed.

gitlab Configured!

7. Check the status of gitlab

[root@gitlab ~]# gitlab-ctl status
run: alertmanager: (pid 26208) 98s; run: log: (pid 25929) 115s
run: gitaly: (pid 26031) 109s; run: log: (pid 24248) 258s
run: gitlab-exporter: (pid 26170) 100s; run: log: (pid 25629) 136s
run: gitlab-kas: (pid 24555) 244s; run: log: (pid 24580) 243s
run: gitlab-workhorse: (pid 26018) 110s; run: log: (pid 25366) 153s
run: logrotate: (pid 23437) 309s; run: log: (pid 23457) 307s
run: nginx: (pid 25434) 149s; run: log: (pid 25451) 148s
run: node-exporter: (pid 26154) 100s; run: log: (pid 25581) 140s
run: postgres-exporter: (pid 26219) 98s; run: log: (pid 26026) 110s
run: postgresql: (pid 24361) 250s; run: log: (pid 24395) 249s
run: prometheus: (pid 26185) 99s; run: log: (pid 25839) 122s
run: puma: (pid 25162) 167s; run: log: (pid 25207) 164s
run: redis: (pid 24114) 268s; run: log: (pid 24145) 264s
run: redis-exporter: (pid 26172) 100s; run: log: (pid 25763) 128s
run: sidekiq: (pid 25231) 161s; run: log: (pid 25249) 160s

8. Add the port to the firewall

[root@gitlab ~]# firewall-cmd --zone=public --add-port=90/tcp --permanent
success
[root@gitlab ~]# firewall-cmd --reload
success
[root@gitlab ~]#

9. Check the default initial password of gitlab. This file will be automatically deleted 24 hours after reconfigure is executed for the first time.

vim /etc/gitlab/initial_root_password

10. Browser access: http://192.168.4.107:90, log in with root account and default password

The first thing after logging in is to change the login password. Path: Click on the avatar-edit profile-password.

(Optional) Change the custom language to Chinese. Path: Preferences-Localization-Language.

11. Log in to gitlab and create a new blank project. According to the command line instructions on the homepage of the new blank project, configure git in the local IDE and push the project code to the gitlab warehouse.

Git global settings
git config --global user.name "Administrator"
git config --global user.email "[email protected]"
Create a new warehouse
git clone http://192.168.4.107:90/root/ruoyi-vue.git
cd ruoyi-vue
git switch --create main
touch README.md
git add README.md
git commit -m "add README"
git push --set-upstream origin main
Push existing folder
cd existing_folder
git init --initial-branch=main
git remote add origin http://192.168.4.107:90/root/ruoyi-vue.git
git add .
git commit -m "Initial commit"
git push --set-upstream origin main
Push an existing Git repository
cd existing_repo
git remote rename origin old-origin
git remote add origin http://192.168.4.107:90/root/ruoyi-vue.git
git push --set-upstream origin --all
git push --set-upstream origin --tags

12. Open the terminal in IDEA and execute the following command for the first time

D:\workspace\RuoYi-Vue> git config --global user.name "571934457"
D:\workspace\RuoYi-Vue> git config --global user.email "[email protected]"
D:\workspace\RuoYi-Vue> git init --initial-branch=main
Initialized empty Git repository in D:/workspace/RuoYi-Vue/.git/
PS D:\workspace\RuoYi-Vue> git remote add origin http://192.168.4.107:90/root/ruoyi-vue.git
PS D:\workspace\RuoYi-Vue> git add .
warning: in the working copy of '.idea/workspace.xml', LF will be replaced by CRLF the next time Git touches it
...
PS D:\workspace\RuoYi-Vue> git commit -m "Initial commit"
[main (root-commit) 67356c4] Initial commit
 921 files changed, 70578 insertions( + )
...
 D:\workspace\RuoYi-Vue> git push --set-upstream origin main
Enumerating objects: 1216, done.
Counting objects: 100% (1216/1216), done.
Delta compression using up to 8 threads
Compressing objects: 100% (1086/1086), done.
Writing objects: 100% (1216/1216), 2.26 MiB | 4.62 MiB/s, done.
Total 1216 (delta 118), reused 0 (delta 0), pack-reused 0
remote: Resolving deltas: 100% (118/118), done.
To http://192.168.4.107:90/root/ruoyi-vue.git
 * [new branch] main -> main
branch 'main' set up to track 'origin/main'.

13. The project code has been uploaded to the gitlab warehouse

?

14.gitlab start and stop related operations

gitlab-ctl status
Use the console to view logs in real time
# View all logs; press Ctrl-C to exit
gitlab-ctl tail
# Pull the logs from the subdirectory under /var/log/gitlab
gitlab-ctl tail gitlab-rails
# Pull a specified log file
gitlab-ctl tail nginx/gitlab_error.log
#Start and shut down gitlab
gitlab-ctl start
gitlab-ctl stop #Stop
gitlab-ctl status #View status
gitlab-ctl restart #restart
gitlab-ctl reconfigure #Update the configuration file to make the configuration effective
gitlab-ctl help #help
gitlab-rake gitlab:check SANITIZE=true --trace #Check gitlab
#gitlab The default log file is stored in the /var/log/gitlab directory
gitlab-ctl tail #View all logs
#Disable Gitlab from starting at boot
systemctl disable gitlab-runsvdir.service
#Enable Gitlab to start automatically at boot
systemctl enable gitlab-runsvdir.service

15. Failed to start gitlab, execute systemctl start gitlab-runsvdir, which is used to start the gitlab running service directory (runsvdir)

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: node-exporter: runsv not running
fail: postgres-exporter: runsv not running
fail: postgresql: runsv not running
fail: prometheus: runsv not running
fail: redis: runsv not running
fail: redis-exporter: runsv not running
fail: sidekiq: runsv not running
fail: unicorn: runsv not running

16. When gitlab takes up too much memory, execute vim /etc/gitlab/gitlab.rb and modify the gitlab configuration file.

If you want the memory usage to be relatively small, the old version can use /unicorn to find the number of people who have worker_processes set to work;

unicorn['worker_processes'] = 2

In the new version, all are replaced with puma. Use /puma to find the corresponding place, uncomment or add a new line directly.

puma[enable’] = true
puma[worker_timeout’] = 60
puma[worker_processes’] = 2 # Based on the number of users
puma[max_threads’] = 4
puma[per_worker_max_memory_mb’] = 1024
sidekiq[max_concurrency’] = 16
postgresql[shared_buffers’] = “256MB”
postgresql[max_worker_processes’] = 8

Before optimization

After optimization (to be added)