下载Github安装包(选择社区版本)
清华大学开源软件镜像站:
https://mirrors.tuna.tsinghua.edu.cn/
示例采用 gitlab-ce-13.1.2-ce.0.el7.x86_64.rpm
配置依赖步骤
1) 安装防火墙
yum install firewalld systemd -y
2) 开启防火墙
service firewalld start
3) 安装SSH协议
yum install -y curl policycoreutils-python openssh-server
4) 设置SSH服务开机自启动
systemctl enable sshd
5) 启动SSH服务
systemctl start sshd
6) 添加HTTP和HTTPS服务到firewalld
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
7) 重启防火墙
systemctl reload firewalld
8) 安装Postfix以发送通知邮件
yum install postfix
9) 将postfix服务设置成开机自启动
systemctl enable postfix
10) 启动postfix
systemctl start postfix
11) 安装vim编辑器
yum install vim -y
安装GitLab
1) 安装rpm包
rpm -ivh gitlab-ce-13.1.2-ce.0.el7.x86_64.rpm
2) 修改配置文件
#编辑配置文件
vim /etc/gitlab/gitlab.rb
#修改访问URL
#格式:external_url 'http://ip:端口'
external_url 'http://127.0.0.1:80'
#配置时区
gitlab_rails['time_zone'] = 'Asia/Shanghai'
#配置仓库地址
git_data_dirs({
"default" => {
"path" => "/data/git-data"
}
})
#配置仓库备份地址
gitlab_rails['backup_path'] = "/data/gitlab/backups"
#配置仓库备份自动删除时间2天
gitlab_rails['backup_keep_time'] = 172800
3) 开放防火墙端口
# 开放80端口
firewall-cmd --zone=public --add-port=80/tcp --permanent
# 重启防火墙
firewall-cmd --reload
# 验证防火墙端口
firewall-cmd --query-port=80/tcp
4) 重置Gitlab配置
gitlab-ctl reconfigure
5) 启动Gitlab
gitlab-ctl restart
gitlab 数据备份
方案一
远程NAS文件服务器或者 win共享文件夹
将文件地址挂载到gitlab服务器安装服务器 地址自己设置
通过linux 定时任务方式
命令 crontab -e
# create gitlab backups
0 1 * * * /opt/gitlab/bin/gitlab-rake gitlab:backup:create
# copy gitlab backups to data1
0 2 * * * find /data/gitlab/backups/ -mtime -1 -name "*_gitlab_backup.tar" | xargs cp -t /data1
# 删除备份文件个数保留历史2天的记录
0 2 * * * find /data1 -mtime 2 -name "*_gitlab_backup.tar" | xargs rm -rf
命令 service crond restart
常用命令
# 更新配置
gitlab-ctl reconfigure
# 启动gitlab
gitlab-ctl start 或者 gitlab-ctl restart
# 关闭gitlab
gitlab-ctl stop