gitlab installation, use, backup and restore

Gitlab installation

Yum installation:

Official website: https://about.gitlab.com

Official installation document: https://about.gitlab.com/install/#centos-7

Tsinghua University source: https://mirror.tuna.tsinghua.edu.cn/help/gitlab-ce/

rpm package download address: https://packages.gitlab.com/gitlab/gitlab-ce

New /etc/yum.repos.d/gitlab_gitlab-ce.repo

[root@jinkai gitlab]# vim /etc/yum.repos.d/gitlab_gitlab-ce.repo

[root@jinkai gitlab]# cat !$

cat /etc/yum.repos.d/gitlab_gitlab-ce.repo

[gitlab-this]

name=Gitlab CE Repository

baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/

gpgcheck=0

enabled=1

Install dependent packages:

[root@jinkai gitlab]#yum -y install curl openssh-server openssh-clients postfix cronie

Install gitlab:

[root@jinkai gitlab]# yum install gitlab-ce

Rpm package installation:

[root@jinkai tools]# mkdir -p /service/tools

[root @ jinkai tools] # cd / service / tools /

[root@jinkai tools]# rpm -ivh https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-10.8.4-ce.0.el7.x86_64.rpm

Configuration takes effect and restart service

[root@jinkai gitlab]#gitlab-ctl reconfigure

[root@jinkai gitlab]# gitlab-ctl restart

Commonly used commands:

gitlab-ctl start # Start all gitlab components;

gitlab-ctl stop # Stop all gitlab components;

gitlab-ctl restart # restart all gitlab components;

gitlab-ctl status # View service status;

vim /etc/gitlab/gitlab.rb # Modify the gitlab configuration file;

gitlab-ctl reconfigure # Recompile the configuration of gitlab;

gitlab-rake gitlab:check SANITIZE=true --trace # 检查gitlab;

gitlab-ctl tail # View log;

gitlab-ctl tail nginx/gitlab_access.log

Configure the domain name: vim /var/opt/gitlab/nginx/conf/gitlab-http.conf

# ``外网访问的端口,如果服务器已经有服务器占用了80,那么这里可以改成其它
  listen *:8888;
  server_name gitlab.test.domain.com;

  set $http_host_with_default "gitlab.test.domain.com:8888";

Supplementary note: Because this custom nginx configuration will be regenerated when compiling the gitlab configuration /etc/gitlab/gitlab.rb, so as long as the gitlab configuration is configured well, the above nginx does not need to be customized.

The webpage can be directly accessed by entering the IP

img

Encountering a 502 error may be a permission problem

chmod -R 755 /var/log/gitlab

Then re-enter the IP to visit the web page, the default administrator root, no password, it will let us define a password

img

img

You can choose to create a new project, create a new combination and create a new user according to your needs

New Project:

img

When creating, you can choose to create it under your own user or create it in a group

img

Project name, the project name can be composed of letters, numbers, spaces, underscores, underscores, and dots, and must start with a letter or number, and cannot be in Chinese

project description

Visibility (library category)

Private library: only visible to users who have been granted permissions

Internal library: logged in users can download

Public library: everyone can download

The project is successfully created. At this time, if the client wants to use the project, it also needs to establish a key file with the client to perform the client's operation on the project.

img

Client generates secret key

[root@jinkai tools]# ssh-keygen

Generating public/private rsa key pair.

Enter file in which to save the key (/root/.ssh/id_rsa):

Enter passphrase (empty for no passphrase):

Enter same passphrase again:

Your identification has been saved in /root/.ssh/id_rsa.

Your public key has been saved in /root/.ssh/id_rsa.pub.

The key fingerprint is:

SHA256:h/2mcO56hbV3gyPf8SpVO98XY1ykyjbLVtaUzuQwiTE [email protected]

The key's randomart image is:

+ --- [RSA 2048] ---- +

| |

| E .|

| + .o. |

| o .. +. o + |

| S o+ oX+o|

| ..oBo = & o |

| . .+=B+.X|

| + .o =. . = |

| .++. ....|

+----[SHA256]-----+

[root @ jinkai tools] # cat /root/.ssh/id_rsa.pub

AAAAB3NzaC1yc2EAAAADAQABAAABAQC6uxDaTJEtRnM65QQJ2NsKjPLQ8FOvAs18gySLJvRKi ssh RSA / 9XTS01n13uwwYtekkR4QvIQsiai7ndhuEv22UZtCiwEkCTw7xAUyCuOzBe81E8jSSaU3cpqK7p67hveyxRUbLG7B3aHwfGFw1xy / mJr1GL96nRJFah9E / cODfdfjIX + tL56jtgpygL3yIUW7fowvwjAjpgkJp8N6Idw6AxD3nrVjATV8Kf2GssnkbIAQ2TI4YrpXh6DLS2exkW1HVRgQdj3ZzFP8PVJCF5Ve9xV7DclXJP4l6X2Lyi3Bx9U50L8SzMesQEFeGdZVFCGBe6AfuIoRHr4dp5j39CREIOhF83 [email protected]

Copy the public key above into gitlab

img img

Create a group:

img img img

New user:

img img

The user’s password will be sent in the form of an email, but the mailbox service is currently not enabled. After creating the user below, edit the user’s password again

img img

Verify that the password is valid, log out and log in again

img img

New projects and groups can also be created under the newly created user linuxprobe

img

GitLab backup and restore

Backup:

# ``可以将此命令写入crontab,以实现定时备份

[root@jinkai tools]# gitlab-rake gitlab:backup:create

The backed up data will be stored in /var/opt/gitlab/backups

[root@jinkai tools]# ls /var/opt/gitlab/backups/

1607965594_2020_12_15_10.8.4_gitlab_backup.tar

restore:

# ``停止unicorn和sidekiq,保证数据库没有新的连接,不会有写数据情况

[root@jinkai tools]# gitlab-ctl stop unicorn

ok: down: unicorn: 0s, normally up

[root@jinkai tools]# gitlab-ctl stop sidekiq

ok: down: sidekiq: 0s, normally up

1607965594 is the timestamp of the backup file

[root@jinkai tools]# gitlab-rake gitlab:backup:restore BACKUP=1607965594

If 502 appears again:

chmod -R o+x /var/opt/gitlab/gitlab-rails

Backup and restore reference link:

https://cloud.tencent.com/developer/article/1622317?from=article.detail.1622316

Extended content

Svn files shared by classmates

http://note.youdao.com/noteshare?id=1bb87a28a2973ae5722bf765882c2d8f

svn multi-warehouse management http://elim.iteye.com/blog/1171108

svn+ssh http://www.linuxfly.org/post/450/

svn clear saved user name and password

http://holy2010.blog.51cto.com/1086044/645944

Detailed explanation of svn command http://blog.sina.com.cn/s/blog_963453200101eiuq.html

svn hook http://coolnull.com/1716.html

gitlab modify port http://blog.csdn.net/arybd/article/details/54635295

Modify the host name http://www.mamicode.com/info-detail-1316828.html

Third-party mail http://blog.csdn.net/liuruiqun/article/details/50000213

server ssh port is not 22

http://www.cnblogs.com/limx/p/5709101.html http://www.linuxidc.com/Linux/2017-02/141043.htm

Should be modified

/opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml

“# If you use non-standard ssh port you need to specify it”

ssh_port: xxxxx

Hook related configuration of gitlab http://fighter.blog.51cto.com/1318618/1670667

Guess you like

Origin blog.51cto.com/11451960/2640806