一、服务器配置
官方推荐配置:
- 4核 4GB内存 支持500个用户
- 8核 8GB内存 支持1000个用户
- 磁盘使用SSD
- 至少有 2GB 的交换空间
- 内核的 swappiness 设置配置为较低的值,例如 10
二、安装GitLab
1、安装依赖
-
安装并启动 sshd
# 安装sshd依赖 yum install -y curl policycoreutils-python openssh-server # 启用并启动 sshd systemctl enable sshd systemctl start sshd
-
安装并启动 postfix
# 安装 yum install -y postfix # 启用并启动 systemctl enable postfix systemctl start postfix
2、安装并初始化 gitlab 社区版
-
修改 yum 源
在 /etc/yum.repos.d 目录下新建 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
重新生成缓存:
yum makecache
-
安装 gitlab
安装时如果不指定管理员(root)初始密码,会自动生成一个随机密码。安装时设置初始root密码参考文档。
GITLAB_ROOT_PASSWORD="<strongpassword>" yum install -y gitlab-ce
-
初始化 gitlab
# 重新配置gitlab并重启服务 gitlab-ctl reconfigure
三、常用命令
# 查看组件状态
gitlab-ctl status
# 启动
gitlab-ctl start
# 停止
gitlab-ctl stop
# 重启
gitlab-ctl restart
# 开机启动
systemctl enable gitlab-runsvdir.service
# 禁止开机自启动
systemctl disable gitlab-runsvdir.service
相关资源链接: