部署gitlab服务
准备环境: 关闭防火墙和selinux
192.168.201.128 #gitlab服务器
配置yum源
[root@git-server ~]# cd /etc/yum.repos.d/
[root@git-server yum.repos.d]# vi gitlab-ce.repo
[gitlab-ce]
name=Gitlab CE Repository
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el$releasever
gpgcheck=0
enabled=1
安装相关依赖
[root@git-server yum.repos.d]# yum install -y curl policycoreutils-python openssh-server
[root@git-server yum.repos.d]# systemctl enable sshd
[root@git-server yum.repos.d]# systemctl start sshd
安装postfix
[root@git-server yum.repos.d]# yum install -y postfix #安装邮箱
[root@git-server yum.repos.d]# systemctl enable postfix
[root@git-server yum.repos.d]# systemctl start postfix
[root@git-server yum.repos.d]# yum install -y gitlab-ce #将会安装gitlab最新版本
配置gitlab
[root@git-server ~]# vim /etc/gitlab/gitlab.rb
1.添加对外的域名(gitlab.papamk.com请添加A记录指向本服务器的公网IP):将原来的修改为
external_url 'http://192.168.201.128'
2.设置地区
gitlab_rails['time_zone'] = 'Asia/Shanghai'
将数据路径的注释去掉
git_data_dirs({
"default" => {
"path" => "/mnt/nfs-01/git-data"
}
})
开启ssh服务:
gitlab_rails['gitlab_shell_ssh_port'] = 22
重置并启动GitLab执行:
[root@git-server ~]# gitlab-ctl reconfigure #重新加载,需要等很长时间
启动:
[root@git-server ~]# gitlab-ctl restart #启动
测试访问:http://192.168.201.128
添加项目时,提示如下所示,则需要添加密钥
(建立密钥时的用户,需要与登录GitLab的用户名一致)
[root@client ~]# ssh-keygen
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
/root/.ssh/id_rsa already exists.
Overwrite (y/n)?
[root@client ~]# cat .ssh/
id_rsa id_rsa.pub known_hosts
[root@client ~]# cat .ssh/id_rsa.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDHwaaorlCxuTyEs0OCLN1Jj7wY6zMMvS/DMwEpSwIAXOz49wKLAnbyWb7IMDG2uyldDYbBEVgLCh35tyxcHU6MyZS/E6g+hmfbHUsTyRqP0wQizN+xNy97pGz0gU/wTG7PTAUE9kvA3kR6kfm5vrWf0kF+9x4akG0YPkEnnhZ2kq3mbCATeoSxkzfFUVNrchdVQehIQU1yo9Gz0VxDI15MxYn9x7s9hHNhh0VADl1y7sxTcSwetAKNp757B/87K4djovkHcXPhVfp2XlM1BU+8aVE0B3dJgDt10hN14IqkvLk4Y3Sp8Xb1Q1AOounbjkyBnfqEcrA1R0b4K0cR+xm3 root@zabbix-node1
[root@client ~]#