gitlab实现主备切换集群

历史:gitlab-ce是不支持分布式架构方案的,所以all in one的服务down后,服务无法迅速恢复

rsync+PostgreSQL备份的方式实现快速切换server ip实现伪高可用

主机列表
192.168.102.7 gitlab-master
192.168.102.7 gitlab-backup

1,搭建gitlab环境(主从一样)

#wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-11.6.5-ce.0.el7.x86_64.rpm
#rpm -ivh gitlab-ce-11.6.5-ce.0.el7.x86_64.rpm
#gitlab-ctl reconfigure
#gitlab-ctl restart

2,rsync同步repo(192.168.102.7)
#ssh-keygen
#ssh-copy-id -i .ssh/id_rsa.pub 192.168.102.8
#/5 * rsync -av /var/opt/gitlab/git-data/repositories 192.168.102.8:/var/opt/gitlab/git-data/ ##这里是默认的repo地址

3,创建测试数据(192.168.102.7)
gitlab实现主备切换集群

这里创建了一个test1的repo

4,备份数据库(192.168.102.7)
#su - gitlab-psql
#pg_dump -c –f gitlabhq_production.sql gitlabhq_production
#scp gitlabhq_production.sql 192.168.102.8:/root

5,恢复数据库(192.168.102.8)
#su - gitlab-psql
#psql -h /var/opt/gitlab/postgresql -d gitlabhq_production -f gitlabhq_production.sql

6,验证从节点数据是否一致
gitlab实现主备切换集群

到此测试完成,以这种方式的恢复,不需要gitlab-rake自带工具恢复,可以快速恢复gitlab的服务

猜你喜欢

转载自blog.51cto.com/chentianwang/2413926
今日推荐