Gitlab 服务器搭建
创建 repo 文件
vim /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
查看可安装版本
yum search gitlab-ce --showduplicates
会列出可以安装的所有版本信息,因为我是要将原来 gitlab 上的内容转移过来,因此选择和之前一致的版本 gitlab-ce-10.2.5-ce.0.el7.x86_64 安装;
安装 Gitlab
yum install gitlab-ce-10.2.5-ce.0.el7.x86_64
如果要安装最新版,可以直接 yum install gitlab-ce;
查看版本
vim /opt/gitlab/embedded/service/gitlab-rails/VERSION
10.2.5
配置
一些配置在 /etc/gitlab/gitlab.rb 中进行配置,如果没有端口冲突等可以不修改配置
配置端口:
nginx['listen_port'] = nil
改为需要的端口,如:
nginx['listen_port'] = 8000
重新加载配置,不管修改不修改配置文件都要执行:
# gitlab-ctl reconfigure
不执行会报如下错误:
/usr/bin/gitlab-rails error: could not load /opt/gitlab/etc/gitlab-rails/gitlab-rails-rc
此时 gitlab 服务已经启动,查看端口(我没有修改配置文件,因此默认为 80 端口):
# netstat -nplt|grep 80
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 12274/nginx: master
备份数据
在原 gitlab 服务器上执行备份数据命令:
# cd /var/opt/gitlab/backups
# gitlab-rake gitlab:backup:create
会生成带有时间戳的备份文件,如:1657606611_2022_07_12_10.2.5_gitlab_backup.tar
恢复数据
在新 gitlab 服务器上进行数据恢复
将在原 gitlab 服务器上备份生成的文件拷贝新服务器上,且拷贝到 /var/opt/gitlab/backups 目录下
# cp 1657606611_2022_07_12_10.2.5_gitlab_backup.tar /var/opt/gitlab/backups/
执行恢复命令:
# gitlab-rake gitlab:backup:restore BACKUP=1657606611_2022_07_12_10.2.5
打开 GitLab 页面
用浏览器打开:http://server-ip