CentOS 7 上 GitLab 的安装、备份、迁移及恢复 发布 2018-11-14 / 更新 2020-05-13 / 4,931 次 / 快抢沙发 /

GitLab 是目前最适合公司进行代码管理的系统,采用自己公司服务器来搭建 GitLab 是最好的选择。

本文是 AppX 系列中的一篇。AppX 系列是 @ifeegoo 个人移动互联网学习、工作和生活的提炼与总结的文章系列。更多内容请关注:
AppX @ifeegoo https://www.ifeegoo.com/appx.html

GitLab 是目前最适合公司进行代码管理的系统,采用自己公司服务器来搭建 GitLab 是最好的选择。

以下便是记录 GitLab 在 CentOS 7.x 上安装、备份、迁移及恢复的步骤。

CentOS 7.x 上 GitLab 的安装。
备注:GitLab 官方安装步骤参考文档

相关操作环境:
CentOS 7.5 64位
GitLab

注意:在官方文档 GitLab CE 版本和 GitLab EE 版本如何选择中,我们可以看到,安装 GitLab EE 版本会更好,你没有相关企业版本 [EE] 授权,就相当于社区版本 [CE] 版本,也不影响使用,将来想要从社区版本 [CE] 转成企业版本 [EE] 也是相当的方便,因此接下来我们安装的是企业版本 [EE] 的 GitLab。

1.安装和配置必要的依赖库:

在 CentOS 7 中,以下命令行会同时在系统防火墙中打开 HTTP 和 SSH 的访问。

# sudo yum install -y curl policycoreutils-python openssh-server
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
epel                                                                                                                                | 3.2 kB  00:00:00     
extras                                                                                                                              | 3.4 kB  00:00:00     
os                                                                                                                                  | 3.6 kB  00:00:00     
updates                                                                                                                             | 3.4 kB  00:00:00     
(1/3): extras/7/x86_64/primary_db                                                                                                   | 205 kB  00:00:00     
(2/3): epel/7/x86_64/updateinfo                                                                                                     | 932 kB  00:00:00     
(3/3): epel/7/x86_64/primary                                                                                                        | 3.6 MB  00:00:00     
epel                                                                                                                                           12698/12698
Package curl-7.29.0-46.el7.x86_64 already installed and latest version
Package openssh-server-7.4p1-16.el7.x86_64 already installed and latest version
Resolving Dependencies
--> Running transaction check
---> Package policycoreutils-python.x86_64 0:2.5-22.el7 will be installed
--> Processing Dependency: setools-libs >= 3.3.8-2 for package: policycoreutils-python-2.5-22.el7.x86_64
--> Processing Dependency: libsemanage-python >= 2.5-9 for package: policycoreutils-python-2.5-22.el7.x86_64
--> Processing Dependency: audit-libs-python >= 2.1.3-4 for package: policycoreutils-python-2.5-22.el7.x86_64
--> Processing Dependency: python-IPy for package: policycoreutils-python-2.5-22.el7.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.4)(64bit) for package: policycoreutils-python-2.5-22.el7.x86_64
--> Processing Dependency: libqpol.so.1(VERS_1.2)(64bit) for package: policycoreutils-python-2.5-22.el7.x86_64
--> Processing Dependency: libcgroup for package: policycoreutils-python-2.5-22.el7.x86_64
--> Processing Dependency: libapol.so.4(VERS_4.0)(64bit) for package: policycoreutils-python-2.5-22.el7.x86_64
--> Processing Dependency: checkpolicy for package: policycoreutils-python-2.5-22.el7.x86_64
--> Processing Dependency: libqpol.so.1()(64bit) for package: policycoreutils-python-2.5-22.el7.x86_64
--> Processing Dependency: libapol.so.4()(64bit) for package: policycoreutils-python-2.5-22.el7.x86_64
--> Running transaction check
---> Package audit-libs-python.x86_64 0:2.8.1-3.el7_5.1 will be installed
--> Processing Dependency: audit-libs(x86-64) = 2.8.1-3.el7_5.1 for package: audit-libs-python-2.8.1-3.el7_5.1.x86_64
---> Package checkpolicy.x86_64 0:2.5-6.el7 will be installed
---> Package libcgroup.x86_64 0:0.41-15.el7 will be installed
---> Package libsemanage-python.x86_64 0:2.5-11.el7 will be installed
---> Package python-IPy.noarch 0:0.75-6.el7 will be installed
---> Package setools-libs.x86_64 0:3.3.8-2.el7 will be installed
--> Running transaction check
---> Package audit-libs.x86_64 0:2.8.1-3.el7 will be updated
--> Processing Dependency: audit-libs(x86-64) = 2.8.1-3.el7 for package: audit-2.8.1-3.el7.x86_64
---> Package audit-libs.x86_64 0:2.8.1-3.el7_5.1 will be an update
--> Running transaction check
---> Package audit.x86_64 0:2.8.1-3.el7 will be updated
---> Package audit.x86_64 0:2.8.1-3.el7_5.1 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

===========================================================================================================================================================
 Package                                       Arch                          Version                                  Repository                      Size
===========================================================================================================================================================
Installing:
 policycoreutils-python                        x86_64                        2.5-22.el7                               os                             454 k
Installing for dependencies:
 audit-libs-python                             x86_64                        2.8.1-3.el7_5.1                          updates                         75 k
 checkpolicy                                   x86_64                        2.5-6.el7                                os                             294 k
 libcgroup                                     x86_64                        0.41-15.el7                              os                              65 k
 libsemanage-python                            x86_64                        2.5-11.el7                               os                             112 k
 python-IPy                                    noarch                        0.75-6.el7                               os                              32 k
 setools-libs                                  x86_64                        3.3.8-2.el7                              os                             619 k
Updating for dependencies:
 audit                                         x86_64                        2.8.1-3.el7_5.1                          updates                        247 k
 audit-libs                                    x86_64                        2.8.1-3.el7_5.1                          updates                         99 k

Transaction Summary
===========================================================================================================================================================
Install  1 Package  (+6 Dependent packages)
Upgrade             ( 2 Dependent packages)

Total download size: 2.0 M
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
(1/9): audit-libs-2.8.1-3.el7_5.1.x86_64.rpm                                                                                        |  99 kB  00:00:00     
(2/9): audit-2.8.1-3.el7_5.1.x86_64.rpm                                                                                             | 247 kB  00:00:00     
(3/9): audit-libs-python-2.8.1-3.el7_5.1.x86_64.rpm                                                                                 |  75 kB  00:00:00     
(4/9): libcgroup-0.41-15.el7.x86_64.rpm                                                                                             |  65 kB  00:00:00     
(5/9): checkpolicy-2.5-6.el7.x86_64.rpm                                                                                             | 294 kB  00:00:00     
(6/9): libsemanage-python-2.5-11.el7.x86_64.rpm                                                                                     | 112 kB  00:00:00     
(7/9): python-IPy-0.75-6.el7.noarch.rpm                                                                                             |  32 kB  00:00:00     
(8/9): policycoreutils-python-2.5-22.el7.x86_64.rpm                                                                                 | 454 kB  00:00:00     
(9/9): setools-libs-3.3.8-2.el7.x86_64.rpm                                                                                          | 619 kB  00:00:00     
-----------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                      3.9 MB/s | 2.0 MB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : audit-libs-2.8.1-3.el7_5.1.x86_64                                                                                                      1/11 
  Installing : audit-libs-python-2.8.1-3.el7_5.1.x86_64                                                                                               2/11 
  Installing : python-IPy-0.75-6.el7.noarch                                                                                                           3/11 
  Installing : checkpolicy-2.5-6.el7.x86_64                                                                                                           4/11 
  Installing : libsemanage-python-2.5-11.el7.x86_64                                                                                                   5/11 
  Installing : setools-libs-3.3.8-2.el7.x86_64                                                                                                        6/11 
  Installing : libcgroup-0.41-15.el7.x86_64                                                                                                           7/11 
  Installing : policycoreutils-python-2.5-22.el7.x86_64                                                                                               8/11 
  Updating   : audit-2.8.1-3.el7_5.1.x86_64                                                                                                           9/11 
  Cleanup    : audit-2.8.1-3.el7.x86_64                                                                                                              10/11 
  Cleanup    : audit-libs-2.8.1-3.el7.x86_64                                                                                                         11/11 
  Verifying  : libcgroup-0.41-15.el7.x86_64                                                                                                           1/11 
  Verifying  : setools-libs-3.3.8-2.el7.x86_64                                                                                                        2/11 
  Verifying  : policycoreutils-python-2.5-22.el7.x86_64                                                                                               3/11 
  Verifying  : libsemanage-python-2.5-11.el7.x86_64                                                                                                   4/11 
  Verifying  : checkpolicy-2.5-6.el7.x86_64                                                                                                           5/11 
  Verifying  : python-IPy-0.75-6.el7.noarch                                                                                                           6/11 
  Verifying  : audit-libs-2.8.1-3.el7_5.1.x86_64                                                                                                      7/11 
  Verifying  : audit-2.8.1-3.el7_5.1.x86_64                                                                                                           8/11 
  Verifying  : audit-libs-python-2.8.1-3.el7_5.1.x86_64                                                                                               9/11 
  Verifying  : audit-libs-2.8.1-3.el7.x86_64                                                                                                         10/11 
  Verifying  : audit-2.8.1-3.el7.x86_64                                                                                                              11/11 

Installed:
  policycoreutils-python.x86_64 0:2.5-22.el7                                                                                                               

Dependency Installed:
  audit-libs-python.x86_64 0:2.8.1-3.el7_5.1  checkpolicy.x86_64 0:2.5-6.el7     libcgroup.x86_64 0:0.41-15.el7  libsemanage-python.x86_64 0:2.5-11.el7 
  python-IPy.noarch 0:0.75-6.el7              setools-libs.x86_64 0:3.3.8-2.el7 

Dependency Updated:
  audit.x86_64 0:2.8.1-3.el7_5.1                                            audit-libs.x86_64 0:2.8.1-3.el7_5.1                                           

Complete!
# sudo systemctl enable sshd
# sudo systemctl start sshd
# sudo firewall-cmd --permanent --add-service=http
FirewallD is not running
# systemctl start firewalld
# sudo firewall-cmd --permanent --add-service=http
success
# sudo systemctl reload firewalld

