在服务器上搭建Gitlab服务
- 添加镜像 把文件下载到服务器上 命令如下:
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm
执行完成之后展示如下:
Resolving mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)... 101.6.8.193, 2402:f000:1:408:8100::1
Connecting to mirrors.tuna.tsinghua.edu.cn (mirrors.tuna.tsinghua.edu.cn)|101.6.8.193|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 359519811 (343M) [application/x-redhat-package-manager]
Saving to: ‘gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm’
100%[=========================================================================================================================================================>] 359,519,811 9.15MB/s in 36s
2019-12-28 15:01:27 (9.63 MB/s) - ‘gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm’ saved [359519811/359519811]
- 安装命令
rpm -i gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm
执行完成之后展示如下(这里会有警告和错误,需要安装依赖)
warning: gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID f27eab47: NOKEY
error: Failed dependencies:
policycoreutils-python is needed by gitlab-ce-10.0.0-ce.0.el7.x86_64
-
安装依赖命令
yum install -y policycoreutils-python -
再次执行安装命令
rpm -i gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm
执行完成之后 如下显示就意味着安装成功了:
warning: gitlab-ce-10.0.0-ce.0.el7.x86_64.rpm: Header V4 RSA/SHA1 Signature, key ID f27eab47: NOKEY
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
- 配置文件修改命令(指定服务器ip和自定义端口)
vim /etc/gitlab/gitlab.rb
修改内容:
external_url 'http://10.11.1.149:8210/'
- 重置命令
gitlab-ctl reconfigure
执行完成之后展示如下:
Running handlers:
Running handlers complete
Chef Client finished, 360/515 resources updated in 01 minutes 52 seconds
gitlab Reconfigured!
- 重启命令
gitlab-ctl restart
执行完成之后,展示如下:
ok: run: gitaly: (pid 9138) 1s
ok: run: gitlab-monitor: (pid 9157) 0s
ok: run: gitlab-workhorse: (pid 9161) 1s
ok: run: logrotate: (pid 9211) 0s
ok: run: nginx: (pid 9217) 1s
ok: run: node-exporter: (pid 9226) 0s
ok: run: postgres-exporter: (pid 9232) 0s
ok: run: postgresql: (pid 9243) 0s
ok: run: prometheus: (pid 9251) 0s
ok: run: redis: (pid 9261) 1s
ok: run: redis-exporter: (pid 9266) 0s
ok: run: sidekiq: (pid 9278) 0s
ok: run: unicorn: (pid 9287) 0s
[root@tunfishcms ~]#
提示 "ok: run:"表示启动成功
- 访问我们搭建的Gitlab服务
http://101.132.195.59:8210
第一次打开,提示修改密码,默认账号是root
mark:gitlab起好之后,可能访问不了,应该是服务器防火墙问题,我们需要把服务器防火墙进行关闭
// 启动防火墙
systemctl start firewalld.service
//重启防火墙
systemctl restart firewalld.service
// 关闭防火墙
systemctl stop firewalld.service
//查看当前防火墙状态
firewall-cmd --stat