Gitlab安装配置管理

安装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# vim /etc/yum.repos.d/gitlab-ce.repo
[gitlab-ce]
name=Gitlab CE Repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever/
gpgcheck=0
enabled=1

# yum makecache
# EXTERNAL_URL="http://172.16.100.99"
# yum install -y gitlab-ce

# gitlab-ctl reconfigure
# gitlab-ctl status
run: gitaly: (pid 3627) 9s; run: log: (pid 3287) 40s
run: gitlab-monitor: (pid 3667) 8s; run: log: (pid 3493) 28s
run: gitlab-workhorse: (pid 3653) 9s; run: log: (pid 3315) 39s
run: logrotate: (pid 3387) 36s; run: log: (pid 3386) 36s
run: nginx: (pid 3361) 38s; run: log: (pid 3360) 38s
run: node-exporter: (pid 3475) 30s; run: log: (pid 3474) 30s
run: postgres-exporter: (pid 3726) 7s; run: log: (pid 3565) 19s
run: postgresql: (pid 3111) 90s; run: log: (pid 3110) 90s
run: prometheus: (pid 3710) 8s; run: log: (pid 3537) 21s
run: redis: (pid 3051) 96s; run: log: (pid 3050) 96s
run: redis-exporter: (pid 3521) 22s; run: log: (pid 3520) 22s
run: sidekiq: (pid 3268) 46s; run: log: (pid 3267) 46s
run: unicorn: (pid 3230) 48s; run: log: (pid 3229) 48s

集成LDAP

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
gitlab_rails['ldap_enabled'] = true
gitlab_rails['ldap_servers'] = YAML.load <<-'EOS'
main:
label: 'LDAP'
host: '192.168.1.20'
port: 389
uid: 'sAMAccountName'
bind_dn: 'CN=***,OU=服务器软件部五组,OU=服务器软件部,OU=研发中心,OU=亿联-用户,DC=yealink,DC=com'
password: '******'
encryption: 'plain'
verify_certificates: false
active_directory: true
allow_username_or_email_login: false
block_auto_created_users: false
base: 'DC=yealink,DC=com'
user_filter: ''
EOS

通过gitlab-rake gitlab:ldap:check命令可检查LDAP配置

1
2
3
4
5
6
7
8
9
# gitlab-ctl reconfigure
# gitlab-rake gitlab:ldap:check
Checking LDAP ...

Server: ldapmain
LDAP authentication... Success
LDAP users with access to your GitLab server (only showing the first 100 results)
<...以下省略100行,若无输出一般是user_filter配置错了...>
Checking LDAP ... Finished

配置邮件通知

postfix

前提需要配置postfix能够发送邮件,先用以下命令测试,具体配置可参考http://blog.51cto.com/vnimos/1203162#T1

echo "postfix test again" | mail -s 'postfix_test2' zyp19891128@163.com

1
2
3
gitlab_rails['gitlab_email_enabled'] = true
gitlab_rails['gitlab_email_from'] = 'gitlab@vnimos.com'
gitlab_rails['gitlab_email_display_name'] = 'Gitlab'

smtp

通过stmp,不需要配置sendmail或postfix。

  • 163邮箱

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    gitlab_rails['gitlab_email_from'] = 'zyp19891128@163.com'
    gitlab_rails['gitlab_email_display_name'] = 'Gitlab'
    gitlab_rails['smtp_enable'] = true
    gitlab_rails['smtp_address'] = "smtp.163.com"
    gitlab_rails['smtp_port'] = 25
    gitlab_rails['smtp_user_name'] = "zyp19891128@163.com"
    gitlab_rails['smtp_password'] = "<授权密码,非邮箱密码>"
    gitlab_rails['smtp_domain'] = "163.com"
    gitlab_rails['smtp_authentication'] = "login"
    gitlab_rails['smtp_enable_starttls_auto'] = true
    gitlab_rails['smtp_tls'] = false
  • 公司邮箱

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    gitlab_rails['gitlab_email_from'] = '***@yealink.com'
    gitlab_rails['gitlab_email_display_name'] = 'Gitlab'
    gitlab_rails['smtp_enable'] = true
    gitlab_rails['smtp_address'] = "mail.yealink.com"
    gitlab_rails['smtp_port'] = 587
    gitlab_rails['smtp_user_name'] = "yl1844"
    gitlab_rails['smtp_password'] = "****"
    gitlab_rails['smtp_domain'] = "yealink.com"
    gitlab_rails['smtp_authentication'] = "login"
    gitlab_rails['smtp_enable_starttls_auto'] = true
    gitlab_rails['smtp_tls'] = false
    gitlab_rails['smtp_openssl_verify_mode'] = 'none'

