1.环境准备
# 操作系统信息
[root@gitlab ~]# cat /etc/redhat-release
CentOS Linux release 7.8.2003 (Core)
[root@gitlab ~]# uname -r
3.10.0-1127.el7.x86_64
# 关闭防火墙
[root@gitlab ~]# systemctl stop firewalld
[root@gitlab ~]# systemctl disable firewalld
# 关闭 NetworkManager
[root@gitlab ~]# systemctl stop NetworkManager
[root@gitlab ~]# systemctl disable NetworkManager
# 关闭SELINUX 方法1:
[root@gitlab ~]# vim /etc/selinux/config
SELINUX=disabled
:wq! # 保存退出
# 使配置立即生效
[root@gitlab ~]# setenforce 0
# # 关闭SELINUX 方法2:
[root@gitlab ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config
[root@gitlab ~]# grep SELINUX=disabled /etc/selinux/config
[root@gitlab ~]# setenforce 0
# 设置epel源
[root@gitlab ~]# wget http://mirrors.aliyun.com/epel/epel-release-latest-7.noarch.rpm
[root@gitlab ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
# 更新系统并重启
[root@gitlab ~]# yum update -y && reboot
2.yum源配置
[root@gitlab ~]# yum install curl policycoreutils openssh-server openssh-clients postfix -y
[root@gitlab ~]# systemctl start postfix
[root@gitlab ~]# curl -sS https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash
# 修改成为清华源
[root@gitlab ~]# vim /etc/yum.repos.d/gitlab-ce.repo
[gitlab-ce]
name=gitlab-ce
baseurl=http://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7
repo_gpgcheck=0
gpgcheck=0
enabled=1
gpgkey=https://packages.gitlab.com/gpg.key
[root@gitlab ~]# yum makecache
3.安装Gitlab
# 方法1:安装最新的版本
[root@gitlab ~]# yum install -y gitlab-ce git
# 方法2:安装指定版本
[root@gitlab ~]# wget -c http://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-14.6.0-ce.0.el7.x86_64.rpm
[root@gitlab ~]# yum -y localinstall gitlab-ce-14.6.0-ce.0.el7.x86_64.rpm
4.配置启动
# 重载配置文件,耗时较长
[root@gitlab ~]# gitlab-ctl reconfigure
# gitlab常用命令
[root@gitlab ~]# gitlab-ctl stop # 停止
[root@gitlab ~]# gitlab-ctl start # 启动
[root@gitlab ~]# gitlab-ctl restart # 重启
[root@gitlab ~]# gitlab-ctl status # 状态
run: alertmanager: (pid 14092) 42s; run: log: (pid 13844) 104s
run: gitaly: (pid 14082) 42s; run: log: (pid 2340) 206s
run: gitlab-exporter: (pid 14050) 44s; run: log: (pid 13662) 124s
run: gitlab-kas: (pid 14022) 46s; run: log: (pid 2591) 195s
run: gitlab-workhorse: (pid 14033) 45s; run: log: (pid 2726) 141s
run: grafana: (pid 14187) 41s; run: log: (pid 13966) 64s
run: logrotate: (pid 2259) 221s; run: log: (pid 2286) 218s
run: nginx: (pid 2737) 137s; run: log: (pid 6918) 134s
run: node-exporter: (pid 14043) 45s; run: log: (pid 13648) 128s
run: postgres-exporter: (pid 14102) 42s; run: log: (pid 13880) 98s
run: postgresql: (pid 2455) 203s; run: log: (pid 2498) 200s
run: prometheus: (pid 14063) 43s; run: log: (pid 13808) 112s
run: puma: (pid 2653) 155s; run: log: (pid 2660) 154s
run: redis: (pid 2290) 215s; run: log: (pid 2299) 211s
run: redis-exporter: (pid 14052) 44s; run: log: (pid 13778) 116s
run: sidekiq: (pid 2670) 149s; run: log: (pid 2678) 148s
5.访问
http://192.168.120.12
默认用户名:root
密码在/etc/gitlab/initial_root_password文件内:jtblRXwXfYtVmzqK5mlQ9jlESeguwVTEu6Vrtuif5bg=
登录之后修改密码:12345678