# CentOS 部署 GitLab 汉化版
# 介绍
http://www.21yunwei.com/archives/4351
# 使用管道方式部署
GitLab 安装官方地址
https://about.gitlab.com/install
# 使用rpm方式进行部署(本文使用该方式进行部署)
centos (内核7.x)
https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7
centos (内核6.x)
https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el6
请在上方寻找适合安装的版本
下载rpm包
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el6/gitlab-ce-9.3.6-ce.0.el6.x86_64.rpm
1
安装rpm包
rpm -ivh gitlab-ce-9.3.6-ce.0.el6.x86_64.rpm
1
# 配置基础
修改gitlab配置
vim /etc/gitlab/gitlab.rb
1
修改gitlab绑定域名
external_url 'http://www.starmcc.com/gitlab'
1
修改unicorn端口,unicorn默认端口是8080,有可能被占用,修改成其他端口
unicorn['listen'] = 'localhost'
unicorn['port'] = 3000
1
2
2
# 优化GitLab性能
超时时间
unicorn['worker_timeout'] = 60
1
减少进程数,不能低于2,否则卡死 worker=CPU核数+1
unicorn['worker_processes'] = 2
1
减少数据库缓存大小 默认256,可适当改小
postgresql['shared_buffers'] = "256MB"
1
减少数据库并发数
postgresql['max_worker_processes'] = 8
1
减少sidekiq并发数
sidekiq['concurrency'] = 10
1
减少内存
unicorn['worker_memory_limit_min'] = "200 * 1 << 20"
unicorn['worker_memory_limit_max'] = "300 * 1 << 20"
1
2
2
配置邮箱服务SMTP服务器
本例使用的是阿里云ECS服务器,TCP 25端口是默认的邮箱服务端口。基于安全考虑,云服务器ECS的25端口默认受限。阿里云建议使用465端口发送邮件
SMTP服务器设置参考:https://docs.gitlab.com/omnibus/settings/smtp.html
gitlab_rails['smtp_enable'] = true
gitlab_rails['smtp_address'] = "smtp.server"
gitlab_rails['smtp_port'] = 465
gitlab_rails['smtp_user_name'] = "smtp user"
gitlab_rails['smtp_password'] = "smtp password"
gitlab_rails['smtp_domain'] = "example.com"
gitlab_rails['smtp_authentication'] = "login"
gitlab_rails['smtp_enable_starttls_auto'] = true
gitlab_rails['smtp_openssl_verify_mode'] = 'peer'
# If your SMTP server does not like the default 'From: gitlab@localhost' you
# can change the 'From' with this setting.
gitlab_rails['gitlab_email_from'] = 'gitlab@example.com'
gitlab_rails['gitlab_email_reply_to'] = 'noreply@example.com'
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
# 汉化GitLab补丁
汉化库地址
https://gitlab.com/xhang/gitlab
- 查看当前安装的gitlab版本
cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
1
- 克隆汉化版的库(可以直接查看tag获取到对应版本下载)
git clone -b 版本号 https://gitlab.com/xhang/gitlab.git
1
- 比较汉化标签导出补丁
git diff v${gitlab_version} v${gitlab_version}-zh > /tmp/${gitlab_version}-zh.diff
1
git diff v9.3.6-zh v9.3.6-zh > /tmp/v9.3.6-ch.diff
1
- 导入汉化补丁(如果启动了gitlab需要先停止
gitlab-ctl stop
)
patch -d /opt/gitlab/embedded/service/gitlab-rails -p1 < /tmp/v9.3.6-zh.diff
1
或者这样
cd /opt/gitlab/embedded/service/gitlab-rails
git apply /tmp/v9.3.6-zh.diff
1
2
2
- 需要重执行配置命令
sudo gitlab-ctl reconfigure
1
可能出现如一下错误:这是因为补丁中有一些较新的文件,但是我们安装的gitlab并没有这个文件存在,解决办法:一直按回车,跳过即可
# GitLab 基本命令
执行重新配置命令
sudo gitlab-ctl reconfigure
1
启动GitLab
sudo gitlab-ctl start
1
停止GitLab
sudo gitlab-ctl stop
1
# 卸载GitLab
卸载gitlab
sudo rpm -e gitlab-ce
1
查看gitlab进程
ps -ef|grep gitlab
1
杀掉最多....的那个线程
kill -9 pid
删除所有包含gitlab的文件及目录
find / -name gitlab|xargs rm -rf
1
通过以上几步就可以彻底卸载gitlab
# 版本号预留
- 9.3.6