升級思路:先在新服務器上安裝一個和原版本相同版本的gitlab,然后備份原版本gitlab數(shù)據(jù),備份完在新服務器恢復,恢復完在進行升級。
1.查看gitlab版本的命令:
gitlab-rake gitlab:env:info
備份原老服務器上的的數(shù)據(jù)
gitlab-rake gitlab:backup:create RAILS_ENV=production
PS: 備份后的文件一般是位于/var/opt/gitlab/backups下, 自動生成文件名文件名如1481529483_gitlab_backup.tar
將步驟2生成的tar文件拷貝到新服務器上相應的backups目錄下
可以利用scp進行直接拷貝.
scp username@src_ip:/var/opt/gitlab/backups/1481529483_gitlab_backup.tar /var/opt/gitlab/backups
PS: username為原服務器的用戶名,src_ip原服務器IP地址
在新服務器恢復數(shù)據(jù)
gitlab-rake gitlab:backup:restore RAILS_ENV=production BACKUP=1481529483
PS:BACKUP的時間點必須與原服務器備份后的文件名一致
5.出錯解決:
數(shù)據(jù)遷移到后檢查登錄gialab有時候會跳出500報錯(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內核會根據(jù)參數(shù)vm.overcommit_memory參數(shù)的設置決定是否放行。
修改完執(zhí)行sysctl -p
vm.overcommit_memory = 1,直接放行
vm.overcommit_memory = 0:則比較 此次請求分配的虛擬內存大小和系統(tǒng)當前空閑的物理內存加上swap,決定是否放行。
vm.overcommit_memory = 2:則會比較進程所有已分配的虛擬內存加上此次請求分配的虛擬內
在升級前一定要做好備份,記錄自己當前gitlab-ca的版本號。
查看當前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的升級不能跨越大版本號,因此只能升級到當前大版本號到最高版本,方可升級到下一個大版本號。
需要做的升級步驟如下:
11.4.3->11.11.8->12.0.9
1、準備好相關的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í)行gitlab-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
完成之后再查看下當前的版本:
[root@gitlab ~]# cat /opt/gitlab/embedded/service/gitlab-rails/VERSION
12.0.9