升級思路:先在新服務(wù)器上安裝一個和原版本相同版本的gitlab鲫趁,然后備份原版本gitlab數(shù)據(jù),備份完在新服務(wù)器恢復(fù)利虫,恢復(fù)完在進(jìn)行升級挨厚。
1.查看gitlab版本的命令:
gitlab-rake gitlab:env:info
備份原老服務(wù)器上的的數(shù)據(jù)
gitlab-rake gitlab:backup:create RAILS_ENV=production
PS: 備份后的文件一般是位于/var/opt/gitlab/backups下, 自動生成文件名文件名如1481529483_gitlab_backup.tar
將步驟2生成的tar文件拷貝到新服務(wù)器上相應(yīng)的backups目錄下
可以利用scp進(jìn)行直接拷貝.
scp username@src_ip:/var/opt/gitlab/backups/1481529483_gitlab_backup.tar /var/opt/gitlab/backups
PS: username為原服務(wù)器的用戶名,src_ip原服務(wù)器IP地址
在新服務(wù)器恢復(fù)數(shù)據(jù)
gitlab-rake gitlab:backup:restore RAILS_ENV=production BACKUP=1481529483
PS:BACKUP的時間點(diǎn)必須與原服務(wù)器備份后的文件名一致
5.出錯解決:
數(shù)據(jù)遷移到后檢查登錄gialab有時候會跳出500報(bào)錯(Something went wrong on our end.)以及無法正常新建用戶
查看日志:tail -f /var/log/gitlab/redis/current
Can't save in background: fork: Cannot allocate memory
解決方案:
修改/etc/sysctl.conf
加上vm.overcommit_memory = 1, Linux內(nèi)核會根據(jù)參數(shù)vm.overcommit_memory參數(shù)的設(shè)置決定是否放行糠惫。
修改完執(zhí)行sysctl -p
vm.overcommit_memory = 1疫剃,直接放行
vm.overcommit_memory = 0:則比較 此次請求分配的虛擬內(nèi)存大小和系統(tǒng)當(dāng)前空閑的物理內(nèi)存加上swap,決定是否放行硼讽。
vm.overcommit_memory = 2:則會比較進(jìn)程所有已分配的虛擬內(nèi)存加上此次請求分配的虛擬內(nèi)
在升級前一定要做好備份巢价,記錄自己當(dāng)前gitlab-ca的版本號。
查看當(dāng)前gitlab版本號
[root@localhost ~]``# yum list | grep gitlab-ce
gitlab-ce.x86_64 11.4.3-ce.0.el7 installed
備份文件
[root@localhost ~]# gitlab-rake gitlab:backup:create
在/var/opt/gitlab/backups下會生成一個備份文件如:1557218709_2019_05_07_9.2.2_gitlab_backup.tar固阁,其中1557218709即為此次備份都版本號壤躲。
還原備份
執(zhí)行
gitlab-rake gitlab:backup:restore BACKUP=備份版本號
(一)配置gitlab-yum源
[root@localhost ~]# cat << EOF > /etc/yum.repos.d/gitlab-ce.repo
[gitlab-ce]
name=gitlab-ce
baseurl=https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/
repo_gpgcheck=0
gpgcheck=0
enable=1
gpgkey=https://packages.gitlab.com/gpg.key
EOF
(二)yum localinstall安裝
注意:Gitlab的升級不能跨越大版本號,因此只能升級到當(dāng)前大版本號到最高版本备燃,方可升級到下一個大版本號碉克。
需要做的升級步驟如下:
11.4.3->11.11.8->12.0.9
1、準(zhǔn)備好相關(guān)的rpm包
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-11.11.8-ce.0.el7.x86_64.rpm
wget https://mirrors.tuna.tsinghua.edu.cn/gitlab-ce/yum/el7/gitlab-ce-12.0.9-ce.0.el7.x86_64.rpm
2并齐、依次執(zhí)行下面指令逐步升級漏麦,在每一步安裝成功后如果發(fā)現(xiàn)界面500客税,執(zhí)行g(shù)itlab-ctl reconfigure指令刷新配置文件。(一定保證數(shù)據(jù)可以正常訪問方可執(zhí)行下一步升級指令)
yum localinstall -y gitlab-ce-11.11.8-ce.0.el7.x86_64.rpm
yum localinstall -y gitlab-ce-12.0.9-ce.0.el7.x86_64.rpm
完成之后再查看下當(dāng)前的版本:
[root@gitlab ~]# cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
12.0.9