一,如圖所示:
二,office-com-gitlab-01安裝html
[root@office-com-gitlab-01 ~]# systemctl stop firewalld [root@office-com-gitlab-01 ~]# systemctl disable firewalld [root@office-com-gitlab-01 ~]# setenforce 0 [root@office-com-gitlab-01 ~]# sed -i 's/SELINUX=enforcing/SELINUX=disabled/g'/etc/sysconfig/selinux [root@office-com-gitlab-01 ~]# yum install iptables* [root@office-com-gitlab-01 ~]# iptables -F;iptables -X;iptables -Z;iptables -t nat -F;iptables -t nat -X;iptables -t nat -Z [root@office-com-gitlab-01 ~]# service iptables save [root@office-com-gitlab-01 ~]# yum install -y curl policycoreutils openssh-server openssh-clients postfix cronie policycoreutils-python python wget [root@office-com-gitlab-01 ~]# yum install git patch [root@office-com-gitlab-01 ~]# wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-11.9.12-ce.0.el7.x86_64.rpm [root@office-com-gitlab-01 ~]# rpm -ivh gitlab-ce-11.9.12-ce.0.el7.x86_64.rpm [root@office-com-gitlab-01 ~]# cat /etc/gitlab/gitlab.rb |grep -E "^external_url" external_url 'http://gitlab2.hs.com' 修改http://後面的網址 [root@office-com-gitlab-01 ~]# gitlab-ctl reconfigure [root@office-com-gitlab-01 ~]# gitlab-ctl start 在客戶端上瀏覽器訪問http://git.topcmd.com
三,office-com-gitlab-02安裝和office-com-gitlab-01一樣python
四,office-com-gitlab-01創建用戶,組,項目
五,Home Page URL設定(提早說一下,A服務器把數據備份還原到B 此時B的Home Page URL仍是A的,二種狀況,1.原來url不變繼續使用2.更換url下面會說如何處理)
六,備份office-com-gitlab-01數據linux
[root@office-com-gitlab-01 ~]# vim /etc/gitlab/gitlab.rb //修改備份目錄 gitlab_rails['manage_backup_path'] = true gitlab_rails['backup_path'] = "/home/gitlab/backups" //gitlab備份目錄 gitlab_rails['backup_archive_permissions'] = 0644 //生成的備份文件權限 gitlab_rails['backup_keep_time'] = 7776000 //備份保留天數爲3個月(即90天,這裏是7776000秒) [root@office-com-gitlab-01 ~]# mkdir -p /home/gitlab/backups [root@office-com-gitlab-01 ~]# chown -R git.git /home/gitlab/backups [root@office-com-gitlab-01 ~]# chmod -R 777 /home/gitlab/backups [root@office-com-gitlab-01 ~]# gitlab-ctl reconfigure [root@office-com-gitlab-01 ~]# gitlab-rake gitlab:backup:create RAILS_ENV=production //備份數據 [root@office-com-gitlab-01 ~]# ls /home/gitlab/backups/ 1560497018_2019_06_14_11.9.12_gitlab_backup.tar [root@office-com-gitlab-01 ~]# scp -r 1560497018_2019_06_14_11.9.12_gitlab_backup.tar root@office-com-gitlab-02:/home/gitlab/backups //拷貝到office-com-gitlab-02上還原
七,還原數據到office-com-gitlab-02git
[root@office-com-gitlab-02 ~]# cd /home/gitlab/backups/ [root@office-com-gitlab-02 backups]# ls 1560497018_2019_06_14_11.9.12_gitlab_backup.tar [root@office-com-gitlab-02 backups]# gitlab-rake gitlab:backup:restore RAILS_ENV=production BACKUP=1560497018_2019_06_14_11.9.12 //還原只還原數字開頭部分
八,驗證數據
8.1當使用git.show.com登錄的時候直接跳轉到git.topcmd.com上,這就是前面提到的Home Page URL,解決辦法就是在域名解析或者host中修改解析。vim
8.2登錄office-com-gitlat-01主機上執行gitlab-ctl stop瀏覽器
8.3修改域名或者hosts記錄192.168.5.101 → git.topcmd.com修改Home Page URL服務器
8.4登錄使用office-com-gitlab-01的用戶名密碼好比root能登錄說明數據已經遷移過去了ssh
8.5登錄修改Home Page URL會出現500錯誤處理以下curl
[root@office-com-gitlab-02 ~]# gitlab-rails c irb(main):001:0> settings=ApplicationSetting.last irb(main):001:0> settings.update_column(:runners_registration_token_encrypted,nil) irb(main):001:0> exit [root@office-com-gitlab-02 ~]# gitlab-ctl restart [root@office-com-gitlab-02 ~]# tail-f/var/log/gitlab/gitlab-rails/production.log //在次登錄修改Home Page URL查看輸出日誌
產考資料:
gitlab備份:http://www.javashuo.com/article/p-dbuusmnv-mq.html
https://www.cnblogs.com/wenwei-blog/p/6362829.html
500錯誤處理:https://gitlab.com/gitlab-org/gitlab-ce/issues/56403ide