GitLab 12.7.6 迁移记

2021-02-19  本文已影响0人  云顶天宫写代码

安装gitlab的前提是服务器硬件最低2核4G,如果不够,可以设置交换分区(建议在安装gitlab之前)
相互迁移的gitlab版本尽量要一致,切记!!!否则你可能需要猜很多的坑。

安装步骤如下:

1. 更换镜像地址

vi /etc/yum.repos.d/gitlab-ce.repo

然后将下面的内容复制粘贴进去

[gitlab-ce]
name=gitlab-ce
# 清华大学的镜像源
baseurl=http://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7
repo_gpgcheck=0
gpgcheck=0
enabled=1
gpgkey=https://packages.gitlab.com/gpg.key

2. 在CentOS系统上,下面的命令将会打开系统防火墙HTTP和SSH访问。

# 安装所需的环境依赖
sudo yum install curl policycoreutils openssh-server openssh-clients 
# 开启ssh
sudo systemctl enable sshd
sudo systemctl start sshd
# 安装及开启邮件服务
sudo yum install postfix
sudo systemctl enable postfix
sudo systemctl start postfix
# 防火墙的相关处理
sudo firewall-cmd --permanent --add-service=http
sudo systemctl reload firewalld 
# 如果是阿里云的服务器因为有安全组的策略可能有时不需要开启防火墙,需要关闭防火墙
firewall-cmd --state
systemctl stop firewalld.service
systemctl disable firewalld.service
systemctl stop firewalld.service
firewall-cmd --state

注:如果启动邮件服务报错如下

image

解决方法:
修改 /etc/postfix/main.cf的设置
inet_protocols = ipv4
inet_interfaces = all
重新启动postfix即可
systemctl start postfix.service

image

3. 执行命令,重新生成cache

yum clean all
yum makecache

4 执行安装命令:

$ sudo yum install gitlab-ce
sudo yum install gitlab-ce-12.7.6 // 12.7.6是指定的版本

5 加载配置

$ sudo gitlab-ctl reconfigure

6 重新启动

$ sudo gitlab-ctl restart

迁移代码如下:

1. 备份数据

在旧的代码服务器上执行命令

gitlab-rake gitlab:backup:create

当然如果想配置备份参数,还需要你自己去详细看文档,这里采用默认的备份方式

备份文件存放于

/var/opt/gitlab/backups

文件名类似于

1613699577_2021_02_19_12.7.6_gitlab_backup.tar

2.备份必要的文件

将下面两个文件通过你的ftp工具,导入到新的服务器上
/etc/gitlab/gitlab-secrets.json/etc/gitlab/gitlab.rb
这两个文件非常重要,一是秘钥的记录文件,一个是配置文件,关系到备份好的数据能在新服务器能正常使用

3.修改 external_url

新服务器上执行命令

vim /etc/gitlab/gitlab.rb

在只读模式下使用/搜索 external_url,N向下搜索,shift+n 向上搜索
/external_url
以 176.289.28.2:8999为例,改成如下这样

external_url 'http://176.289.28.2:8999

:wq 保存

4. 执行命令

gitlab-ctl reconfigure && gitlab-ctl restart
上一篇 下一篇

猜你喜欢

热点阅读