gitlab安裝和遷移

一,如圖所示:
gitlab安裝和遷移
二,office-com-gitlab-01安裝

[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同樣

四,office-com-gitlab-01建立用戶,組,項目
gitlab安裝和遷移
gitlab安裝和遷移
五,Home Page URL設定(提前說一下,A服務器把數據備份還原到B 此時B的Home Page URL還是A的,二種情況,1.原來url不變繼續使用2.更換url下面會說如何處理)
gitlab安裝和遷移
六,備份office-com-gitlab-01數據

[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-02

[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中修改解析。

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能登陸說明數據已經遷移過去了

8.5登陸修改Home Page URL會出現500錯誤處理如下

[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備份:https://www.cnblogs.com/kevingrace/p/7821529.html
https://www.cnblogs.com/wenwei-blog/p/6362829.html
500錯誤處理:https://gitlab.com/gitlab-org/gitlab-ce/issues/56403

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章