GitLab installation and use

GitLab is an open source application developed by Ruby on Rails. It implements a self managed Git project warehouse, which can access public or private projects through Web interface.

GitLab has similar functions to Github, which can browse source code, manage defects and comments. You can manage team access to the repository, which is very easy to browse submitted versions and provide a file history library. It also provides a code fragment collection function, which can easily realize code reuse and facilitate future search when necessary.

 

 

1. GitLab installation and configuration

1.1. Basic environment preparation

1 [root@mini04 ~]# yum install -y curl policycoreutils openssh-server openssh-clients postfix
2 ..................
3 [root@mini04 ~]# systemctl start postfix

 

1.2. Configure yum source

Note: due to network problems and domestic users, it is recommended to use the image source of Tsinghua University for installation:

1 [root@mini04 ~]# vim /etc/yum.repos.d/gitlab-ce.repo
2 [gitlab-ce]
3 name=gitlab-ce
4 baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/
5 repo_gpgcheck=0
6 gpgcheck=0
7 enabled=1
8 gpgkey=https://packages.gitlab.com/gpg.key

 

1.3. Update local yum cache

1 [root@mini04 ~]# yum makecache
2 ..................

 

1.4. Install GitLab

1 [root@mini04 ~]# yum install -y gitlab-ce
2 ..................

 

1.5. Configuration modification

1 [root@mini04 ~]# vim /etc/gitlab/gitlab.rb 
2 ..................
3 ## GitLab URL
4 ##! URL on which GitLab will be reachable.
5 ##! For more details on configuring external_url see:
6 ##! https://docs.gitlab.com/omnibus/settings/configuration.html#configuring-the-external-url-for-gitlab
7 # external_url 'http://gitlab.example.com'
8 # Able to parse
9 external_url 'http://mini04'

 

1.6. Configure and start gitlab CE

1 [root@mini04 ~]# gitlab-ctl reconfigure
2 ..................

 

1.7. View gitlab status

 1 [root@mini04 ~]# gitlab-ctl status  
 2 run: alertmanager: (pid 4075) 27s; run: log: (pid 4180) 25s
 3 run: gitaly: (pid 4004) 28s; run: log: (pid 4016) 28s
 4 run: gitlab-monitor: (pid 4025) 28s; run: log: (pid 4045) 27s
 5 run: gitlab-workhorse: (pid 3983) 28s; run: log: (pid 4049) 27s
 6 run: logrotate: (pid 3529) 90s; run: log: (pid 4051) 27s
 7 run: nginx: (pid 3506) 96s; run: log: (pid 4050) 27s
 8 run: node-exporter: (pid 3710) 78s; run: log: (pid 4017) 28s
 9 run: postgres-exporter: (pid 4096) 26s; run: log: (pid 4196) 25s
10 run: postgresql: (pid 3229) 140s; run: log: (pid 3972) 29s
11 run: prometheus: (pid 4052) 27s; run: log: (pid 4070) 27s
12 run: redis: (pid 3154) 146s; run: log: (pid 4021) 28s
13 run: redis-exporter: (pid 3783) 66s; run: log: (pid 4041) 27s
14 run: sidekiq: (pid 3475) 103s; run: log: (pid 3974) 29s
15 run: unicorn: (pid 3432) 110s; run: log: (pid 3973) 30s

 

1.8. GitLab common commands

1 gitlab-ctl start    # Start all gitlab components;
2 gitlab-ctl stop        # Stop all gitlab components;
3 gitlab-ctl restart        # Restart all gitlab components;
4 gitlab-ctl status        # Check the service status;
5 gitlab-ctl reconfigure        # Start up services;
6 vim /etc/gitlab/gitlab.rb        # Modify the default configuration file;
7 gitlab-ctl tail        # View log;
8 gitlab-rake gitlab:check SANITIZE=true --trace    # Check gitlab;

 

 

2. Use of gitlab

2.1. First landing

1 http://10.0.0.14

 

The first login will require the password of the root user to be changed.

 

Then on the login page, use root to log in.

 

2.2. Add SSH Key information

 1 [root@mini04 ~]# ssh-keygen -t rsa
 2 Generating public/private rsa key pair.
 3 Enter file in which to save the key (/root/.ssh/id_rsa): 
 4 Created directory '/root/.ssh'.
 5 Enter passphrase (empty for no passphrase): 
 6 Enter same passphrase again: 
 7 Your identification has been saved in /root/.ssh/id_rsa.
 8 Your public key has been saved in /root/.ssh/id_rsa.pub.
 9 The key fingerprint is:
10 SHA256:ACvHut11cMKDaL1QzsrL3x23OyUl9cd7+kLfFW30cLM root@mini04
11 The key's randomart image is:
12 +---[RSA 2048]----+
13 |    . .          |
14 |   . O o      o.o|
15 |  . B * = .  . *=|
16 |   * o o =  . .EB|
17 |  . o . S .  o .+|
18 |   + o . .  . o.o|
19 |  . + .   . .+ o+|
20 |     . . . o..o o|
21 |      . . . oo o.|
22 +----[SHA256]-----+
23 [root@mini04 ~]# ll -d .ssh/
24 drwx------ 2 root root 38 Sep 17 22:26 .ssh/
25 [root@mini04 ~]# cd .ssh/
26 [root@mini04 .ssh]# ll
27 total 8
28 -rw------- 1 root root 1679 Sep 17 22:26 id_rsa
29 -rw-r--r-- 1 root root  393 Sep 17 22:26 id_rsa.pub
30 [root@mini04 .ssh]# cat id_rsa.pub 
31 ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCpqkXHf8f7UQSPVH0E40pydotJChFQliRSSmHQezVGh91AB++YfUeGPHHDWDgLCjefxCc+KnJrqJPrUR02K1OwJoC9X4K2x0+gJekEpfs9Yb7Y5hE5XiGz4Z6X+ybN015u3G9czVhV5XAT2M4q+couVgaPpf2npfqv9eqhTuh1W0336sKIvAj1N8iXzfSDbdaERCP2NscnTOrgmHZ8aVMvyyruslvQoNjgQN06/91R48aSqwD++kLOTChGo7qNC10H315UR7cX2MKME9ssuyf77azFLYYdBrALR//YjOoid/jkTHkCLO1ZvHdqakWK7YAHOwV/RocTcm71hqq3mLfz root@mini04

 

 

 

 

For the use of GitLab page, please refer to Baidu. For the command line use of git, please refer to the previous blogs.

Keywords: Linux GitLab ssh yum vim

Added by Jaehoon on Thu, 19 Dec 2019 23:06:39 +0200