gitlab部署

近日,公司决定使用gitlab来做代码缺陷管理,后期也方便把代码库迁移到gitab中,顺便做个部署记录。

GitLab的官方网站找到对应系统安装gitlab的介绍页面如下:
https://about.gitlab.com/install/#centos-6

1.安装依赖包:

1
[admin@haifly-bj-gitlab ~]$ sudo yum install curl policycoreutils openssh-server openssh-clients

2.修改postfix配置:

修改 /etc/postfix/main.cf的设置,后面发邮件用

1
2
3
4
5
inet_protocols = ipv4 
inet_interfaces = all

[admin@haifly-bj-gitlab ~]$ sudo systemctl enable postfix
[admin@haifly-bj-gitlab ~]$ sudo systemctl start postfix

3.配置yum仓库安装gitlab:

1
2
[admin@haifly-bj-gitlab ~]$ curl -sS http://packages.gitlab.cc/install/gitlab-ce/script.rpm.sh | sudo bash
[admin@haifly-bj-gitlab ~]$ sudo yum install gitlab-ce

4.修改external_url

改为自己的gitlab域名地址:

1
2
[admin@haifly-bj-gitlab ~]$ sudo vim /etc/gitlab/gitlab.rb
external_url 'http://gitlab.feiersmart.com'

5.加载配置并启动:

1
[admin@haifly-bj-gitlab ~]$ sudo gitlab-ctl reconfigure

6.配置gitlab邮箱

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[admin@haifly-bj-gitlab ~]$ sudo vim /etc/gitlab/gitlab.rb
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.mxhichina.com"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "gitlab@feiersmart.com"
gitlab_rails['smtp_password'] = "***********"
gitlab_rails['smtp_domain'] = "smtp.feiersmart.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_tls'] = true

gitlab_rails['gitlab_email_enabled'] = true
gitlab_rails['gitlab_email_from'] = 'gitlab@feiersmart.com'
gitlab_rails['gitlab_email_display_name'] = '飞尔Gitlab后台'

验证邮箱:

1
2
3
[admin@haifly-bj-gitlab ~]$ sudo gitlab-rails console

Notify.test_email('18650032533@163.com', 'test1', '1111').deliver_now

7.配置中文支持

可以直接改配置文件支持中文,我使用的版本是gitlab-ce-11.7.0只有部分转换成了中文,已经足够了

1
2
[admin@haifly-bj-gitlab ~]$ sudo vim /etc/gitlab/gitlab.rb
gitlab_rails['time_zone'] = 'Asia/Shanghai'

8.修改数据存储路径

1
2
3
4
5
6
7
8
9
10
11
[admin@haifly-bj-gitlab ~]$ sudo vim /etc/gitlab/gitlab.rb
git_data_dirs({
"default" => {
"path" => "/work/admin/gitlab/git-data"
}
})

postgresql['data_dir'] = "/work/admin/gitlab/postgresql/data"

##! **recommend value is 1/4 of total RAM, up to 14GB.**
postgresql['shared_buffers'] = "512MB"

修改配置文件后执行下 reconfigure

1
[admin@haifly-bj-gitlab ~]$ sudo gitlab-ctl reconfigure

9.启动和重启:

1
2
[admin@haifly-bj-gitlab ~]$ sudo gitlab-ctl start
[admin@haifly-bj-gitlab ~]$ sudo gitlab-ctl restart

结语:

gitlab还是比较吃资源的,用4G内存跑的话页面会出现加载慢,有时还会崩溃无法访问,建议还是用8G内存跑,这也算是我个人在使用gitlab的一点体会吧。

-------------本文结束感谢您的阅读-------------