https://mirror.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/
2.配置並啓動node
gitlab-ctl reconfigure gitlab-ctl status gitlab-ctl stop gitlab-ctl start
3.瀏覽到主機名和登陸Browse to the hostname and loginlinux
Username: root
Password: 5iveL!fenginx
1.Gitlab備份
使用Gitlab一鍵安裝包安裝Gitlab很是簡單, 一樣的備份恢復與遷移也很是簡單. 使用一條命令便可建立完整的Gitlab備份:git
gitlab-rake gitlab:backup:create
使用以上命令會在/var/opt/gitlab/backups目錄下建立一個名稱相似爲
1481598919_gitlab_backup.tar的壓縮包, 這個壓縮包就是Gitlab整個的完整部分, 其中開頭的1481598919是備份建立的日期centos
/etc/gitlab/gitlab.rb 配置文件須備份 /var/opt/gitlab/nginx/conf nginx配置文件 /etc/postfix/main.cfpostfix 郵件配置備份
1.1Gitlab備份目錄
能夠經過/etc/gitlab/gitlab.rb配置文件來修改默認存放備份文件的目錄ruby
gitlab_rails['backup_path'] = "/var/opt/gitlab/backups" /var/opt/gitlab/backups修改成你想存放備份的目錄便可, 修改完成以後使用gitlab-ctl reconfigure命令重載配置文件便可.
1.2Gitlab自動備份
實現天天凌晨2點進行一次自動備份:經過crontab使用備份命令實現bash
0 2 * * * /opt/gitlab/bin/gitlab-rake gitlab:backup:create
2.Gitlab恢復
Gitlab的從備份恢復也很是簡單:服務器
# 中止相關數據鏈接服務 gitlab-ctl stop unicorn gitlab-ctl stop sidekiq # 從1481598919編號備份中恢復 gitlab-rake gitlab:backup:restore BACKUP=1481598919
sudo gitlab-ctl start
3.gitlab遷移
遷移如同備份與恢復的步驟同樣, 只須要將老服務器curl
/var/opt/gitlab/backups
目錄下的備份文件拷貝到新服務器上的/var/opt/gitlab/backups
便可(若是你沒修改過默認備份目錄的話).
可是須要注意的是新服務器上的Gitlab的版本必須與建立備份時的Gitlab版本號相同. 好比新服務器安裝的是最新的7.60版本的Gitlab, 那麼遷移以前, 最好將老服務器的Gitlab 升級爲7.60在進行備份.socket
/etc/gitlab/gitlab.rb gitlab配置文件須遷移,遷移後須要調整數據存放目錄 /var/opt/gitlab/nginx/conf nginx配置文件目錄須遷移 [root@linux-node1 ~]# gitlab-ctl stop unicorn ok: down: unicorn: 0s, normally up [root@linux-node1 ~]# gitlab-ctl stop sidekiq ok: down: sidekiq: 0s, normally up [root@linux-node1 ~]# chmod 777 /var/opt/gitlab/backups/1481598919_gitlab_backup.tar [root@linux-node1 ~]# gitlab-rake gitlab:backup:restore BACKUP=1481598919
4.gitlab升級
1.關閉gitlab服務
gitlab-ctl stop unicorn gitlab-ctl stop sidekiq gitlab-ctl stop nginx
2.備份gitlab
gitlab-rake gitlab:backup:create
3.下載gitlab的RPM包並進行升級
curl -s https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bash yum update gitlab-ce
或者直接安裝高版本
yum install gitlab-ce-8.12.13-ce.0.el7.x86_64
或者上官網下載最新版本 gitlab對應軟件包 gitlab官網
使用 rpm -Uvh gitlab-ce-8.12.13-ce.0.el7.x86_64
報錯.
Error executing action run
on resource 'ruby_block[directory resource: /var/opt/gitlab/git-data/repositories]'
解決方法:
sudo chmod 2770 /var/opt/gitlab/git-data/repositories
4.啓動並查看gitlab版本信息
gitlab-ctl reconfigure gitlab-ctl restart # head -1 /opt/gitlab/version-manifest.txt gitlab-ce 8.7.3
5.gitlab更改默認Nginx
更換gitlab自帶Nginx,使用自行編譯Nginx來管理gitlab服務。
編輯gitlab配置文件禁用自帶Nignx服務器
```
vi /etc/gitlab/gitlab.rb
...
nginx['enable'] = false
...
檢查默認nginx配置文件,並遷移至新Nginx服務
/var/opt/gitlab/nginx/conf/nginx.conf #nginx配置文件,包含gitlab-http.conf文件
/var/opt/gitlab/nginx/conf/gitlab-http.conf #gitlab核心nginx配置文件
重啓 nginx、gitlab服務
$ sudo gitlab-ctl reconfigure
$ sudo service nginx restart
訪問報502。緣由是nginx用戶沒法訪問gitlab用戶的socket文件。 重啓gitlab須要從新受權
chmod -R o+x /var/opt/gitlab/gitlab-rails