1 背景
之前用的15.10.2版本,已经比较旧了:一方面是安全和兼容性风险越来越高,另一方面很多新功能、修复和维护工具都已经跟老版本脱节了
gitlab更新比较麻烦,某些版本必须先停留,不能直接跨过去
2 下载安装包
按照官方升级路径查询,先准备好这些安装包。由于我用的是Ubuntu22.04系统,直接用deb包来装了。
#download.sh
#!/usr/bin/env bash
set -euo pipefail
BASE_URL="https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu/jammy/pool/main/g/gitlab-ce"
ARCH="amd64"
OUTDIR="${1:-gitlab-ce-upgrade-packages}"
VERSIONS=(
"15.11.13-ce.0"
"16.3.9-ce.0"
"16.7.10-ce.0"
"16.11.10-ce.0"
"17.3.7-ce.0"
"17.5.5-ce.0"
"17.8.7-ce.0"
"17.11.7-ce.0"
"18.2.8-ce.0"
"18.5.5-ce.0"
"18.8.9-ce.0"
"18.11.0-ce.0"
)
mkdir -p "$OUTDIR"
cd "$OUTDIR"
for ver in "${VERSIONS[@]}"; do
file="gitlab-ce_${ver}_${ARCH}.deb"
url="${BASE_URL}/${file}"
echo "Downloading ${file} ..."
wget -c "$url"
done
echo
echo "Done. Packages saved in: $(pwd)"
ls -lh
3 漫长的升级过程
直接写了个脚本来一步步安装,安装前保证旧版本的gitlab正常运行,并且已经做好备份:
# install.sh
#!/usr/bin/env bash
set -euo pipefail
PACKAGES=(
"gitlab-ce_15.11.13-ce.0_amd64.deb"
"gitlab-ce_16.3.9-ce.0_amd64.deb"
"gitlab-ce_16.7.10-ce.0_amd64.deb"
"gitlab-ce_16.11.10-ce.0_amd64.deb"
"gitlab-ce_17.3.7-ce.0_amd64.deb"
"gitlab-ce_17.5.5-ce.0_amd64.deb"
"gitlab-ce_17.8.7-ce.0_amd64.deb"
"gitlab-ce_17.11.7-ce.0_amd64.deb"
"gitlab-ce_18.2.8-ce.0_amd64.deb"
"gitlab-ce_18.5.5-ce.0_amd64.deb"
"gitlab-ce_18.8.9-ce.0_amd64.deb"
"gitlab-ce_18.11.0-ce.0_amd64.deb"
)
for pkg in "${PACKAGES[@]}"; do
echo "Installing $pkg ..."
sudo dpkg -i "./$pkg"
sudo gitlab-ctl reconfigure
sudo gitlab-ctl restart
echo "Check background migrations before continuing."
sudo gitlab-rails runner 'puts Gitlab::BackgroundMigration.remaining'
read -rp "Press Enter to continue to the next version..."
done
这个脚本好像执行到18.5.5左右版本时会报个小错误,可能是某个命令(gitlab-rails那行)太旧用法改变了,但不妨碍继续运行安装。