smtp邮箱问题排查

OpenSSL::SSL::SSLError: SSL_connect returned=1 errno=0 state=SSLv2/v3 read server hello A: unknown protocol

该报错提示SSL认证错误,需要禁用SSL认证,或启用SSL认证时填写正确的SSL对应的端口。

1
2
3
4
gitlab_rails['smtp_tls'] = false
---------------------------------
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_tls'] = true

另外SMTP授权认证问题可参考:# SMTP邮箱登录验证


备份

1
2
3
4
# gitlab-rake gitlab:backup:create
# ll /var/opt/gitlab/backups/
total 252
-rw------- 1 git git 256000 Jul 12 16:51 1531385481_2018_07_12_10.1.3_gitlab_backup.tar

恢复

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# gitlab-ctl stop unicorn
# gitlab-ctl stop sidekiq
# gitlab-ctl status
run: gitaly: (pid 3627) 2782s; run: log: (pid 3287) 2813s
run: gitlab-monitor: (pid 3667) 2781s; run: log: (pid 3493) 2801s
run: gitlab-workhorse: (pid 3653) 2782s; run: log: (pid 3315) 2812s
run: logrotate: (pid 3387) 2809s; run: log: (pid 3386) 2809s
run: nginx: (pid 7235) 1637s; run: log: (pid 3360) 2811s
run: node-exporter: (pid 3475) 2803s; run: log: (pid 3474) 2803s
run: postgres-exporter: (pid 3726) 2780s; run: log: (pid 3565) 2792s
run: postgresql: (pid 3111) 2863s; run: log: (pid 3110) 2863s
run: prometheus: (pid 3710) 2781s; run: log: (pid 3537) 2794s
run: redis: (pid 3051) 2869s; run: log: (pid 3050) 2869s
run: redis-exporter: (pid 3521) 2795s; run: log: (pid 3520) 2795s
down: sidekiq: 103s, normally up; run: log: (pid 3267) 2819s
down: unicorn: 114s, normally up; run: log: (pid 3229) 2821s

# gitlab-rake gitlab:backup:restore BACKUP=1531385481_2018_07_12_10.1.3

# gitlab-ctl restart
ok: run: gitaly: (pid 10554) 0s
ok: run: gitlab-monitor: (pid 10566) 1s
ok: run: gitlab-workhorse: (pid 10574) 0s
ok: run: logrotate: (pid 10619) 0s
ok: run: nginx: (pid 10630) 1s
ok: run: node-exporter: (pid 10638) 0s
ok: run: postgres-exporter: (pid 10644) 1s
ok: run: postgresql: (pid 10653) 0s
ok: run: prometheus: (pid 10661) 0s
ok: run: redis: (pid 10671) 0s
ok: run: redis-exporter: (pid 10675) 0s
ok: run: sidekiq: (pid 10681) 1s
ok: run: unicorn: (pid 10688) 0s

# gitlab-rake gitlab:check SANITIZE=true

升级

当前版本为10.1.3,升级到最新版本(11.0.3),需要先升级到10.x的最新版本(当前为10.8.5),才能进行跨版本升级。

升级过程中gitlab将自动进行备份,安装新版本并卸载、清除旧版本的gitlab,然后reconfigure

1
2
# rpm -Uvh gitlab-ce-10.8.5-ce.0.el7.x86_64.rpm
# rpm -Uvh gitlab-ce-11.0.3-ce.0.el7.x86_64.rpm
坚持原创技术分享,您的支持将鼓励我继续创作!
0%