下一步,通过安装 Postfix 发送邮件通知。如果你想要使用其他的解决方案来发送邮件,请跳过此步骤,在 GitLab 安装之后,配置外部的 SMTP 服务器
备注:此系统内部预装了 Postfix 服务,所以不用安装。

[root@VM_129_173_centos ~]# sudo yum install postfix
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Package 2:postfix-2.10.1-6.el7.x86_64 already installed and latest version
Nothing to do
[root@VM_129_173_centos ~]# sudo systemctl enable postfix
[root@VM_129_173_centos ~]# sudo systemctl start postfix
Job for postfix.service failed because the control process exited with error code. See "systemctl status postfix.service" and "journalctl -xe" for details.

我们在启用 Postfix 服务的时候,提示错误,我们通过命令行查看:

# systemctl status postfix.service
● postfix.service - Postfix Mail Transport Agent
   Loaded: loaded (/usr/lib/systemd/system/postfix.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Mon 2018-11-12 16:57:43 CST; 1min 13s ago
  Process: 3338 ExecStart=/usr/sbin/postfix start (code=exited, status=1/FAILURE)
  Process: 3336 ExecStartPre=/usr/libexec/postfix/chroot-update (code=exited, status=0/SUCCESS)
  Process: 3332 ExecStartPre=/usr/libexec/postfix/aliasesdb (code=exited, status=75)

Nov 12 16:57:41 VM_129_173_centos systemd[1]: Starting Postfix Mail Transport Agent...
Nov 12 16:57:41 VM_129_173_centos aliasesdb[3332]: /usr/sbin/postconf: fatal: parameter inet_interfaces: no local interface found for ::1
Nov 12 16:57:42 VM_129_173_centos aliasesdb[3332]: newaliases: fatal: parameter inet_interfaces: no local interface found for ::1
Nov 12 16:57:42 VM_129_173_centos postfix[3338]: fatal: parameter inet_interfaces: no local interface found for ::1
Nov 12 16:57:43 VM_129_173_centos systemd[1]: postfix.service: control process exited, code=exited status=1
Nov 12 16:57:43 VM_129_173_centos systemd[1]: Failed to start Postfix Mail Transport Agent.
Nov 12 16:57:43 VM_129_173_centos systemd[1]: Unit postfix.service entered failed state.
Nov 12 16:57:43 VM_129_173_centos systemd[1]: postfix.service failed.

以上命令提示信息也看不出什么,通过 Google 搜索,有一个解决方案:找到 /etc/postfix/main.cf 这个配置文件。将里面的如下配置修改:

inet_interfaces = localhost
# 修改成
inet_interfaces = all

然后重启 Postfix 服务,再启动 Postfix,就没有什么问题了!

[root@VM_129_173_centos ~]# service postfix restart
Redirecting to /bin/systemctl restart postfix.service
[root@VM_129_173_centos ~]# sudo systemctl start postfix

如果系统上没有安装过 Postfix,那么在安装的过程中,会出现相关的配置,选择 ‘Internet Site’ 回车即可。使用你服务器外部 DNS 作为 ‘mail name’ 然后回车,若有其他选项,保持默认即可。

2.添加 GitLab 包仓库并安装包

添加 GitLab 包仓库:

# curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.rpm.sh | sudo bash
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100  6463    0  6463    0     0   4400      0 --:--:--  0:00:01 --:--:--  4402
Detected operating system as centos/7.
Checking for curl...
Detected curl...
Downloading repository file: https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/config_file.repo?os=centos&dist=7&source=script
done.
Installing pygpgme to verify GPG signatures...
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
gitlab_gitlab-ee-source/signature                                                                                                   |  836 B  00:00:00     
Retrieving key from https://packages.gitlab.com/gitlab/gitlab-ee/gpgkey
Importing GPG key 0xE15E78F4:
 Userid     : "GitLab B.V. (package repository signing key) <packages@gitlab.com>"
 Fingerprint: 1a4c 919d b987 d435 9396 38b9 1421 9a96 e15e 78f4
 From       : https://packages.gitlab.com/gitlab/gitlab-ee/gpgkey
Retrieving key from https://packages.gitlab.com/gitlab/gitlab-ee/gpgkey/gitlab-gitlab-ee-3D645A26AB9FBD22.pub.gpg
gitlab_gitlab-ee-source/signature                                                                                                   |  951 B  00:00:01 !!! 
gitlab_gitlab-ee-source/primary                                                                                                     |  175 B  00:00:01     
Package pygpgme-0.3-9.el7.x86_64 already installed and latest version
Nothing to do
Installing yum-utils...
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package yum-utils.noarch 0:1.1.31-45.el7 will be updated
---> Package yum-utils.noarch 0:1.1.31-46.el7_5 will be an update
--> Finished Dependency Resolution

Dependencies Resolved

===========================================================================================================================================================
 Package                             Arch                             Version                                      Repository                         Size
===========================================================================================================================================================
Updating:
 yum-utils                           noarch                           1.1.31-46.el7_5                              updates                           120 k

Transaction Summary
===========================================================================================================================================================
Upgrade  1 Package

Total download size: 120 k
Downloading packages:
Delta RPMs disabled because /usr/bin/applydeltarpm not installed.
yum-utils-1.1.31-46.el7_5.noarch.rpm                                                                                                | 120 kB  00:00:00     
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
  Updating   : yum-utils-1.1.31-46.el7_5.noarch                                                                                                        1/2 
  Cleanup    : yum-utils-1.1.31-45.el7.noarch                                                                                                          2/2 
  Verifying  : yum-utils-1.1.31-46.el7_5.noarch                                                                                                        1/2 
  Verifying  : yum-utils-1.1.31-45.el7.noarch                                                                                                          2/2 

Updated:
  yum-utils.noarch 0:1.1.31-46.el7_5                                                                                                                       

Complete!
Generating yum cache for gitlab_gitlab-ee...
Importing GPG key 0xE15E78F4:
 Userid     : "GitLab B.V. (package repository signing key) <packages@gitlab.com>"
 Fingerprint: 1a4c 919d b987 d435 9396 38b9 1421 9a96 e15e 78f4
 From       : https://packages.gitlab.com/gitlab/gitlab-ee/gpgkey

The repository is setup! You can now install packages.

下一步,安装 GitLab 包,将 `http://gitlab.example.com` URL 修改成你想要访问 GitLab 的实例。安装过程会自动配置,并在此 URL 启动 GitLab。HTTPS 在安装之后,需要额外的配置

// sudo EXTERNAL_URL="http://gitlab.example.com" yum install -y gitlab-ee
# sudo EXTERNAL_URL="http://gitlab.ifeegoo.com" yum install -y gitlab-ee



Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
Resolving Dependencies
--> Running transaction check
---> Package gitlab-ee.x86_64 0:11.4.5-ee.0.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

===========================================================================================================================================================
 Package                           Arch                           Version                                   Repository                                Size
===========================================================================================================================================================
Installing:
 gitlab-ee                         x86_64                         11.4.5-ee.0.el7                           gitlab_gitlab-ee                         487 M

Transaction Summary
===========================================================================================================================================================
Install  1 Package

Total download size: 487 M
Installed size: 1.4 G
Downloading packages:****
***
***
Running handlers complete
Chef Client failed. 434 resources updated in 06 minutes 16 seconds
warning: %posttrans(gitlab-ee-11.4.5-ee.0.el7.x86_64) scriptlet failed, exit status 1
Non-fatal POSTTRANS scriptlet failure in rpm package gitlab-ee-11.4.5-ee.0.el7.x86_64
  Verifying  : gitlab-ee-11.4.5-ee.0.el7.x86_64                                                                                                        1/1 

Installed:
  gitlab-ee.x86_64 0:11.4.5-ee.0.el7                                                                                                                       

Complete!

我暂时将这个 GitLab 的地址指向 http://gitlab.ifeegoo.com。我们安装好,并且配置好域名指向之后,访问发现以下错误:

centos-7-gitlab-installation-502-gitLab-is-taking-too-much-time-to-respond

我们可以通过 gitlab-ctl 命令得到一些参考日志信息,我们保存日志之后,通过查找 warning,failed 或者 error 关键词来查找相关的参考。另外也请注意查看:/var/log/gitlab 子目录底下的 Log 日志。

# gitlab-ctl tail
==> /var/log/gitlab/gitlab-monitor/current <==
2018-11-13_08:34:30.17021 127.0.0.1 - - [13/Nov/2018:16:34:29 CST] "GET /process HTTP/1.1" 200 104
2018-11-13_08:34:30.17021 - -> /process
2018-11-13_08:34:30.33189 127.0.0.1 - - [13/Nov/2018:16:34:30 CST] "GET /process HTTP/1.1" 200 104
2018-11-13_08:34:30.33190 - -> /process
2018-11-13_08:34:30.43173 127.0.0.1 - - [13/Nov/2018:16:34:29 CST] "GET /database HTTP/1.1" 200 94727
2018-11-13_08:34:30.43175 - -> /database
2018-11-13_08:34:30.66573 127.0.0.1 - - [13/Nov/2018:16:34:30 CST] "GET /database HTTP/1.1" 200 94727
2018-11-13_08:34:30.66575 - -> /database
2018-11-13_08:34:32.71828 127.0.0.1 - - [13/Nov/2018:16:34:32 CST] "GET /sidekiq HTTP/1.1" 200 26
2018-11-13_08:34:32.71830 - -> /sidekiq

==> /var/log/gitlab/unicorn/unicorn_stderr.log <==
I, [2018-11-12T20:33:25.893804 #4973]  INFO -- : Refreshing Gem list
I, [2018-11-12T20:34:52.545928 #5207]  INFO -- : Refreshing Gem list
I, [2018-11-13T16:22:23.295373 #1324]  INFO -- : Refreshing Gem list
I, [2018-11-13T16:24:24.960101 #1701]  INFO -- : Refreshing Gem list
I, [2018-11-13T16:25:44.332280 #1869]  INFO -- : Refreshing Gem list
I, [2018-11-13T16:27:26.953284 #2073]  INFO -- : Refreshing Gem list
I, [2018-11-13T16:29:24.213776 #2260]  INFO -- : Refreshing Gem list
I, [2018-11-13T16:30:39.039260 #2411]  INFO -- : Refreshing Gem list
I, [2018-11-13T16:32:00.365238 #2554]  INFO -- : Refreshing Gem list
I, [2018-11-13T16:33:24.932720 #2732]  INFO -- : Refreshing Gem list

==> /var/log/gitlab/unicorn/unicorn_stdout.log <==

==> /var/log/gitlab/unicorn/current <==
2018-11-13_08:29:22.00674 starting new unicorn master
2018-11-13_08:30:34.11509 master failed to start, check stderr log for details
2018-11-13_08:30:35.91004 failed to start a new unicorn master
2018-11-13_08:30:36.01299 starting new unicorn master
2018-11-13_08:31:55.80923 master failed to start, check stderr log for details
2018-11-13_08:31:57.10317 failed to start a new unicorn master
2018-11-13_08:31:57.20874 starting new unicorn master
2018-11-13_08:33:19.78558 master failed to start, check stderr log for details
2018-11-13_08:33:21.22905 failed to start a new unicorn master
2018-11-13_08:33:21.29079 starting new unicorn master

==> /var/log/gitlab/postgres-exporter/current <==
2018-11-13_08:22:14.56267 time="2018-11-13T16:22:14+08:00" level=info msg="Established new database connection." source="postgres_exporter.go:995"
2018-11-13_08:22:14.59324 time="2018-11-13T16:22:14+08:00" level=info msg="Error while closing non-pinging DB connection: <nil>" source="postgres_exporter.go:1001"
2018-11-13_08:22:14.59326 time="2018-11-13T16:22:14+08:00" level=info msg="Error opening connection to database (user=gitlab-psql%20host=/var/opt/gitlab/postgresql%20database=postgres%20sslmode=allow): dial unix /var/opt/gitlab/postgresql/.s.PGSQL.5432: connect: no such file or directory" source="postgres_exporter.go:1030"
2018-11-13_08:22:14.59326 time="2018-11-13T16:22:14+08:00" level=info msg="Starting Server: localhost:9187" source="postgres_exporter.go:1137"
2018-11-13_08:22:29.96889 time="2018-11-13T16:22:29+08:00" level=info msg="Established new database connection." source="postgres_exporter.go:995"
2018-11-13_08:22:30.11867 time="2018-11-13T16:22:30+08:00" level=info msg="Semantic Version Changed: 0.0.0 -> 9.6.8" source="postgres_exporter.go:925"

==> /var/log/gitlab/prometheus/current <==
2018-11-13_08:22:17.68113 level=info ts=2018-11-13T08:22:17.670312141Z caller=compact.go:398 component=tsdb msg="write block" mint=1542060000000 maxt=1542067200000 ulid=01CW62KZ7HSP6TKRMKA70033PD
2018-11-13_08:22:17.69236 level=info ts=2018-11-13T08:22:17.683637004Z caller=head.go:446 component=tsdb msg="head GC completed" duration=1.488016ms
2018-11-13_08:22:17.78913 level=info ts=2018-11-13T08:22:17.77884655Z caller=compact.go:398 component=tsdb msg="write block" mint=1542067200000 maxt=1542074400000 ulid=01CW62KZB0QH1CNX9FYKG7SN2B
2018-11-13_08:22:17.80040 level=info ts=2018-11-13T08:22:17.79243572Z caller=head.go:446 component=tsdb msg="head GC completed" duration=1.409014ms
2018-11-13_08:22:17.88312 level=info ts=2018-11-13T08:22:17.872524627Z caller=compact.go:398 component=tsdb msg="write block" mint=1542074400000 maxt=1542081600000 ulid=01CW62KZEBHCRMKCGK5X8ZFSFR
2018-11-13_08:22:17.89541 level=info ts=2018-11-13T08:22:17.889136419Z caller=head.go:446 component=tsdb msg="head GC completed" duration=1.492571ms
2018-11-13_08:22:17.97913 level=info ts=2018-11-13T08:22:17.968839894Z caller=compact.go:398 component=tsdb msg="write block" mint=1542081600000 maxt=1542088800000 ulid=01CW62KZHC4AJ2FMRFYGKVANSX
2018-11-13_08:22:17.99143 level=info ts=2018-11-13T08:22:17.989074475Z caller=head.go:446 component=tsdb msg="head GC completed" duration=1.802067ms
2018-11-13_08:22:18.27314 level=info ts=2018-11-13T08:22:18.262186941Z caller=compact.go:352 component=tsdb msg="compact blocks" count=3 mint=1542024000000 maxt=1542045600000 ulid=01CW62KZMS4D83W9N0GFXR69FS sources="[01CW62KXV1QXNS9ATVYNZAHR91 01CW62KY9S09VEA0RY5QV23GPK 01CW62KYHBR7C875S3KNQ8FNDN]"
2018-11-13_08:22:18.47132 level=info ts=2018-11-13T08:22:18.461118256Z caller=compact.go:352 component=tsdb msg="compact blocks" count=3 mint=1542045600000 maxt=1542067200000 ulid=01CW62KZXYDSE27P6GNEPMETZ4 sources="[01CW62KYSMNDDTEJ7S6GMMSTF5 01CW62KZ06R6HCDTDGP3KZWR2J 01CW62KZ7HSP6TKRMKA70033PD]"

==> /var/log/gitlab/gitlab-workhorse/current <==
2018-11-13_08:30:50.57165 time="2018-11-13T16:30:50+08:00" level=error msg=error correlation-id=yxwOpvwUGY4 error="badgateway: failed after 0s: dial unix /var/opt/gitlab/gitlab-rails/sockets/gitlab.socket: connect: no such file or directory" method=GET uri=/favicon.ico
2018-11-13_08:30:50.57167 gitlab.ifeegoo.com @ - - [2018/11/13:16:30:50 +0800] "GET /favicon.ico HTTP/1.1" 502 2940 "http://gitlab.ifeegoo.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36" 0.001
2018-11-13_08:30:52.72495 time="2018-11-13T16:30:52+08:00" level=error msg=error correlation-id=HxWcAMXrRE6 error="badgateway: failed after 0s: dial unix /var/opt/gitlab/gitlab-rails/sockets/gitlab.socket: connect: no such file or directory" method=GET uri=/
2018-11-13_08:30:52.72677 gitlab.ifeegoo.com @ - - [2018/11/13:16:30:52 +0800] "GET / HTTP/1.1" 502 2940 "" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36" 0.048
2018-11-13_08:30:53.17844 time="2018-11-13T16:30:53+08:00" level=error msg=error correlation-id=mUtmxxAigk2 error="badgateway: failed after 0s: dial unix /var/opt/gitlab/gitlab-rails/sockets/gitlab.socket: connect: no such file or directory" method=GET uri=/favicon.ico
2018-11-13_08:30:53.17847 gitlab.ifeegoo.com @ - - [2018/11/13:16:30:53 +0800] "GET /favicon.ico HTTP/1.1" 502 2940 "http://gitlab.ifeegoo.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36" 0.002
2018-11-13_08:31:23.65612 time="2018-11-13T16:31:23+08:00" level=error msg=error correlation-id=BSMZ5CuoFc4 error="badgateway: failed after 0s: dial unix /var/opt/gitlab/gitlab-rails/sockets/gitlab.socket: connect: no such file or directory" method=GET uri=/
2018-11-13_08:31:23.66695 gitlab.ifeegoo.com @ - - [2018/11/13:16:31:23 +0800] "GET / HTTP/1.1" 502 2940 "" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36" 0.814
2018-11-13_08:31:24.41023 time="2018-11-13T16:31:24+08:00" level=error msg=error correlation-id=6JxCG4cAHE3 error="badgateway: failed after 0s: dial unix /var/opt/gitlab/gitlab-rails/sockets/gitlab.socket: connect: no such file or directory" method=GET uri=/favicon.ico
2018-11-13_08:31:24.41029 gitlab.ifeegoo.com @ - - [2018/11/13:16:31:24 +0800] "GET /favicon.ico HTTP/1.1" 502 2940 "http://gitlab.ifeegoo.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36" 0.001

==> /var/log/gitlab/logrotate/current <==

==> /var/log/gitlab/postgresql/current <==
2018-11-12_12:35:03.58822 LOG:  received smart shutdown request
2018-11-12_12:35:03.58822 received TERM from runit, sending INT instead to force quit connections
2018-11-12_12:35:03.58822 LOG:  received fast shutdown request
2018-11-12_12:35:03.58822 received TERM from runit, sending INT instead to force quit connections
2018-11-12_12:35:05.79841 LOG:  shutting down
2018-11-12_12:35:05.96881 LOG:  database system is shut down
2018-11-13_08:22:15.76475 LOG:  database system was shut down at 2018-11-12 12:35:05 GMT
2018-11-13_08:22:16.09868 LOG:  MultiXact member wraparound protections are now enabled
2018-11-13_08:22:16.10336 LOG:  database system is ready to accept connections
2018-11-13_08:22:16.12288 LOG:  autovacuum launcher started

==> /var/log/gitlab/node-exporter/current <==
2018-11-13_08:22:14.55855 time="2018-11-13T16:22:14+08:00" level=info msg=" - sockstat" source="node_exporter.go:97"
2018-11-13_08:22:14.55855 time="2018-11-13T16:22:14+08:00" level=info msg=" - stat" source="node_exporter.go:97"
2018-11-13_08:22:14.55855 time="2018-11-13T16:22:14+08:00" level=info msg=" - textfile" source="node_exporter.go:97"
2018-11-13_08:22:14.55856 time="2018-11-13T16:22:14+08:00" level=info msg=" - time" source="node_exporter.go:97"
2018-11-13_08:22:14.55856 time="2018-11-13T16:22:14+08:00" level=info msg=" - uname" source="node_exporter.go:97"
2018-11-13_08:22:14.55856 time="2018-11-13T16:22:14+08:00" level=info msg=" - vmstat" source="node_exporter.go:97"
2018-11-13_08:22:14.55856 time="2018-11-13T16:22:14+08:00" level=info msg=" - wifi" source="node_exporter.go:97"
2018-11-13_08:22:14.55857 time="2018-11-13T16:22:14+08:00" level=info msg=" - xfs" source="node_exporter.go:97"
2018-11-13_08:22:14.55857 time="2018-11-13T16:22:14+08:00" level=info msg=" - zfs" source="node_exporter.go:97"
2018-11-13_08:22:14.55857 time="2018-11-13T16:22:14+08:00" level=info msg="Listening on localhost:9100" source="node_exporter.go:111"

==> /var/log/gitlab/nginx/access.log <==

==> /var/log/gitlab/nginx/error.log <==

==> /var/log/gitlab/nginx/gitlab_error.log <==

==> /var/log/gitlab/nginx/gitlab_access.log <==
172.105.216.67 - - [13/Nov/2018:16:30:45 +0800] "GET / HTTP/1.1" 502 2940 "" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
172.105.216.67 - - [13/Nov/2018:16:30:46 +0800] "GET /favicon.ico HTTP/1.1" 502 2940 "http://gitlab.ifeegoo.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
172.105.216.67 - - [13/Nov/2018:16:30:48 +0800] "GET / HTTP/1.1" 502 2940 "" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
172.105.216.67 - - [13/Nov/2018:16:30:48 +0800] "GET /favicon.ico HTTP/1.1" 502 2940 "http://gitlab.ifeegoo.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
172.105.216.67 - - [13/Nov/2018:16:30:50 +0800] "GET / HTTP/1.1" 502 2940 "" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
172.105.216.67 - - [13/Nov/2018:16:30:50 +0800] "GET /favicon.ico HTTP/1.1" 502 2940 "http://gitlab.ifeegoo.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
172.105.216.67 - - [13/Nov/2018:16:30:52 +0800] "GET / HTTP/1.1" 502 2940 "" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
172.105.216.67 - - [13/Nov/2018:16:30:53 +0800] "GET /favicon.ico HTTP/1.1" 502 2940 "http://gitlab.ifeegoo.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
172.105.216.67 - - [13/Nov/2018:16:31:23 +0800] "GET / HTTP/1.1" 502 2940 "" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"
172.105.216.67 - - [13/Nov/2018:16:31:24 +0800] "GET /favicon.ico HTTP/1.1" 502 2940 "http://gitlab.ifeegoo.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"

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

==> /var/log/gitlab/gitlab-shell/gitlab-shell.log <==

==> /var/log/gitlab/redis-exporter/current <==
2018-11-13_08:22:14.55864 time="2018-11-13T16:22:14+08:00" level=info msg="Redis Metrics Exporter 0.20.2    build date: 2018-11-04T23:54:17+00:00    sha1: 694ec659c0944f104ad7e820a30ba74a1bb4fe1c    Go: go1.10.3" 
2018-11-13_08:22:14.55871 time="2018-11-13T16:22:14+08:00" level=info msg="Providing metrics at localhost:9121/metrics" 
2018-11-13_08:22:14.55871 time="2018-11-13T16:22:14+08:00" level=info msg="Connecting to redis hosts: []string{\"unix:///var/opt/gitlab/redis/redis.socket\"}" 
2018-11-13_08:22:14.55871 time="2018-11-13T16:22:14+08:00" level=info msg="Using alias: []string{\"\"}" 

==> /var/log/gitlab/gitaly/current <==
2018-11-13_08:22:14.91917 time="2018-11-13T08:22:14Z" level=warning msg="git path not configured. Using default path resolution" resolvedPath=/opt/gitlab/embedded/bin/git
2018-11-13_08:22:18.96303 time="2018-11-13T08:22:18Z" level=info msg="listening on unix socket" address=/var/opt/gitlab/gitaly/gitaly.socket
2018-11-13_08:22:18.96305 time="2018-11-13T08:22:18Z" level=info msg="Starting prometheus listener" address="localhost:9236"
2018-11-13_08:22:19.00136 time="2018-11-13T08:22:19Z" level=info msg="starting RSS monitor" supervisor.name=gitaly-ruby.0 supervisor.rss_threshold=209715200
2018-11-13_08:22:19.00137 time="2018-11-13T08:22:19Z" level=info msg="starting RSS monitor" supervisor.name=gitaly-ruby.1 supervisor.rss_threshold=209715200
2018-11-13_08:22:19.00138 time="2018-11-13T08:22:19Z" level=info msg="finished tempdir cleaner walk" storage=default time_ms=37
2018-11-13_08:22:19.00138 time="2018-11-13T08:22:19Z" level=warning msg=spawned supervisor.args="[bundle exec bin/ruby-cd /var/opt/gitlab/gitaly /opt/gitlab/embedded/service/gitaly-ruby/bin/gitaly-ruby 1220 /tmp/gitaly-ruby811892894/socket.0]" supervisor.name=gitaly-ruby.0 supervisor.pid=1305
2018-11-13_08:22:19.02382 time="2018-11-13T08:22:19Z" level=warning msg=spawned supervisor.args="[bundle exec bin/ruby-cd /var/opt/gitlab/gitaly /opt/gitlab/embedded/service/gitaly-ruby/bin/gitaly-ruby 1220 /tmp/gitaly-ruby811892894/socket.1]" supervisor.name=gitaly-ruby.1 supervisor.pid=1307
2018-11-13_08:22:21.40995 time="2018-11-13T08:22:21Z" level=info msg="PID 1307 BUNDLE_GEMFILE=/opt/gitlab/embedded/service/gitaly-ruby/Gemfile" supervisor.args="[bundle exec bin/ruby-cd /var/opt/gitlab/gitaly /opt/gitlab/embedded/service/gitaly-ruby/bin/gitaly-ruby 1220 /tmp/gitaly-ruby811892894/socket.1]" supervisor.name=gitaly-ruby.1
2018-11-13_08:22:21.40997 time="2018-11-13T08:22:21Z" level=info msg="PID 1305 BUNDLE_GEMFILE=/opt/gitlab/embedded/service/gitaly-ruby/Gemfile" supervisor.args="[bundle exec bin/ruby-cd /var/opt/gitlab/gitaly /opt/gitlab/embedded/service/gitaly-ruby/bin/gitaly-ruby 1220 /tmp/gitaly-ruby811892894/socket.0]" supervisor.name=gitaly-ruby.0

==> /var/log/gitlab/redis/current <==
2018-11-13_08:22:14.78267   `-._    `-._`-.__.-'_.-'    _.-'                                   
2018-11-13_08:22:14.78267       `-._    `-.__.-'    _.-'                                       
2018-11-13_08:22:14.78268           `-._        _.-'                                           
2018-11-13_08:22:14.78269               `-.__.-'                                               
2018-11-13_08:22:14.78269 
2018-11-13_08:22:14.78269 1275:M 13 Nov 16:22:14.771 # Server started, Redis version 3.2.12
2018-11-13_08:22:14.78270 1275:M 13 Nov 16:22:14.771 # WARNING overcommit_memory is set to 0! Background save may fail under low memory condition. To fix this issue add 'vm.overcommit_memory = 1' to /etc/sysctl.conf and then reboot or run the command 'sysctl vm.overcommit_memory=1' for this to take effect.
2018-11-13_08:22:14.78270 1275:M 13 Nov 16:22:14.771 # WARNING you have Transparent Huge Pages (THP) support enabled in your kernel. This will create latency and memory usage issues with Redis. To fix this issue run the command 'echo never > /sys/kernel/mm/transparent_hugepage/enabled' as root, and add it to your /etc/rc.local in order to retain the setting after a reboot. Redis must be restarted after THP is disabled.
2018-11-13_08:22:14.78271 1275:M 13 Nov 16:22:14.776 * DB loaded from disk: 0.005 seconds
2018-11-13_08:22:14.78271 1275:M 13 Nov 16:22:14.776 * The server is now ready to accept connections at /var/opt/gitlab/redis/redis.socket

==> /var/log/gitlab/sidekiq/current <==

==> /var/log/gitlab/gitlab-rails/production.log <==

==> /var/log/gitlab/gitlab-rails/application.log <==
# Logfile created on 2018-11-12 20:28:36 +0800 by logger.rb/56815
November 12, 2018 20:28: User "Administrator" (admin@example.com) was created

==> /var/log/gitlab/gitlab-rails/api_json.log <==
# Logfile created on 2018-11-12 20:28:07 +0800 by logger.rb/56815

==> /var/log/gitlab/gitlab-rails/grpc.log <==
# Logfile created on 2018-11-12 20:28:07 +0800 by logger.rb/56815

==> /var/log/gitlab/gitlab-rails/sidekiq.log <==

==> /var/log/gitlab/gitlab-rails/production_json.log <==
# Logfile created on 2018-11-12 20:28:07 +0800 by logger.rb/56815

==> /var/log/gitlab/gitlab-rails/gitlab-rails-db-migrate-2018-11-12-20-27-42.log <==
== Seed from /opt/gitlab/embedded/service/gitlab-rails/db/fixtures/production/001_admin.rb
Administrator account created:

login:    root
password: You'll be prompted to create one on your first visit.


== Seed from /opt/gitlab/embedded/service/gitlab-rails/db/fixtures/production/010_settings.rb

== Seed from /opt/gitlab/embedded/service/gitlab-rails/db/fixtures/production/999_common_metrics.rb

==> /var/log/gitlab/alertmanager/current <==
2018-11-12_12:34:48.37537 level=info ts=2018-11-12T12:34:48.277076637Z caller=cluster.go:579 component=cluster msg="gossip not settled but continuing anyway" polls=0 elapsed=1m2.422143738s
2018-11-12_12:35:03.50659 level=info ts=2018-11-12T12:35:03.261135852Z caller=main.go:424 msg="Received SIGTERM, exiting gracefully..."
2018-11-13_08:22:14.55828 level=info ts=2018-11-13T08:22:12.055466381Z caller=main.go:174 msg="Starting Alertmanager" version="(version=0.15.1, branch=master, revision=694ec659c0944f104ad7e820a30ba74a1bb4fe1c)"
2018-11-13_08:22:14.58853 level=info ts=2018-11-13T08:22:12.055589912Z caller=main.go:175 build_context="(go=go1.10.3, user=GitLab-Omnibus, date=2018-11-04T23:54:17+00:00)"
2018-11-13_08:22:14.58855 level=info ts=2018-11-13T08:22:13.611916957Z caller=cluster.go:155 component=cluster msg="setting advertise address explicitly" addr=10.135.129.173 port=9094
2018-11-13_08:22:14.58855 level=info ts=2018-11-13T08:22:14.138018094Z caller=main.go:320 msg="Loading configuration file" file=/var/opt/gitlab/alertmanager/alertmanager.yml
2018-11-13_08:22:14.58856 level=info ts=2018-11-13T08:22:14.139995942Z caller=cluster.go:570 component=cluster msg="Waiting for gossip to settle..." interval=10m0s
2018-11-13_08:22:14.58856 level=info ts=2018-11-13T08:22:14.377131813Z caller=main.go:396 msg=Listening address=localhost:9093
2018-11-13_08:23:48.53571 level=info ts=2018-11-13T08:23:45.691007654Z caller=cluster.go:579 component=cluster msg="gossip not settled but continuing anyway" polls=0 elapsed=1m12.05062069s

==> /var/log/gitlab/gitlab-monitor/current <==
2018-11-13_08:34:38.95736 127.0.0.1 - - [13/Nov/2018:16:34:38 CST] "GET /process HTTP/1.1" 200 104
2018-11-13_08:34:38.95738 - -> /process
2018-11-13_08:34:45.11711 127.0.0.1 - - [13/Nov/2018:16:34:44 CST] "GET /database HTTP/1.1" 200 94727
2018-11-13_08:34:45.11713 - -> /database
2018-11-13_08:34:47.86809 127.0.0.1 - - [13/Nov/2018:16:34:47 CST] "GET /sidekiq HTTP/1.1" 200 26
2018-11-13_08:34:47.86812 - -> /sidekiq

==> /var/log/gitlab/redis/current <==
2018-11-13_08:34:52.41489 1275:M 13 Nov 16:34:52.408 * 10 changes in 300 seconds. Saving...
2018-11-13_08:34:52.41764 1275:M 13 Nov 16:34:52.415 * Background saving started by pid 2894
2018-11-13_08:34:52.46544 2894:C 13 Nov 16:34:52.464 * DB saved on disk
2018-11-13_08:34:52.46545 2894:C 13 Nov 16:34:52.465 * RDB: 6 MB of memory used by copy-on-write
2018-11-13_08:34:52.51550 1275:M 13 Nov 16:34:52.515 * Background saving terminated with success

==> /var/log/gitlab/gitlab-monitor/current <==
2018-11-13_08:35:12.40674 127.0.0.1 - - [13/Nov/2018:16:34:55 CST] "GET /process HTTP/1.1" 200 104
2018-11-13_08:35:12.70460 - -> /process
2018-11-13_08:35:12.95320 127.0.0.1 - - [13/Nov/2018:16:35:12 CST] "GET /sidekiq HTTP/1.1" 200 26
2018-11-13_08:35:12.95322 - -> /sidekiq
2018-11-13_08:35:13.06945 127.0.0.1 - - [13/Nov/2018:16:35:12 CST] "GET /process HTTP/1.1" 200 104
2018-11-13_08:35:13.06947 - -> /process
2018-11-13_08:35:13.14873 127.0.0.1 - - [13/Nov/2018:16:35:12 CST] "GET /database HTTP/1.1" 200 94727
2018-11-13_08:35:13.14876 - -> /database

==> /var/log/gitlab/unicorn/current <==
2018-11-13_08:35:12.34425 master failed to start, check stderr log for details

==> /var/log/gitlab/gitlab-workhorse/current <==
2018-11-13_08:35:12.90926 time="2018-11-13T16:35:12+08:00" level=error msg=error correlation-id=MYaVTVvgur error="badgateway: failed after 0s: dial unix /var/opt/gitlab/gitlab-rails/sockets/gitlab.socket: connect: no such file or directory" method=GET uri=/
2018-11-13_08:35:12.92470 gitlab.ifeegoo.com @ - - [2018/11/13:16:35:12 +0800] "GET / HTTP/1.1" 502 2940 "" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36" 0.223

==> /var/log/gitlab/nginx/gitlab_access.log <==
172.105.216.67 - - [13/Nov/2018:16:35:12 +0800] "GET / HTTP/1.1" 502 2940 "" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"

==> /var/log/gitlab/unicorn/current <==
2018-11-13_08:35:13.72978 failed to start a new unicorn master
2018-11-13_08:35:13.76716 starting new unicorn master

==> /var/log/gitlab/gitlab-workhorse/current <==
2018-11-13_08:35:13.58031 time="2018-11-13T16:35:13+08:00" level=error msg=error correlation-id=p7lr4n63uv9 error="badgateway: failed after 0s: dial unix /var/opt/gitlab/gitlab-rails/sockets/gitlab.socket: connect: no such file or directory" method=GET uri=/favicon.ico
2018-11-13_08:35:13.58033 gitlab.ifeegoo.com @ - - [2018/11/13:16:35:13 +0800] "GET /favicon.ico HTTP/1.1" 502 2940 "http://gitlab.ifeegoo.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36" 0.001

==> /var/log/gitlab/nginx/gitlab_access.log <==
172.105.216.67 - - [13/Nov/2018:16:35:13 +0800] "GET /favicon.ico HTTP/1.1" 502 2940 "http://gitlab.ifeegoo.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"

==> /var/log/gitlab/gitlab-monitor/current <==
2018-11-13_08:35:14.88273 127.0.0.1 - - [13/Nov/2018:16:35:14 CST] "GET /database HTTP/1.1" 200 94727
2018-11-13_08:35:14.88275 - -> /database

==> /var/log/gitlab/unicorn/unicorn_stderr.log <==
I, [2018-11-13T16:35:16.644337 #2957]  INFO -- : Refreshing Gem list

==> /var/log/gitlab/gitlab-monitor/current <==
2018-11-13_08:35:17.69912 127.0.0.1 - - [13/Nov/2018:16:35:17 CST] "GET /sidekiq HTTP/1.1" 200 26
2018-11-13_08:35:17.69914 - -> /sidekiq
2018-11-13_08:35:23.97909 127.0.0.1 - - [13/Nov/2018:16:35:23 CST] "GET /process HTTP/1.1" 200 104
2018-11-13_08:35:23.97910 - -> /process
2018-11-13_08:35:29.99807 127.0.0.1 - - [13/Nov/2018:16:35:29 CST] "GET /database HTTP/1.1" 200 94727
2018-11-13_08:35:29.99809 - -> /database
2018-11-13_08:35:32.94456 127.0.0.1 - - [13/Nov/2018:16:35:32 CST] "GET /sidekiq HTTP/1.1" 200 26
2018-11-13_08:35:33.11172 - -> /sidekiq
2018-11-13_08:36:28.80681 127.0.0.1 - - [13/Nov/2018:16:36:28 CST] "GET /sidekiq HTTP/1.1" 200 26
2018-11-13_08:36:28.81127 - -> /sidekiq
2018-11-13_08:36:28.84816 127.0.0.1 - - [13/Nov/2018:16:36:28 CST] "GET /process HTTP/1.1" 200 104
2018-11-13_08:36:28.84819 - -> /process
2018-11-13_08:36:29.66209 127.0.0.1 - - [13/Nov/2018:16:36:29 CST] "GET /process HTTP/1.1" 200 104
2018-11-13_08:36:29.66210 - -> /process
2018-11-13_08:36:29.66750 127.0.0.1 - - [13/Nov/2018:16:36:29 CST] "GET /sidekiq HTTP/1.1" 200 26
2018-11-13_08:36:29.66752 - -> /sidekiq
2018-11-13_08:36:29.78473 127.0.0.1 - - [13/Nov/2018:16:36:29 CST] "GET /database HTTP/1.1" 200 94727
2018-11-13_08:36:29.78475 - -> /database
2018-11-13_08:36:29.92272 127.0.0.1 - - [13/Nov/2018:16:36:29 CST] "GET /database HTTP/1.1" 200 94727
2018-11-13_08:36:29.92274 - -> /database
2018-11-13_08:36:32.69873 127.0.0.1 - - [13/Nov/2018:16:36:32 CST] "GET /sidekiq HTTP/1.1" 200 26
2018-11-13_08:36:32.69877 - -> /sidekiq
2018-11-13_08:36:38.87456 127.0.0.1 - - [13/Nov/2018:16:36:38 CST] "GET /process HTTP/1.1" 200 104
2018-11-13_08:36:38.87457 - -> /process
2018-11-13_08:36:45.03813 127.0.0.1 - - [13/Nov/2018:16:36:44 CST] "GET /database HTTP/1.1" 200 94727
2018-11-13_08:36:45.03814 - -> /database
2018-11-13_08:36:47.84079 127.0.0.1 - - [13/Nov/2018:16:36:47 CST] "GET /sidekiq HTTP/1.1" 200 26
2018-11-13_08:36:47.84174 - -> /sidekiq

==> /var/log/gitlab/unicorn/current <==
2018-11-13_08:36:51.60874 master failed to start, check stderr log for details
2018-11-13_08:36:52.71886 failed to start a new unicorn master
2018-11-13_08:36:52.76907 starting new unicorn master

==> /var/log/gitlab/gitlab-monitor/current <==
2018-11-13_08:36:53.91853 127.0.0.1 - - [13/Nov/2018:16:36:53 CST] "GET /process HTTP/1.1" 200 104
2018-11-13_08:36:53.92361 - -> /process

==> /var/log/gitlab/unicorn/unicorn_stderr.log <==
I, [2018-11-13T16:36:55.440616 #3112]  INFO -- : Refreshing Gem list

==> /var/log/gitlab/gitlab-monitor/current <==
2018-11-13_08:36:59.99606 127.0.0.1 - - [13/Nov/2018:16:36:59 CST] "GET /database HTTP/1.1" 200 94727
2018-11-13_08:36:59.99609 - -> /database
2018-11-13_08:37:02.68342 127.0.0.1 - - [13/Nov/2018:16:37:02 CST] "GET /sidekiq HTTP/1.1" 200 26
2018-11-13_08:37:02.68343 - -> /sidekiq
2018-11-13_08:37:09.54949 127.0.0.1 - - [13/Nov/2018:16:37:08 CST] "GET /process HTTP/1.1" 200 104
2018-11-13_08:37:09.54951 - -> /process
2018-11-13_08:37:23.98205 127.0.0.1 - - [13/Nov/2018:16:37:23 CST] "GET /sidekiq HTTP/1.1" 200 26
2018-11-13_08:37:23.98681 - -> /sidekiq
2018-11-13_08:37:24.09972 127.0.0.1 - - [13/Nov/2018:16:37:14 CST] "GET /database HTTP/1.1" 200 94727
2018-11-13_08:37:24.09974 - -> /database
2018-11-13_08:37:24.14482 127.0.0.1 - - [13/Nov/2018:16:37:24 CST] "GET /process HTTP/1.1" 200 104
2018-11-13_08:37:24.14483 - -> /process

==> /var/log/gitlab/gitlab-workhorse/current <==
2018-11-13_08:37:23.89821 time="2018-11-13T16:37:23+08:00" level=error msg=error correlation-id=rmNqhLcuL6 error="badgateway: failed after 0s: dial unix /var/opt/gitlab/gitlab-rails/sockets/gitlab.socket: connect: no such file or directory" method=GET uri=/
2018-11-13_08:37:23.90421 gitlab.ifeegoo.com @ - - [2018/11/13:16:37:23 +0800] "GET / HTTP/1.1" 502 2940 "" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36" 0.143

==> /var/log/gitlab/postgresql/current <==
2018-11-13_08:37:23.89944 LOG:  could not send data to client: Broken pipe
2018-11-13_08:37:23.90787 FATAL:  connection to client lost

==> /var/log/gitlab/nginx/gitlab_access.log <==
172.105.216.67 - - [13/Nov/2018:16:37:23 +0800] "GET / HTTP/1.1" 502 2940 "" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"

==> /var/log/gitlab/gitlab-workhorse/current <==
2018-11-13_08:37:25.46372 time="2018-11-13T16:37:25+08:00" level=error msg=error correlation-id=1n7l29DKTV1 error="badgateway: failed after 0s: dial unix /var/opt/gitlab/gitlab-rails/sockets/gitlab.socket: connect: no such file or directory" method=GET uri=/favicon.ico
2018-11-13_08:37:25.46375 gitlab.ifeegoo.com @ - - [2018/11/13:16:37:25 +0800] "GET /favicon.ico HTTP/1.1" 502 2940 "http://gitlab.ifeegoo.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36" 0.001

==> /var/log/gitlab/nginx/gitlab_access.log <==
172.105.216.67 - - [13/Nov/2018:16:37:25 +0800] "GET /favicon.ico HTTP/1.1" 502 2940 "http://gitlab.ifeegoo.com/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36"

==> /var/log/gitlab/gitlab-monitor/current <==
2018-11-13_08:37:29.89704 127.0.0.1 - - [13/Nov/2018:16:37:29 CST] "GET /database HTTP/1.1" 200 94727
2018-11-13_08:37:29.89705 - -> /database
2018-11-13_08:37:32.70032 127.0.0.1 - - [13/Nov/2018:16:37:32 CST] "GET /sidekiq HTTP/1.1" 200 26
2018-11-13_08:37:32.70033 - -> /sidekiq
2018-11-13_08:37:38.95096 127.0.0.1 - - [13/Nov/2018:16:37:38 CST] "GET /process HTTP/1.1" 200 104
2018-11-13_08:37:38.95098 - -> /process

==> /var/log/gitlab/unicorn/current <==
2018-11-13_08:38:02.84688 master failed to start, check stderr log for details

==> /var/log/gitlab/gitlab-monitor/current <==
2018-11-13_08:38:03.40998 127.0.0.1 - - [13/Nov/2018:16:38:02 CST] "GET /sidekiq HTTP/1.1" 200 26
2018-11-13_08:38:03.41813 - -> /sidekiq
2018-11-13_08:38:03.48202 127.0.0.1 - - [13/Nov/2018:16:38:03 CST] "GET /sidekiq HTTP/1.1" 200 26
2018-11-13_08:38:03.48204 - -> /sidekiq
2018-11-13_08:38:03.54679 127.0.0.1 - - [13/Nov/2018:16:37:44 CST] "GET /database HTTP/1.1" 200 0
2018-11-13_08:38:03.54681 - -> /database
2018-11-13_08:38:03.56253 127.0.0.1 - - [13/Nov/2018:16:38:03 CST] "GET /process HTTP/1.1" 200 104
2018-11-13_08:38:03.56254 - -> /process
2018-11-13_08:38:03.63873 127.0.0.1 - - [13/Nov/2018:16:38:03 CST] "GET /database HTTP/1.1" 200 94727
2018-11-13_08:38:03.63877 - -> /database

==> /var/log/gitlab/unicorn/current <==
2018-11-13_08:38:04.18003 failed to start a new unicorn master
2018-11-13_08:38:04.33869 starting new unicorn master

==> /var/log/gitlab/unicorn/unicorn_stderr.log <==
I, [2018-11-13T16:38:08.087394 #3259]  INFO -- : Refreshing Gem list

==> /var/log/gitlab/gitlab-monitor/current <==
2018-11-13_08:38:08.92743 127.0.0.1 - - [13/Nov/2018:16:38:08 CST] "GET /process HTTP/1.1" 200 104
2018-11-13_08:38:08.92745 - -> /process

通过查资料,部分人说这个是由于内存不足,可以通过创建虚拟内存来解决问题。通过官方关于 GitLab 内存这块的说明,也要求了最低配置:至少需要 8G 的 RAM + swap 内存。我们首先通过 free -m 命令来查看是否已经创建 Swap 分区,默认的服务器是没有创建的。

# free -m
              total        used        free      shared  buff/cache   available
Mem:            991         668          68          29         254         137
Swap:             0           0           0

针对 CentOS 7.x 的 Swap 分区大小的建议,可以参考官方文档

recommended-system-swap-space-for-centos-7

由于我的服务器只有 1G RAM,所以我尝试分配一个 8G Swap 空间:

# dd if=/dev/zero  of=/var/swapfile  bs=1024  count=8192k
8388608+0 records in
8388608+0 records out
8589934592 bytes (8.6 GB) copied, 90.3551 s, 95.1 MB/s

转换 Swap 分区:

# mkswap /var/swapfile  
Setting up swapspace version 1, size = 8388604 KiB
no label, UUID=72fbdf39-cd3b-4aa3-a15d-ea7d553372eb

挂载并激活分区:

# swapon /var/swapfile
swapon: /var/swapfile: insecure permissions 0644, 0600 suggested.
# chmod -R 0600 /var/swapfile

设置开机自动挂载该分区:

echo "/var/swapfile   swap  swap  defaults  0  0" >>  /etc/fstab

查看 Swap 是否被使用:

# free -m
              total        used        free      shared  buff/cache   available
Mem:            991         846          64           3          81          26
Swap:          8191         504        7687

我们更新下 GitLab 配置和重启 GitLab 服务。

// 更新 GitLab 配置
# gitlab-ctl reconfigure
// 重启 GitLab 服务
# gitlab-ctl restart

GitLab 有一个可能是 Bug 的问题,初次加载页面的时候,会出现 502,可能过几分钟之后,才会出现正常的响应,这个情况网上很多人反馈有这样的问题。

3.浏览主机和登录

首次访问的时候,你将会被重定向到密码重置页面。提供初始管理员账号的密码,然后会被重定向回登录的页面,使用默认账号用户名 root 进行登录。更多参见:安装和配置详细说明文档

centos-7-gitlab-installation-first-loading

输入密码之后,可能会有以下错误:

centos-7-gitlab-installation-password-setting

我们先尝试通过终端的形式,设置管理员密码:

# cd /opt/gitlab/bin
# sudo gitlab-rails console production
-------------------------------------------------------------------------------------
 GitLab:       11.4.5-ee (bf6db46)
 GitLab Shell: 8.3.3
 postgresql:   9.6.8
-------------------------------------------------------------------------------------
Loading production environment (Rails 4.2.10)
irb(main):001:0> u=User.where(id:1).first
=> #<User id:1 @root>
irb(main):002:0> u.password='gitlab'
=> "gitlab"
irb(main):003:0> u.password_confirmation='gitlab'
=> "gitlab"
irb(main):004:0> u.save!
Enqueued ActionMailer::DeliveryJob (Job ID: a2544b8c-c065-4860-92bd-878c95c32c6b) to Sidekiq(mailers) with arguments: "DeviseMailer", "password_change", "deliver_now", gid://gitlab/User/1
=> true

当你通过以上设置的密码跳过上面一步之后,又提示你要验证邮件,如果你的邮件系统没有配置好的话,你就接收不到这封邮件了。实际操作过程中,也不太需要邮件的验证,管理员直接分配账号即可。具体的移除邮件验证,网上有相关的资料,由于我的测试服务器性能太差,大部分时间访问都是 502,根本无法进行测试确认,大家自己尝试下!

由于我当前个人的测试服务器性能比较低:单核 1G 内存,虽然我采用了 Swap 扩充虚拟内存,但是跑 GitLab 还是很吃力,响应很慢,而且页面访问大部分都是 502,官方也说明了针对于 100 个用户左右,双核 8G RAM 是最基本的要求。正常使用的时候,公司可以购买性能更强劲的服务器专门用于代码管理、CI/CD 这块。或者公司内网用一台服务器来搭建局域网代码管理系统,如果想要外网访问的话,可以通过一些内网穿透工具,例如花生壳等来实现外网的访问。能用钱解决的问题,都不是问题,目前 GitLab 的功能是最强大的,能够结合 CI/CD 工具配合使用,能够极大的提高生产效率!

Note:以上安装 GitLab 的步骤是直接安装的 GitLab 最新针对 CentOS 版本,当你需要进行数据迁移的时候,一定要注意最好安装相同的版本,否则数据迁移过程可能有问题!

由于个人测试服务器性能太差,无法继续进行相关步骤推进,后续有更好的操作环境,再进一步推进!未完待续、不断更新!

2019-09-20(Fri) 追加:个人重新购买了一台性能较好的服务器,可以继续使用 GitLab。

如果你的服务器是 [系统盘 + 数据盘] 配置的话,建议将 GitLab 的数据存放到数据盘中。我就从新购买的 [系统盘 + 数据盘] 来说明如何一步步的处理:

1.登录云服务器,查看服务器相关状态。

通过 fdisk -l 命令查看当前系统盘和数据盘状态:

[root@VM_161_138_centos ~]# fdisk -l

Disk /dev/vda: 53.7 GB, 53687091200 bytes, 104857600 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0009ac89

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048   104857599    52427776   83  Linux

Disk /dev/vdb: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

我们看到有一个 50G 左右的系统盘和一个 100G 左右的数据盘。然后我们通过 df -h 命令来查看当前数据盘有没有被挂载。

[root@VM_161_138_centos ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        50G  1.7G   45G   4% /
devtmpfs        7.8G     0  7.8G   0% /dev
tmpfs           7.8G   24K  7.8G   1% /dev/shm
tmpfs           7.8G  456K  7.8G   1% /run
tmpfs           7.8G     0  7.8G   0% /sys/fs/cgroup
tmpfs           1.6G     0  1.6G   0% /run/user/0

从以上信息我们没有看到有 /dev/vdb 数据盘。那么我们就需要进行数据盘挂载操作,挂载之前需要对硬盘分区和格式化,通过 fdisk /dev/vdb 命令来管理:

[root@VM_161_138_centos ~]# fdisk /dev/vdb
Welcome to fdisk (util-linux 2.23.2).

Changes will remain in memory only, until you decide to write them.
Be careful before using the write command.

Device does not contain a recognized partition table
Building a new DOS disklabel with disk identifier 0x756ee2de.

Command (m for help): m
Command action
   a   toggle a bootable flag
   b   edit bsd disklabel
   c   toggle the dos compatibility flag
   d   delete a partition
   g   create a new empty GPT partition table
   G   create an IRIX (SGI) partition table
   l   list known partition types
   m   print this menu
   n   add a new partition
   o   create a new empty DOS partition table
   p   print the partition table
   q   quit without saving changes
   s   create a new empty Sun disklabel
   t   change a partition's system id
   u   change display/entry units
   v   verify the partition table
   w   write table to disk and exit
   x   extra functionality (experts only)

Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-209715199, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199): 
Using default value 209715199
Partition 1 of type Linux and of size 100 GiB is set

Command (m for help): wq
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

fdisk /dev/vdb 之后,可以用 m 命名查看相关的操作,这个时候我们输入 n:新增一个分区。然后提醒分区类型,我们选择 p,也是默认的。然后分区数量选择一个就好,另外两个默认参数值就直接回车默认就好,最后通过 wq 命令退出。这样我们就完成了分区。接下来我们通过 df -hT 命令查看下系统分区的磁盘类型。

[root@VM_161_138_centos ~]#  df -hT
Filesystem     Type      Size  Used Avail Use% Mounted on
/dev/vda1      ext4       50G  1.7G   45G   4% /
devtmpfs       devtmpfs  7.8G     0  7.8G   0% /dev
tmpfs          tmpfs     7.8G   24K  7.8G   1% /dev/shm
tmpfs          tmpfs     7.8G  460K  7.8G   1% /run
tmpfs          tmpfs     7.8G     0  7.8G   0% /sys/fs/cgroup
tmpfs          tmpfs     1.6G     0  1.6G   0% /run/user/0

我们看到系统区分的磁盘类型是 ext4,那么接下来我们也将数据盘格式化成 ext4 格式:使用 mkfs.ext4 /dev/vdb 命令。

[root@VM_161_138_centos ~]# mkfs.ext4 /dev/vdb
mke2fs 1.42.9 (28-Dec-2013)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
Stride=0 blocks, Stripe width=0 blocks
6553600 inodes, 26214400 blocks
1310720 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=2174746624
800 block groups
32768 blocks per group, 32768 fragments per group
8192 inodes per group
Superblock backups stored on blocks: 
        32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208, 
        4096000, 7962624, 11239424, 20480000, 23887872

Allocating group tables: done                            
Writing inode tables: done                            
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done  

接下来,最重要的一步就是要挂载数据盘。可以通过 mount /dev/vdb /mnt 命令将数据盘挂载到 /mnt。

[root@VM_161_138_centos /]# mount /dev/vdb /mnt
[root@VM_161_138_centos /]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        50G  1.7G   45G   4% /
devtmpfs        7.8G     0  7.8G   0% /dev
tmpfs           7.8G   24K  7.8G   1% /dev/shm
tmpfs           7.8G  456K  7.8G   1% /run
tmpfs           7.8G     0  7.8G   0% /sys/fs/cgroup
tmpfs           1.6G     0  1.6G   0% /run/user/0
/dev/vdb         99G   61M   94G   1% /mnt

执行挂载命令之后,我们再次通过 df -h 命令来查看数据盘 /dev/vdb 是否挂载,看到最后一项 /dev/vdb Mounted on /mnt 最可以认定是挂载成功了!

然后我们需要设置一个开机自动挂载数据盘,通过以下命令:

echo '/dev/vdb /mnt ext4 defaults 0 0' >> /etc/fstab

我们通过前面的最后一步命令行安装 GitLab EE:sudo EXTERNAL_URL=”http://gitlab.ifeegoo.com” yum install -y gitlab-ee。当然,请注意将你的相关域名解析指向服务器 IP 地址。

我们安装好 GitLab EE 之后,先不要急着去访问,我们先要做一些配置的修改,最主要的就是将 Git 数据目录设置到挂载的数据盘上。如果新手不习惯 Linux 的 vi/Vim 文本编辑器,推荐大家安装一款 Linux 服务器管理工具:AppNode。个人认为 AppNode 还是很好用的。我们通过以下命令来安装控制中心和受控端。

INSTALL_AGENT=1 INIT_SWAPFILE=1 bash -c "$(curl -sS http://dl.appnode.com/install.sh)"

注意安装这个 Linux 服务器管理工具过程中,会被防火墙关掉,重新通过命令行启用防火墙即可 !

安装好了这个 Linux 服务器管理工具之后,可以去到后台,找到以下文件:/etc/gitlab/gitlab.rb。这个文件是一个 GitLab 非常重要的配置文件。如果你想修改 GitLab 访问的端口,可以通过修改以下配置参数。

# nginx['listen_port'] = nil

将前面的 # 注释符去掉,然后将 nil 替换成你想要修改的端口,例如 1024。

nginx['listen_port'] = 1024

另外,我们需要修改 GitLab 的 Git 数据的存储路径。还是在 /etc/gitlab/gitlab.rb 文件中,找到以下配置:

# git_data_dirs({
#   "default" => {
#     "path" => "/mnt/nfs-01/git-data"
#    }
# })

然后将 path 修改成你想要对应的目录。我们这里想要将目录修改成: /mnt/gitlab/git-data。我们先在 /mnt 目录下创建相关目录:

[root@VM_161_138_centos mnt]# ls
lost+found
[root@VM_161_138_centos mnt]# mkdir gitlab
[root@VM_161_138_centos mnt]# ls
gitlab  lost+found
[root@VM_161_138_centos mnt]# cd gitlab
[root@VM_161_138_centos gitlab]# mkdir git-data
[root@VM_161_138_centos gitlab]# ls
git-data
[root@VM_161_138_centos gitlab]# cd /mnt/gitlab/git-data

然后将配置文件 /etc/gitlab/gitlab.rb 修改成这样:

git_data_dirs({
  "default" => {
    "path" => "/mnt/gitlab/git-data"
   }
})

然后保存相关文件。可以用以下命令来查看当前 GitLab 服务是否随开机自启动:如果显示 enabled 就是已经启用,如果是 disabled 就是已经禁止。

[root@VM_161_138_centos git-data]# systemctl is-enabled gitlab-runsvdir.service
enabled
[root@VM_161_138_centos git-data]# systemctl disable gitlab-runsvdir.service
Removed symlink /etc/systemd/system/multi-user.target.wants/gitlab-runsvdir.service.
[root@VM_161_138_centos git-data]# systemctl enable gitlab-runsvdir.service
Created symlink from /etc/systemd/system/multi-user.target.wants/gitlab-runsvdir.service to /usr/lib/systemd/system/gitlab-runsvdir.service.
[root@VM_161_138_centos git-data]# systemctl is-enabled gitlab-runsvdir.service
enabled

我们还可以通过以上 enable/disable 命令来启用和禁用开机启动服务。

最后我们需要更新一下 GitLab 的配置并重启 GitLab 服务:

[root@VM_161_138_centos git-data]# gitlab-ctl reconfigure
*****
[root@VM_161_138_centos git-data]# gitlab-ctl restart
ok: run: alertmanager: (pid 17723) 0s
ok: run: gitaly: (pid 17742) 0s
ok: run: gitlab-monitor: (pid 17764) 1s
ok: run: gitlab-workhorse: (pid 17774) 0s
ok: run: grafana: (pid 17787) 1s
ok: run: logrotate: (pid 17804) 0s
ok: run: nginx: (pid 17811) 0s
ok: run: node-exporter: (pid 17819) 1s
ok: run: postgres-exporter: (pid 17906) 0s
ok: run: postgresql: (pid 17918) 1s
ok: run: prometheus: (pid 17928) 0s
ok: run: redis: (pid 17943) 0s
ok: run: redis-exporter: (pid 17948) 0s
ok: run: sidekiq: (pid 17963) 1s
ok: run: unicorn: (pid 17986) 0s

一切准备就绪,我们就开始浏览器访问我们已经配置好的域名相关地址。首次载入会让你修改密码,这个是对用用户名为 root 的管理员账号。

gitlab-first-loading

如果你是公司内部的 GitLab,只允许分配账号,不允许注册账号,可以用管理员身份去后台取消注册,只允许登录。

小技巧:有时候你会发现,用户注册或者后台新建用户,用户无法接收到邮件从而无法完成新用户的创建流程。这个时候,你可以先新建用户,然后通过修改用户信息:修改用户密码来完成对新用户的创建!

启用 https。

一般网站采用 https 会更加安全,可以申请免费的 SSL 证书,也可以购买付费的 SSL 证书,都是一样的。GitLab 启用 https 是非常简单的,它默认的给你处理了一些配置,你只需要按照以下步骤操作即可:

将 /etc/gitlab/gitlab.rb 中的访问地址修改下:

external_url 'http://gitlab.example.com'
修改成:
external_url 'https://gitlab.example.com'

然后用命令行创建指定的目录,然后将相关的证书以指定命名格式放置到目录底下。

sudo mkdir -p /etc/gitlab/ssl
sudo chmod 700 /etc/gitlab/ssl
sudo cp gitlab.example.com.key gitlab.example.com.crt /etc/gitlab/ssl/

然后通过命令行重启配置即可!

sudo gitlab-ctl reconfigure

将 /etc/gitlab/gitlab.rb 中的这段注释打开,然后将值修改成 true,就可以将 http 的访问连接调整到 https。

nginx['redirect_http_to_https'] = true

如果你发现 https 不能访问的时候,看看是不是开启了防火墙,查看防火墙状态的命令:

[root@VM_161_138_centos ~]# systemctl status firewalld
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: active (running) since Thu 2019-09-26 10:56:54 CST; 7min ago
     Docs: man:firewalld(1)
 Main PID: 7703 (firewalld)
   CGroup: /system.slice/firewalld.service
           └─7703 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid

Sep 26 10:56:53 VM_161_138_centos systemd[1]: Starting firewalld - dynamic firewall daemon...
Sep 26 10:56:54 VM_161_138_centos systemd[1]: Started firewalld - dynamic firewall daemon.

如果发现防火墙开启了之后,可以通过以下命令来允许 https 访问:

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

当然要注意将 http 访问的地址指向 https,同时禁止 IP 地址访问。其他参考资料:
《WordPress 博客启用 https》
《GitLab 的 Nginx 配置》
《GitLab 的 SSL 配置》

GitLab 数据备份:
1.可参考 《GitLab 官方数据备份文档》
2.如果感觉以上数据备份很复杂、恢复数据很麻烦,可以推荐使用系统盘镜像/快照 + 数据盘快照备份的方式进行整体数据备份和数据恢复,现在大部分云服务器都支持这种操作,这种很简单也很方便。说明:此方法只适合新手和懒人,但是这种并不保险,保险的做法是既做镜像/快照,又做单独的指定软件的数据备份,数据文件的备份还需要做多重备份保障,这样才保险!

记一次 GitLab 跨服务器迁移的曲折之路
最近由于服务器需要迁移,进行了一次 GitLab 跨服务器迁移的操作,过程还是挺纠结,但是还是一步步的迁移过来了。

需求场景
我们公司的 GitLab 代码服务器是挂载腾讯云上面,独立的服务器:系统盘 + 数据盘的形式,GitLab 的 git-data 是存储在数据盘上,之前是在个人账号底下,由于要做企业账号身份验证,所以要迁移到另外一个经过企业账号验证的服务器上。

尝试步骤 1:是否可以直接将腾讯云个人账号上的服务器的管理权限给到企业账号。
按照平时的操作逻辑应该是可以的。

此种情况下,服务器的主体还是个人管理,还不是很好。看看有没有第二种方法:

尝试步骤 2:是否可以直接将腾讯云个人账号上的服务器的直接迁移到企业账号。
这种想法,按照常规应该支持。

咨询腾讯云官方,说是不能直接将个人账号上的服务器直接迁移到企业账号上,因为涉及到身份认证的问题,所以只能想另外一个办法,因为个人账号上的服务器已经快要到期了,所以可以在企业账号新购买服务器。

尝试步骤 3:在企业账号上购买相似的服务器配置:系统盘+数据盘。空间要能够保证数据迁移。
这种操作没有问题。

购买了相关服务器:系统盘 + 数据盘之后,进行好相关数据盘格式操作和相同位置挂载,进行下一步:

尝试步骤 4:直接通过腾讯云服务在不同账号间可以共享系统镜像和磁盘快照的方式进行数据同步。
这种操作看起来也没有问题。

可以先在个人账号上将当前服务器系统盘制作镜像,然后共享给企业账号,然后企业账号通过重装系统的方式可以直接恢复同步过去。但是数据盘,一旦购买了之后,是没有办法通过数据回滚方式来从共享的数据盘磁盘快照来恢复的,这个时候问题就来了。

尝试步骤 5:将个人账号上的数据盘通过 FTP 方式打包下载上传解压。
这种操作看起来也没有问题。

以上操作方式是没有任何问题的,由于我们的 GitLab 数据较大,以后会更大,考虑到数据盘的数据隔离,我们重新购买了一块新的数据盘,在购买数据盘之前,是通过磁盘快照的方式生成的,这样直接就将数据同步过来了。

尝试步骤 6:调整数据盘的挂载。
这种操作看起来也没有问题。

由于之前 GitLab 的数据目录是指向 /mnt/gitlab/git-data,是 vdb 挂载到 /mnt 底下的,我们现在 GitLab 的数据是在 vdc 上面的,那么我们就先将 vdb 卸载,然后挂载到 /data 目录下,然后将 vdc 挂载到 /mnt 目录就可以,同时注意修改 /etc/fstab 开机启动自动挂载

[root@VM_16_16_centos ~]# umount /mnt
[root@VM_16_16_centos ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        99G   12G   83G  12% /
devtmpfs        3.9G     0  3.9G   0% /dev
tmpfs           3.9G   36K  3.9G   1% /dev/shm
tmpfs           3.9G  684K  3.9G   1% /run
tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
tmpfs           783M     0  783M   0% /run/user/0
[root@VM_16_16_centos ~]# mount /dev/vdb /data
[root@VM_16_16_centos ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        99G   12G   83G  12% /
devtmpfs        3.9G     0  3.9G   0% /dev
tmpfs           3.9G   36K  3.9G   1% /dev/shm
tmpfs           3.9G  684K  3.9G   1% /run
tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
tmpfs           783M     0  783M   0% /run/user/0
/dev/vdb        197G   61M  187G   1% /data
[root@VM_16_16_centos ~]# fdisk -l

Disk /dev/vda: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0009ac89

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048   209715166   104856559+  83  Linux

Disk /dev/vdb: 214.7 GB, 214748364800 bytes, 419430400 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

[root@VM_16_16_centos ~]# fdisk -l

Disk /dev/vda: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk label type: dos
Disk identifier: 0x0009ac89

   Device Boot      Start         End      Blocks   Id  System
/dev/vda1   *        2048   209715166   104856559+  83  Linux

Disk /dev/vdb: 214.7 GB, 214748364800 bytes, 419430400 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes


Disk /dev/vdc: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes

[root@VM_16_16_centos ~]# df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/vda1        99G   11G   83G  12% /
devtmpfs        3.9G     0  3.9G   0% /dev
tmpfs           3.9G   36K  3.9G   1% /dev/shm
tmpfs           3.9G  724K  3.9G   1% /run
tmpfs           3.9G     0  3.9G   0% /sys/fs/cgroup
tmpfs           783M     0  783M   0% /run/user/0
/dev/vdb        197G   61M  187G   1% /data
[root@VM_16_16_centos ~]# cat /etc/fstab
UUID=4b499d76-769a-40a0-93dc-4a31a59add28            /                    ext4       noatime,acl,user_xattr 1 1
proc                 /proc                proc       defaults              0 0
sysfs                /sys                 sysfs      noauto                0 0
debugfs              /sys/kernel/debug    debugfs    noauto                0 0
devpts               /dev/pts             devpts     mode=0620,gid=5       0 0
/dev/vdb /mnt ext4 defaults 0 0
[root@VM_16_16_centos ~]# df -hT
Filesystem     Type      Size  Used Avail Use% Mounted on
/dev/vda1      ext4       99G   11G   83G  12% /
devtmpfs       devtmpfs  3.9G     0  3.9G   0% /dev
tmpfs          tmpfs     3.9G   36K  3.9G   1% /dev/shm
tmpfs          tmpfs     3.9G  724K  3.9G   1% /run
tmpfs          tmpfs     3.9G     0  3.9G   0% /sys/fs/cgroup
tmpfs          tmpfs     783M     0  783M   0% /run/user/0
/dev/vdb       ext4      197G   61M  187G   1% /data
[root@VM_16_16_centos ~]# mount /dev/vdc /mnt
[root@VM_16_16_centos ~]# df -hT
Filesystem     Type      Size  Used Avail Use% Mounted on
/dev/vda1      ext4       99G   11G   83G  12% /
devtmpfs       devtmpfs  3.9G     0  3.9G   0% /dev
tmpfs          tmpfs     3.9G   36K  3.9G   1% /dev/shm
tmpfs          tmpfs     3.9G  724K  3.9G   1% /run
tmpfs          tmpfs     3.9G     0  3.9G   0% /sys/fs/cgroup
tmpfs          tmpfs     783M     0  783M   0% /run/user/0
/dev/vdb       ext4      197G   61M  187G   1% /data
/dev/vdc       ext4       99G   48G   47G  51% /mnt
尝试步骤 7:调整域名指向:由于客观需求,需要修改 GitLab 的指向域名。
GitLab 相关文件修改配置即可。

将 /etc/gitlab/gitlab.rb 中的访问地址修改下:

external_url 'https://gitlab.exampleA.com'
修改成:
external_url 'https://gitlab.exampleB.com'

这个里面有一个很重要的点,就是当你切换了域名指向之后,一定要注意有对应域名的 SSL 证书,腾讯云有免费一年的 SSL 证书可以申请,很快就可以下来,基本上两三个小时到位,如果你切换域名指向之后,SSL 证书没有那么快准备好,就将 /etc/gitlab/gitlab.rb 中的这段注释掉:

nginx['redirect_http_to_https'] = true
尝试步骤 8:修改 SSL 证书
GitLab 官方推荐的操作步骤。

可以直接按照上面证书的操作流程,将相关的 .crt 和 .key 文件按照指定的命名放到指定的文件目录底下。最后通过一下命令行方式,来更新下 GitLab 的配置:

sudo gitlab-ctl reconfigure

请注意:在国内的域名和服务器,一定要备案!

打赏
本博客所有文章如无特别注明均为原创。复制或转载请以超链接形式注明转自ifeegoo 博客,原文地址《CentOS 7 上 GitLab 的安装、备份、迁移及恢复
上一篇: « 下一篇: »
Copyright © ifeegoo 博客 Time is limited, less is more! / 粤ICP备15109713号 / Theme by Hang & Ben / WordPress / 知识共享许可协议