Gitlab软件及汉化包下载:
清华大学源(gitlab-ce社区版 centos7下载):https://mirror.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/
汉化包各版本下载(上半部分gitlab处选择tag版本):https://gitlab.com/xhang/gitlab/-/tree/12-0-stable-zh
1.准备基础环境及Gitlab安装包
代码语言:javascript复制[root@localhost ~]# echo Gitlab > /etc/hostname
[root@localhost ~]# hostname Gitlab
--永久关闭防火墙和Selinux
[root@Gitlab ~]# systemctl disable firewalld
[root@Gitlab ~]# systemctl stop firewalld
[root@Gitlab ~]# setenforce 0
[root@Gitlab ~]# sed -i 's/enforcing/disabled/' /etc/selinux/config
[root@Gitlab ~]# getenforce
[root@Gitlab ~]# ll
总用量 700008
-rw-r--r--. 1 root root 76578487 3月 4 14:59 gitlab-12-0-stable-zh.tar.gz
-rw-r--r--. 1 root root 640227518 3月 4 15:00 gitlab-ce-12.0.3-ce.0.el7.x86_64.rpm
2.安装Gitlab服务所需的依赖包
代码语言:javascript复制[root@Gitlab ~]# yum install -y curl policycoreutils-python openssh-server perl
3.使用yum localinstall安装rpm包时会自动解决依赖问题
代码语言:javascript复制[root@Gitlab ~]# yum localinstall -y gitlab-ce-12.0.3-ce.0.el7.x86_64.rpm
...
...
正在安装 : gitlab-ce-12.0.3-ce.0.el7.x86_64 1/1
It looks like GitLab has not been configured yet; skipping the upgrade script.
*. *.
*** ***
***** *****
.****** *******
******** ********
,,,,,,,,,***********,,,,,,,,,
,,,,,,,,,,,*********,,,,,,,,,,,
.,,,,,,,,,,,*******,,,,,,,,,,,,
,,,,,,,,,*****,,,,,,,,,.
,,,,,,,****,,,,,,
.,,,***,,,,
,*,.
_______ __ __ __
/ ____(_) /_/ / ____ _/ /_
/ / __/ / __/ / / __ `/ __
/ /_/ / / /_/ /___/ /_/ / /_/ /
____/_/__/_____/__,_/_.___/
Thank you for installing GitLab!
GitLab was unable to detect a valid hostname for your instance.
Please configure a URL for your GitLab instance by setting `external_url`
configuration in /etc/gitlab/gitlab.rb file.
Then, you can start your GitLab instance by running the following command:
sudo gitlab-ctl reconfigure
For a comprehensive list of configuration options please see the Omnibus GitLab readme
https://gitlab.com/gitlab-org/omnibus-gitlab/blob/master/README.md
验证中 : gitlab-ce-12.0.3-ce.0.el7.x86_64 1/1
已安装:
gitlab-ce.x86_64 0:12.0.3-ce.0.el7
完毕!
4.配置Gitlab服务、访问域名以及邮箱
注意:
每次修改完/etc/gitlab/gitlab.rb
文件都需要重新初始化一次!
[root@Gitlab ~]# vim /etc/gitlab/gitlab.rb
...
external_url 'http://gitlab.fzmyw.com'
...(邮件配置也在里面)
配置邮箱服务的用途:1.账号注册时,邮件验证。2.修改密码时,通过邮件修改。
关闭Gitlab中的Prometheus监控(不使用的话,开着会特别占用内存)
代码语言:javascript复制...
1385 prometheus['enable'] = false #将true修改为false
...
5.初始化Gitlab服务并启动
注意:
每次修改完/etc/gitlab/gitlab.rb
文件都需要重新初始化一次!
[root@Gitlab ~]# gitlab-ctl reconfigure
Starting Chef Client, version 13.6.4
resolving cookbooks for run list: ["gitlab"]
Synchronizing Cookbooks:
- package (0.1.0)
- postgresql (0.1.0)
- redis (0.1.0)
- registry (0.1.0)
- consul (0.1.0)
- gitaly (0.1.0)
- letsencrypt (0.1.0)
- nginx (0.1.0)
- runit (4.3.0)
- acme (3.1.0)
- mattermost (0.1.0)
- crond (0.1.0)
- gitlab (0.0.1)
...
...
[root@Gitlab ~]# gitlab-ctl status #查看gitlab初始化后的状态(启动了很多组件,不需要的都可以关闭)
run: alertmanager: (pid 13077) 164s; run: log: (pid 12872) 207s
run: gitaly: (pid 13027) 166s; run: log: (pid 12194) 295s
run: gitlab-monitor: (pid 13066) 165s; run: log: (pid 12754) 224s
run: gitlab-workhorse: (pid 13047) 166s; run: log: (pid 12591) 251s
run: grafana: (pid 13174) 163s; run: log: (pid 13006) 177s
run: logrotate: (pid 12647) 240s; run: log: (pid 12657) 239s
run: nginx: (pid 12621) 246s; run: log: (pid 12629) 245s
run: node-exporter: (pid 13059) 166s; run: log: (pid 12702) 233s
run: postgres-exporter: (pid 13091) 163s; run: log: (pid 12932) 202s
run: postgresql: (pid 12329) 290s; run: log: (pid 12391) 289s
run: redis: (pid 12135) 302s; run: log: (pid 12165) 301s
run: redis-exporter: (pid 13070) 164s; run: log: (pid 12850) 214s
run: sidekiq: (pid 12549) 258s; run: log: (pid 12561) 255s
run: unicorn: (pid 12508) 264s; run: log: (pid 12531) 261s
6.访问Gitlab服务、以及Gitlab汉化
由于我们在上面配置的Gitlab的域名没有备案,属于假域名,只能供我们自己内网测试,所以Windows本机测试的时候可以修改一下hosts文件,就可以解析到我们配置的域名了。
设置Gitlab登录密码并登录
Gitlab汉化
Gitlab汉化包下载地址(tag处可选版本):https://gitlab.com/xhang/gitlab/-/tree/12-0-stable-zh
代码语言:javascript复制[root@Gitlab ~]# ll
总用量 700008
-rw-r--r--. 1 root root 76578487 3月 4 14:59 gitlab-12-0-stable-zh.tar.gz
-rw-r--r--. 1 root root 640227518 3月 4 15:00 gitlab-ce-12.0.3-ce.0.el7.x86_64.rpm
[root@Gitlab ~]# tar -xf gitlab-12-0-stable-zh.tar.gz #解压Gitlab汉化包
[root@Gitlab ~]# gitlab-ctl stop #停止Gitlab
ok: down: alertmanager: 0s, normally up
ok: down: gitaly: 1s, normally up
ok: down: gitlab-monitor: 0s, normally up
ok: down: gitlab-workhorse: 0s, normally up
ok: down: grafana: 0s, normally up
ok: down: logrotate: 0s, normally up
ok: down: nginx: 1s, normally up
ok: down: node-exporter: 0s, normally up
ok: down: postgres-exporter: 1s, normally up
ok: down: postgresql: 0s, normally up
ok: down: redis: 0s, normally up
ok: down: redis-exporter: 1s, normally up
ok: down: sidekiq: 1s, normally up
ok: down: unicorn: 0s, normally up
[root@Gitlab ~]# cp -r gitlab-12-0-stable-zh/* /opt/gitlab/embedded/service/gitlab-rails/ #加上防止有重复的,在拷贝时会报2个异常(log、tmp),不用管
[root@Gitlab ~]# gitlab-ctl start #启动Gitlab
ok: run: alertmanager: (pid 16842) 0s
ok: run: gitaly: (pid 16850) 1s
ok: run: gitlab-monitor: (pid 16871) 0s
ok: run: gitlab-workhorse: (pid 16874) 1s
ok: run: grafana: (pid 16882) 0s
ok: run: logrotate: (pid 16895) 0s
ok: run: nginx: (pid 16901) 1s
ok: run: node-exporter: (pid 16906) 0s
ok: run: postgres-exporter: (pid 16910) 1s
ok: run: postgresql: (pid 16991) 0s
ok: run: redis: (pid 17000) 1s
ok: run: redis-exporter: (pid 17004) 0s
ok: run: sidekiq: (pid 17009) 0s
ok: run: unicorn: (pid 17015) 1s