简单Gitlab服务器的搭建(Gitlab+GerRit+Jenkins)

本文详细介绍了在Centos系统下搭建GitLab服务器的过程,包括硬件配置要求、安装步骤、常见问题解决方法及权限配置,适合企业级代码版本控制需求。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

目前代码版本控制分为两种:集中式管理SVN和分布式管理Git,微软近期以75亿美元收购了Github平台,而GitLab也颇受企业喜爱,因为Github平台只能提供一个私有仓库,而Gitlab服务器可以企业自己搭建。下面就是简单Gitlab服务器的搭建过程。

服务器硬件配置介绍:

https://docs.gitlab.com.cn/ce/install/requirements.html

如果低于4GB+2vCPU请不要尝试,浪费时间。

就算你配置好了,启动了,clone和push代码时也会有各种问题,类似API不可读等。

Centos系统下官网安装步骤:https://about.gitlab.com/installation/#centos-6

docker镜像安装:https://hub.docker.com/r/gitlab/gitlab-ce/

清华开源软件镜像站wget下载安装ce版本:

yum -y install policycoreutils openssh-server openssh-clients postfix
yum install policycoreutils-python
systemctl enable postfix && systemctl start postfix
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-9.0.13-ce.0.el7.x86_64.rpm
rpm -i gitlab-ce-10.8.4-ce.0.el7.x86_64.rpm

如果安装postfix时出现了以下错误:parameter inet_interfaces: no local interface found for ::1

解决方案如下:
vi /etc/postfix/main.cf
修改配置
inet_interfaces = localhost

inet_interfaces = all

完成以上安装步骤在配置文件/etc/gitlab/gitlab.rb中添加:

external_url 'http://your IP:your port'

执行配置命令:

gitlab-ctl reconfigure 

修改配置文件 修改:

vim ./gitlab/embedded/service/gitlab-shell/config.yml

gitlab_url: "http://IP:port"

启动Gitlab:

gitlab-ctl start 

如果页面打开没有输入管理员密码的请删除数据保存目录重新安装,如果还是不行请换版本安装。

如果在创建库之后无法通过点击创建库文件按钮来创建,网页回复为没权限读则替换版本,这是8版本中的一个bug。

管理员账号为root

之后生成ssh秘钥并且将公钥复制到账号下的ssh管理区域,便于代码无秘下载和之后利用各服务器插件来沟通。

 ssh-keygen -t rsa -C 'your email' 

之后可以创建库和创建组管理的库,我们可以给组下的成员相关的权限级别,是Owner、Master、Developer、Reporter、Guest。测试ssh配置

ssh -T git@**.**.***.***
Welcome to GitLab, Administrator!

创建一个私有仓库之后,除了管理员,其他成员只能clone,不能push,这也为GerRit的git review提供了保证,在 Replication插件(GerRit中介绍)中可以使用管理员权限来同步仓库

如果在ssh添加公钥之后还是需要输入密码,这个时候可能是git用户被锁。

出错信息如下:

vim /var/log/secure:
Jun 17 22:32:22 jiche sshd[14931]: reprocess config line 50: Deprecated option RSAAuthentication
Jun 17 22:32:22 jiche sshd[14931]: User git not allowed because account is locked
Jun 17 22:32:22 jiche sshd[14931]: input_userauth_request: invalid user git [preauth]
Jun 17 22:32:24 jiche sshd[14931]: Connection closed by **.**.***.*** port 47170 [preauth]

原因:git用户没有设置密码

解除git用户被锁状态,以root权限执行后重启服务:

#passwd -u -f git
Unlocking password for user git.
passwd: Success
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值