Docker中GitLab的升级 及 mysql更换成pgsql
GitLab-CE 8.14.1 ==> GitLab-CE 11.10.4
其中mysql ==> pgsql
- gitlab旧版本镜像使用的是sameersbn/docker-gitlab:8.14.1,新版本镜像sameersbn/gitlab:11.10.4
- postgresql镜像使用的是sameersbn/postgresql:9.6
- redis镜像使用的是sameersbn/redis:latest
- 使用旧版本的gitlab8.14.1的镜像,安装完redis和pgsql9.6版本
- 迁移旧版本gitlab的/home/git/data的数据(有外部路径就备份外部路径)
- 使用专用迁移工具迁移旧版本mysql的数据到pgsql9.6
- 启动gitlab8.14.1镜像,加载数据,尝试正常启动gitlab
- 依照参考资料,对镜像进行逐级升级重启
本地虚拟机迁移
- 使用以下实际迁移操作时使用的脚本
-rwxr-xr--. 1 root root 851 6月 3 10:42 start_gitlab_10.8.4.sh
-rwxr-xr--. 1 root root 852 6月 3 11:26 start_gitlab_11.10.4.sh
-rwxr-xr--. 1 root root 851 6月 3 10:21 start_gitlab_8.14.1.sh
-rwxr-xr--. 1 root root 850 6月 3 10:34 start_gitlab_8.17.4.sh
-rwxr-xr--. 1 root root 849 6月 3 10:38 start_gitlab_9.5.5.sh
-rwxr-xr--. 1 root root 886 6月 3 11:26 start_gitlab_backup_10.8.4.sh
-rwxr-xr--. 1 root root 885 6月 3 10:33 start_gitlab_backup_8.14.1.sh
-rwxr-xr--. 1 root root 885 6月 3 10:37 start_gitlab_backup_8.17.4.sh
-rwxr-xr--. 1 root root 884 6月 3 10:40 start_gitlab_backup_9.5.5.sh
- 8.14.1直升8.17.4
$./start_gitlab_backup_8.14.1.sh
$./start_gitlab_8.17.4.sh
- 8.17.4直升9.5.5
$./start_gitlab_backup_8.17.4.sh
$./start_gitlab_9.5.5.sh
- 9.5.5直升10.8.4
$./start_gitlab_backup_9.5.5.sh
$./start_gitlab_10.8.4.sh
- 10.8.4直升11.10.4
$./start_gitlab_backup_10.8.4.sh
# 更换为
$docker exec -it -u root gitlab10 bash
$bundle exec rake gitlab:backup:create RAILS_ENV=production
出现10.8.4备份失败的问题:
解决方案参考:
https://github.com/sameersbn/docker-gitlab/issues/1576#issuecomment-437339882
https://github.com/sameersbn/docker-gitlab/issues/1576#issuecomment-390137195 (本地试用有效)
$./start_gitlab_11.10.4.sh
本地虚拟机迁移操作
1. 先整体搬迁旧gitlab,搭建环境
- 迁移旧gitlab仓库的data文件夹,文件夹拷贝到新宿主机上的/srv/docker/gitlab/gitlab/data,完成gitlab基本数据迁移
# 先压缩,再scp,再解压
- 修改postgresql的镜像启动脚本(指定好gitlab的gitlabhq_production数据库)
$vi start_postgresql9.6.sh
docker run --name postgresql_gitlab_9_6 -itd --restart always \
--env 'PG_PASSWORD=passw0rd' \
--env 'DB_NAME=gitlabhq_production' \
--env 'DB_USER=gitlab' --env 'DB_PASS=passw0rd' \
--env 'DB_EXTENSION=pg_trgm' \
--volume /srv/docker/gitlab/postgresql9:/var/lib/postgresql \
--volume /etc/localtime:/etc/localtime:ro \
--publish 5431:5432 \
sameersbn/postgresql:9.6
- 启动postgresql后,再修改gitlab8.14.1的启动脚本(指定好pgsql和数据路径)
# 启动前清除pgsql的旧数据
$rm /srv/docker/gitlab/postgresql9
# 修改gitlab启动脚本
$vi start_gitlab_8_14_1.sh
docker run --name gitlab8 -d \
--link postgresql_gitlab_9_6:postgresql \
--link redis_gitlab:redisio \
-e 'UNICORN_WORKERS=15' \
-e 'GITLAB_SECRETS_DB_KEY_BASE=long-and-random-alpha-numeric-string' \
-e 'GITLAB_SECRETS_SECRET_KEY_BASE=long-and-random-alpha-numeric-string' \
-e 'GITLAB_SECRETS_OTP_KEY_BASE=long-and-random-alpha-numeric-string' \
-e 'SMTP_USER=xxx@xxx.com' \
-e 'SMTP_PASS=123456' \
-e 'SMTP_ENABLED=true' \
-e 'SMTP_DOMAIN=xxx.com' \
-e 'SMTP_HOST=xx.xx.xx.xx' \
-e 'NGINX_MAX_UPLOAD_SIZE=128m' \
-e 'SMTP_AUTHENTICATION=login' \
-e 'GITLAB_HOST=192.166.204.130' \
-e 'GITLAB_SSH_PORT=10022' \
-e 'GITLAB_PORT=10080' \
-v /srv/docker/gitlab/gitlab/data:/home/git/data \
-v /etc/localtime:/etc/localtime:ro \
-p 10022:22 \
-p 10080:80 \
-p 10443:443 \
sameersbn/gitlab:8.14.1
- 正常启动过gitlab8后,停止gitlab8容器,再准备迁移mysql数据
$docker stop gitlab8
数据迁移方法一:直接转换mysql的数据库到pgsql(不推荐有问题)
- 导出mysql数据
$mysqldump --compatible=postgresql --default-character-set=utf8 -r gitlabhq_production.mysql -uroot -p gitlabhq_production
- dump数据调整(即使用mysql的数据和数据结构)
# - lanyrd/mysql-postgresql-converter
# 更换采用本地调整过的代码 $python db_converter.py gitlabhq_production.mysql gitlabhq_production.psql
$python db_converter_for_exist_tb.py gitlabhq_production.mysql gitlabhq_production.psql
数据迁移方法二:转换mysql的数据,使用原有的pgsql的结构
- 导出mysql数据
# $mysqldump --compatible=postgresql --default-character-set=utf8 -uroot -p gitlabhq_production -r gitlabhq_production.mysql
# -t:不导出DDL,-c:导出完整的insert语句
$mysqldump -t -c --compatible=postgresql --default-character-set=utf8 -uroot -p gitlabhq_production -r mysql_gitlabhq_production_dataonly.mysql
- 导出pgsql的数据结构
$pg_dump -s -U postgres gitlabhq_production -f postgres_gitlabhq_production_ddlonly.dump
- 编写Python脚本,合并pgsql的备份脚本,
$python db_data_merge.py mysql_gitlabhq_production_dataonly.mysql postgres_gitlabhq_production_ddlonly.dump gitlabhq_production_merged.psql
- 删除pgsql9中的gitlabhq_production数据库,重新创建数据库
# 进入容器
$docker exec -it -u root postgresql_gitlab_9_6 bash
# 进入数据库,用postgres用户
$psql -U postgres postgres
# 数据库重做开始
$drop database gitlabhq_production;
$create database gitlabhq_production with owner=gitlab;
# 重新调整postgres和gitlab用户权限
$grant all privileges on database gitlabhq_production to gitlab;
$grant all privileges on database gitlabhq_production to postgres;
# schema授权给gitlab
# $grant all on SCHEMA public to gitlab;
- 备份恢复
# $psql -U gitlab -d gitlabhq_production -f gitlabhq_production.psql
$psql -U postgres -d gitlabhq_production -f gitlabhq_production_merged.psql
- 调整pgsql的gitlab用户权限
# $alter role gitlab with CREATEDB SUPERUSER;
# 查看role
$\du
- 重新启动pgsql 和 gitlab8的镜像
$docker restart postgresql_gitlab_9_6
$docker start gitlab8
- *回收pgsql的gitlab用户superuser权限
# $alter role gitlab with nosuperuser;
- 进入gitlab8,调整仓库文件夹权限
$docker exec -it -u root gitlab8 bash
$cd /home/git/data
$chown -R git:git ./
- 检查gitlab情况
# 重启容器检查gitlab前台是否正常
$docker restart gitlab8 && docker logs -f gitlab8
- 至此,数据库迁移完成
2. 再开始gitlab的升级
- 升级前准备工作
# 准备好gitlab的docker镜像升级包
$docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
sameersbn/gitlab 11.10.4 cbedd9a35d60 3 weeks ago 2.25GB
sameersbn/gitlab 10.8.4 74dba660e552 11 months ago 2.33GB
sameersbn/gitlab 9.5.5 30a23f8a69f1 20 months ago 1.69GB
sameersbn/gitlab 8.17.4 1575f2089d16 2 years ago 1.03GB
sameersbn/gitlab 8.14.1 605aa4c433d1 2 years ago 778MB
sameersbn/postgresql 10 27c74465cc2f 10 months ago 204MB
sameersbn/postgresql 9.6 af8f69984dd3 2 years ago 233MB
sameersbn/redis latest 105a23df8fb2 4 months ago 90.3MB
# (如果是save的镜像打包文件,则需要)读取镜像
$docker load -i gitlab_image_11.10.4.tar
# 准备逐级升级镜像(直接升级会报错)
$docker pull sameersbn/gitlab:8.17.4
$docker pull sameersbn/gitlab:9.5.5
$docker pull sameersbn/gitlab:10.8.4
$docker pull sameersbn/gitlab:11.10.4
开始准备升级
- 编写逐级升级的备份脚本
# docker 可选参数:
-v /etc/localtime:/etc/localtime:ro # 时间同步:ro(容器内只读)
# 编写8.14.1备份脚本
$vi start_gitlab_backup_8.14.1.sh
docker run --name gitlab8 -d --rm \
--link postgresql_gitlab_9_6:postgresql \
--link redis_gitlab:redisio \
-e 'UNICORN_WORKERS=15' \
-e 'GITLAB_SECRETS_DB_KEY_BASE=long-and-random-alpha-numeric-string' \
-e 'GITLAB_SECRETS_SECRET_KEY_BASE=long-and-random-alpha-numeric-string' \
-e 'GITLAB_SECRETS_OTP_KEY_BASE=long-and-random-alpha-numeric-string' \
-e 'SMTP_USER=xxx@xxx.com' \
-e 'SMTP_PASS=123456' \
-e 'SMTP_ENABLED=true' \
-e 'SMTP_DOMAIN=xxx.com' \
-e 'SMTP_HOST=xx.xx.xx.xx' \
-e 'NGINX_MAX_UPLOAD_SIZE=128m' \
-e 'SMTP_AUTHENTICATION=login' \
-e 'GITLAB_HOST=192.166.204.130' \
-e 'GITLAB_SSH_PORT=10022' \
-e 'GITLAB_PORT=10080' \
-v /srv/docker/gitlab/gitlab/data:/home/git/data \
-v /etc/localtime:/etc/localtime:ro \
-p 10022:22 \
-p 10080:80 \
-p 10443:443 \
sameersbn/gitlab:8.14.1 app:rake gitlab:backup:create
# 编写8.17.4备份脚本
$vi start_gitlab_backup_8.17.4.sh
docker run --name gitlab8 -d --rm \
--link postgresql_gitlab_9_6:postgresql \
--link redis_gitlab:redisio \
-e 'UNICORN_WORKERS=15' \
-e 'GITLAB_SECRETS_DB_KEY_BASE=long-and-random-alpha-numeric-string' \
-e 'GITLAB_SECRETS_SECRET_KEY_BASE=long-and-random-alpha-numeric-string' \
-e 'GITLAB_SECRETS_OTP_KEY_BASE=long-and-random-alpha-numeric-string' \
-e 'SMTP_USER=xxx@xxx.com' \
-e 'SMTP_PASS=123456' \
-e 'SMTP_ENABLED=true' \
-e 'SMTP_DOMAIN=xxx.com' \
-e 'SMTP_HOST=xx.xx.xx.xx' \
-e 'NGINX_MAX_UPLOAD_SIZE=128m' \
-e 'SMTP_AUTHENTICATION=login' \
-e 'GITLAB_HOST=192.166.204.130' \
-e 'GITLAB_SSH_PORT=10022' \
-e 'GITLAB_PORT=10080' \
-v /srv/docker/gitlab/gitlab/data:/home/git/data \
-v /etc/localtime:/etc/localtime:ro \
-p 10022:22 \
-p 10080:80 \
-p 10443:443 \
sameersbn/gitlab:8.17.4 app:rake gitlab:backup:create
# 编写9.5.5备份脚本
$vi start_gitlab_backup_9.5.5.sh
docker run --name gitlab9 -d --rm \
--link postgresql_gitlab_9_6:postgresql \
--link redis_gitlab:redisio \
-e 'UNICORN_WORKERS=15' \
-e 'GITLAB_SECRETS_DB_KEY_BASE=long-and-random-alpha-numeric-string' \
-e 'GITLAB_SECRETS_SECRET_KEY_BASE=long-and-random-alpha-numeric-string' \
-e 'GITLAB_SECRETS_OTP_KEY_BASE=long-and-random-alpha-numeric-string' \
-e 'SMTP_USER=xxx@xxx.com' \
-e 'SMTP_PASS=123456' \
-e 'SMTP_ENABLED=true' \
-e 'SMTP_DOMAIN=xxx.com' \
-e 'SMTP_HOST=xx.xx.xx.xx' \
-e 'NGINX_MAX_UPLOAD_SIZE=128m' \
-e 'SMTP_AUTHENTICATION=login' \
-e 'GITLAB_HOST=192.166.204.130' \
-e 'GITLAB_SSH_PORT=10022' \
-e 'GITLAB_PORT=10080' \
-v /srv/docker/gitlab/gitlab/data:/home/git/data \
-v /etc/localtime:/etc/localtime:ro \
-p 10022:22 \
-p 10080:80 \
-p 10443:443 \
sameersbn/gitlab:9.5.5 app:rake gitlab:backup:create
# 编写10.8.4备份脚本
$vi start_gitlab_backup_10.8.4.sh
docker run --name gitlab10 -d --rm \
--link postgresql_gitlab_9_6:postgresql \
--link redis_gitlab:redisio \
-e 'UNICORN_WORKERS=15' \
-e 'GITLAB_SECRETS_DB_KEY_BASE=long-and-random-alpha-numeric-string' \
-e 'GITLAB_SECRETS_SECRET_KEY_BASE=long-and-random-alpha-numeric-string' \
-e 'GITLAB_SECRETS_OTP_KEY_BASE=long-and-random-alpha-numeric-string' \
-e 'SMTP_USER=xxx@xxx.com' \
-e 'SMTP_PASS=123456' \
-e 'SMTP_ENABLED=true' \
-e 'SMTP_DOMAIN=xxx.com' \
-e 'SMTP_HOST=xx.xx.xx.xx' \
-e 'NGINX_MAX_UPLOAD_SIZE=128m' \
-e 'SMTP_AUTHENTICATION=login' \
-e 'GITLAB_HOST=192.166.204.130' \
-e 'GITLAB_SSH_PORT=10022' \
-e 'GITLAB_PORT=10080' \
-v /srv/docker/gitlab/gitlab/data:/home/git/data \
-v /etc/localtime:/etc/localtime:ro \
-p 10022:22 \
-p 10080:80 \
-p 10443:443 \
sameersbn/gitlab:10.8.4 app:rake gitlab:backup:create
- 编写逐级升级的启动脚本
# 编写8.17.4启动脚本
$vi start_gitlab_8.17.4.sh
docker run --name gitlab8 -d \
--link postgresql_gitlab_9_6:postgresql \
--link redis_gitlab:redisio \
-e 'UNICORN_WORKERS=15' \
-e 'GITLAB_SECRETS_DB_KEY_BASE=long-and-random-alpha-numeric-string' \
-e 'GITLAB_SECRETS_SECRET_KEY_BASE=long-and-random-alpha-numeric-string' \
-e 'GITLAB_SECRETS_OTP_KEY_BASE=long-and-random-alpha-numeric-string' \
-e 'SMTP_USER=xxx@xxx.com' \
-e 'SMTP_PASS=123456' \
-e 'SMTP_ENABLED=true' \
-e 'SMTP_DOMAIN=xxx.com' \
-e 'SMTP_HOST=xx.xx.xx.xx' \
-e 'NGINX_MAX_UPLOAD_SIZE=128m' \
-e 'SMTP_AUTHENTICATION=login' \
-e 'GITLAB_HOST=192.166.204.130' \
-e 'GITLAB_SSH_PORT=10022' \
-e 'GITLAB_PORT=10080' \
-v /srv/docker/gitlab/gitlab/data:/home/git/data \
-v /etc/localtime:/etc/localtime:ro \
-p 10022:22 \
-p 10080:80 \
-p 10443:443 \
sameersbn/gitlab:8.17.4
# 编写9.5.5启动脚本
$vi start_gitlab_9.5.5.sh
docker run --name gitlab9 -d \
--link postgresql_gitlab_9_6:postgresql \
--link redis_gitlab:redisio \
-e 'UNICORN_WORKERS=15' \
-e 'GITLAB_SECRETS_DB_KEY_BASE=long-and-random-alpha-numeric-string' \
-e 'GITLAB_SECRETS_SECRET_KEY_BASE=long-and-random-alpha-numeric-string' \
-e 'GITLAB_SECRETS_OTP_KEY_BASE=long-and-random-alpha-numeric-string' \
-e 'SMTP_USER=xxx@xxx.com' \
-e 'SMTP_PASS=123456' \
-e 'SMTP_ENABLED=true' \
-e 'SMTP_DOMAIN=xxx.com' \
-e 'SMTP_HOST=xx.xx.xx.xx' \
-e 'NGINX_MAX_UPLOAD_SIZE=128m' \
-e 'SMTP_AUTHENTICATION=login' \
-e 'GITLAB_HOST=192.166.204.130' \
-e 'GITLAB_SSH_PORT=10022' \
-e 'GITLAB_PORT=10080' \
-v /srv/docker/gitlab/gitlab/data:/home/git/data \
-v /etc/localtime:/etc/localtime:ro \
-p 10022:22 \
-p 10080:80 \
-p 10443:443 \
sameersbn/gitlab:9.5.5
# 编写10.8.4启动脚本
$vi start_gitlab_10.8.4.sh
docker run --name gitlab10 -d \
--link postgresql_gitlab_9_6:postgresql \
--link redis_gitlab:redisio \
-e 'UNICORN_WORKERS=15' \
-e 'GITLAB_SECRETS_DB_KEY_BASE=long-and-random-alpha-numeric-string' \
-e 'GITLAB_SECRETS_SECRET_KEY_BASE=long-and-random-alpha-numeric-string' \
-e 'GITLAB_SECRETS_OTP_KEY_BASE=long-and-random-alpha-numeric-string' \
-e 'SMTP_USER=xxx@xxx.com' \
-e 'SMTP_PASS=123456' \
-e 'SMTP_ENABLED=true' \
-e 'SMTP_DOMAIN=xxx.com' \
-e 'SMTP_HOST=xx.xx.xx.xx' \
-e 'NGINX_MAX_UPLOAD_SIZE=128m' \
-e 'SMTP_AUTHENTICATION=login' \
-e 'GITLAB_HOST=192.166.204.130' \
-e 'GITLAB_SSH_PORT=10022' \
-e 'GITLAB_PORT=10080' \
-v /srv/docker/gitlab/gitlab/data:/home/git/data \
-v /etc/localtime:/etc/localtime:ro \
-p 10022:22 \
-p 10080:80 \
-p 10443:443 \
sameersbn/gitlab:10.8.4
# 编写11.10.4启动脚本
$vi start_gitlab_11.10.4.sh
docker run --name gitlab11 -d \
--link postgresql_gitlab_9_6:postgresql \
--link redis_gitlab:redisio \
-e 'UNICORN_WORKERS=15' \
-e 'GITLAB_SECRETS_DB_KEY_BASE=long-and-random-alpha-numeric-string' \
-e 'GITLAB_SECRETS_SECRET_KEY_BASE=long-and-random-alpha-numeric-string' \
-e 'GITLAB_SECRETS_OTP_KEY_BASE=long-and-random-alpha-numeric-string' \
-e 'SMTP_USER=xxx@xxx.com' \
-e 'SMTP_PASS=123456' \
-e 'SMTP_ENABLED=true' \
-e 'SMTP_DOMAIN=xxx.com' \
-e 'SMTP_HOST=xx.xx.xx.xx' \
-e 'NGINX_MAX_UPLOAD_SIZE=128m' \
-e 'SMTP_AUTHENTICATION=login' \
-e 'GITLAB_HOST=192.166.204.130' \
-e 'GITLAB_SSH_PORT=10022' \
-e 'GITLAB_PORT=10080' \
-v /srv/docker/gitlab/gitlab/data:/home/git/data \
-v /etc/localtime:/etc/localtime:ro \
-p 10022:22 \
-p 10080:80 \
-p 10443:443 \
sameersbn/gitlab:11.10.4
- 调整执行权限,并准备脚本
$chmod 754 start_gitlab_*.sh
#启动脚本整理
$cd ~/sbin
$ln -s /root/start/gitlab/start_gitlab_10.8.4.sh
$ln -s /root/start/gitlab/start_gitlab_11.10.4.sh
$ln -s /root/start/gitlab/start_gitlab_8.14.1.sh
$ln -s /root/start/gitlab/start_gitlab_8.17.4.sh
$ln -s /root/start/gitlab/start_gitlab_9.5.5.sh
$ln -s /root/start/gitlab/start_gitlab_backup_10.8.4.sh
$ln -s /root/start/gitlab/start_gitlab_backup_8.14.1.sh
$ln -s /root/start/gitlab/start_gitlab_backup_8.17.4.sh
$ln -s /root/start/gitlab/start_gitlab_backup_9.5.5.sh
# 添加路径到path环境变量
$vi .bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin:$HOME/sbin
export PATH
# 准备恢复备份脚本随时修改
$vi start_gitlab_restore.sh
docker run --name gitlab9 -it --rm \
--link postgresql_gitlab_9_6:postgresql \
--link redis_gitlab:redisio \
-e 'UNICORN_WORKERS=15' \
-e 'GITLAB_SECRETS_DB_KEY_BASE=long-and-random-alpha-numeric-string' \
-e 'GITLAB_SECRETS_SECRET_KEY_BASE=long-and-random-alpha-numeric-string' \
-e 'GITLAB_SECRETS_OTP_KEY_BASE=long-and-random-alpha-numeric-string' \
-e 'SMTP_USER=xxx@xxx.com' \
-e 'SMTP_PASS=123456' \
-e 'SMTP_ENABLED=true' \
-e 'SMTP_DOMAIN=xxx.com' \
-e 'SMTP_HOST=xx.xx.xx.xx' \
-e 'NGINX_MAX_UPLOAD_SIZE=128m' \
-e 'SMTP_AUTHENTICATION=login' \
-e 'GITLAB_HOST=192.166.204.130' \
-e 'GITLAB_SSH_PORT=10022' \
-e 'GITLAB_PORT=10080' \
-v /srv/docker/gitlab/gitlab/data:/home/git/data \
-v /etc/localtime:/etc/localtime:ro \
-p 10022:22 \
-p 10080:80 \
-p 10443:443 \
sameersbn/gitlab:9.5.5 app:rake gitlab:backup:restore
-
开始进行升级(备份需注意磁盘空间)
-
升级8.17.4
# 移除正常的旧容器,防止重名
$docker stop gitlab8 && docker rm gitlab8
# 执行备份8.14.1
$start_gitlab_backup_8.14.1.sh && docker logs -f gitlab8
# 执行升级8.17.4
$start_gitlab_8.17.4.sh && docker logs -f gitlab8
# 检查gitlab
- 升级9.5.5
# 移除旧容器
$docker stop gitlab8 && docker rm gitlab8
# 执行备份8.17.4
$start_gitlab_backup_8.17.4.sh && docker logs -f gitlab8
# 执行升级9.5.5
$start_gitlab_9.5.5.sh && docker logs -f gitlab9
# 检查gitlab
- 升级10.8.4 数据迁移方案一升级失败:单独尝试升级到此步骤是成功的(应该是数据库迁移的问题,重新制定迁移数据库方案)
错误(数据迁移方案一):
# 移除旧容器
$docker stop gitlab9 && docker rm gitlab9
# 执行备份9.5.5
$start_gitlab_backup_9.5.5.sh && docker logs -f gitlab9
# 执行升级10.8.4
$start_gitlab_10.8.4.sh && docker logs -f gitlab10
# 检查gitlab
XXX 启动失败
重新制定数据库迁移方案(方案二):升级需要先重启postgresql
# 移除旧容器
$docker stop gitlab9 && docker rm gitlab9
# 执行备份9.5.5
$start_gitlab_backup_9.5.5.sh && docker logs -f gitlab9
# 执行升级10.8.4
$start_gitlab_10.8.4.sh && docker logs -f gitlab10
# 检查gitlab
- 升级11.10.4
# 移除旧容器
$docker stop gitlab10 && docker rm gitlab10
# 执行备份10.8.4
$start_gitlab_backup_10.8.4.sh && docker logs -f gitlab10
# 其中如果备份异常(10.8.4backup error) start_gitlab_backup_10.8.4.sh 更换为:
$start_gitlab_10.8.4.sh
$docker exec -it -u root gitlab10 bash
$su - git
$cd /home/git/gitlab
$bundle exec rake gitlab:backup:create RAILS_ENV=production
# 移除旧容器
$docker stop gitlab10 && docker rm gitlab10
# 执行升级11.10.4
$start_gitlab_11.10.4.sh && docker logs -f gitlab11
# 检查gitlab
异常报错
$ start_gitlab_backup_10.8.4.sh && docker logs -f gitlab10
fcc0a1e82e34c3748a5d0c0ed27abc07045bc8cb6c30d50a41fb71988a54f8b3
Loading /etc/docker-gitlab/runtime/env-defaults
Initializing logdir...
Initializing datadir...
Installing configuration templates...
Configuring gitlab...
Configuring gitlab::database
Configuring gitlab::redis
Configuring gitlab::secrets...
Configuring gitlab::sidekiq...
Configuring gitlab::gitaly...
Configuring gitlab::monitoring...
Configuring gitlab::gitlab-workhorse...
Configuring gitlab::unicorn...
Configuring gitlab::timezone...
Configuring gitlab::rack_attack...
Configuring gitlab::ci...
Configuring gitlab::artifacts...
Configuring gitlab::lfs...
Configuring gitlab::uploads...
Configuring gitlab::mattermost...
Configuring gitlab::project_features...
Configuring gitlab::smtp_settings...
Configuring gitlab::oauth...
Configuring gitlab::ldap...
Configuring gitlab::cron_jobs...
Configuring gitlab::backups...
Configuring gitlab::registry...
Configuring gitlab::pages...
Configuring gitlab-shell...
Configuring nginx...
Configuring nginx::gitlab...
Running raketask gitlab:backup:create...
Missing Rails.application.secrets.openid_connect_signing_key for production environment. The secret will be generated and stored in config/secrets.yml.
Dumping database ...
rake aborted!
Gitlab::Git::CommandError: 14:Connect Failed
/home/git/gitlab/lib/gitlab/git/repository.rb:1454:in `rescue in gitaly_migrate'
/home/git/gitlab/lib/gitlab/git/repository.rb:1447:in `gitaly_migrate'
/home/git/gitlab/lib/gitlab/git/repository.rb:1606:in `uncached_has_local_branches?'
/home/git/gitlab/lib/gitlab/git/repository.rb:237:in `block in has_local_branches?'
/home/git/gitlab/lib/gitlab/utils/strong_memoize.rb:26:in `strong_memoize'
/home/git/gitlab/lib/gitlab/git/repository.rb:236:in `has_local_branches?'
/home/git/gitlab/app/models/repository.rb:517:in `has_visible_content?'
/home/git/gitlab/lib/gitlab/repository_cache_adapter.rb:17:in `block (2 levels) in cache_method'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.10/lib/active_support/cache.rb:299:in `block in fetch'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.10/lib/active_support/cache.rb:585:in `block in save_block_result_to_cache'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.10/lib/active_support/cache.rb:547:in `block in instrument'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.10/lib/active_support/notifications.rb:166:in `instrument'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.10/lib/active_support/cache.rb:547:in `instrument'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.10/lib/active_support/cache.rb:584:in `save_block_result_to_cache'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.10/lib/active_support/cache.rb:299:in `fetch'
/home/git/gitlab/lib/gitlab/repository_cache.rb:22:in `fetch'
/home/git/gitlab/lib/gitlab/repository_cache_adapter.rb:54:in `cache_method_output'
/home/git/gitlab/lib/gitlab/repository_cache_adapter.rb:16:in `block in cache_method'
/home/git/gitlab/app/models/repository.rb:491:in `empty?'
/home/git/gitlab/app/models/repository.rb:336:in `expire_emptiness_caches'
/home/git/gitlab/lib/backup/repository.rb:212:in `empty_repo?'
/home/git/gitlab/lib/backup/repository.rb:24:in `block in dump'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.10/lib/active_record/relation/batches.rb:51:in `block (2 levels) in find_each'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.10/lib/active_record/relation/batches.rb:51:in `each'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.10/lib/active_record/relation/batches.rb:51:in `block in find_each'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.10/lib/active_record/relation/batches.rb:124:in `find_in_batches'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.10/lib/active_record/relation/batches.rb:50:in `find_each'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.10/lib/active_record/querying.rb:9:in `find_each'
/home/git/gitlab/lib/backup/repository.rb:12:in `dump'
/home/git/gitlab/lib/tasks/gitlab/backup.rake:82:in `block (4 levels) in <top (required)>'
/home/git/gitlab/lib/tasks/gitlab/backup.rake:12:in `block (3 levels) in <top (required)>'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/rake-12.3.1/exe/rake:27:in `<top (required)>'
Caused by:
GRPC::Unavailable: 14:Connect Failed
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/grpc-1.11.0-x86_64-linux/src/ruby/lib/grpc/generic/active_call.rb:31:in `check_status'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/grpc-1.11.0-x86_64-linux/src/ruby/lib/grpc/generic/active_call.rb:180:in `attach_status_results_and_complete_call'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/grpc-1.11.0-x86_64-linux/src/ruby/lib/grpc/generic/active_call.rb:372:in `request_response'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/grpc-1.11.0-x86_64-linux/src/ruby/lib/grpc/generic/client_stub.rb:178:in `block in request_response'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/grpc-1.11.0-x86_64-linux/src/ruby/lib/grpc/generic/interceptors.rb:170:in `intercept!'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/grpc-1.11.0-x86_64-linux/src/ruby/lib/grpc/generic/client_stub.rb:177:in `request_response'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/grpc-1.11.0-x86_64-linux/src/ruby/lib/grpc/generic/service.rb:170:in `block (3 levels) in rpc_stub_class'
/home/git/gitlab/lib/gitlab/gitaly_client.rb:134:in `call'
/home/git/gitlab/lib/gitlab/gitaly_client/repository_service.rb:88:in `has_local_branches?'
/home/git/gitlab/lib/gitlab/git/repository.rb:1608:in `block in uncached_has_local_branches?'
/home/git/gitlab/lib/gitlab/gitaly_client.rb:268:in `block (2 levels) in migrate'
/home/git/gitlab/lib/gitlab/gitaly_client.rb:308:in `allow_n_plus_1_calls'
/home/git/gitlab/lib/gitlab/gitaly_client.rb:261:in `block in migrate'
/home/git/gitlab/lib/gitlab/metrics/influx_db.rb:98:in `measure'
/home/git/gitlab/lib/gitlab/gitaly_client.rb:259:in `migrate'
/home/git/gitlab/lib/gitlab/git/repository.rb:1448:in `gitaly_migrate'
/home/git/gitlab/lib/gitlab/git/repository.rb:1606:in `uncached_has_local_branches?'
/home/git/gitlab/lib/gitlab/git/repository.rb:237:in `block in has_local_branches?'
/home/git/gitlab/lib/gitlab/utils/strong_memoize.rb:26:in `strong_memoize'
/home/git/gitlab/lib/gitlab/git/repository.rb:236:in `has_local_branches?'
/home/git/gitlab/app/models/repository.rb:517:in `has_visible_content?'
/home/git/gitlab/lib/gitlab/repository_cache_adapter.rb:17:in `block (2 levels) in cache_method'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.10/lib/active_support/cache.rb:299:in `block in fetch'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.10/lib/active_support/cache.rb:585:in `block in save_block_result_to_cache'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.10/lib/active_support/cache.rb:547:in `block in instrument'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.10/lib/active_support/notifications.rb:166:in `instrument'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.10/lib/active_support/cache.rb:547:in `instrument'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.10/lib/active_support/cache.rb:584:in `save_block_result_to_cache'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.10/lib/active_support/cache.rb:299:in `fetch'
/home/git/gitlab/lib/gitlab/repository_cache.rb:22:in `fetch'
/home/git/gitlab/lib/gitlab/repository_cache_adapter.rb:54:in `cache_method_output'
/home/git/gitlab/lib/gitlab/repository_cache_adapter.rb:16:in `block in cache_method'
/home/git/gitlab/app/models/repository.rb:491:in `empty?'
/home/git/gitlab/app/models/repository.rb:336:in `expire_emptiness_caches'
/home/git/gitlab/lib/backup/repository.rb:212:in `empty_repo?'
/home/git/gitlab/lib/backup/repository.rb:24:in `block in dump'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.10/lib/active_record/relation/batches.rb:51:in `block (2 levels) in find_each'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.10/lib/active_record/relation/batches.rb:51:in `each'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.10/lib/active_record/relation/batches.rb:51:in `block in find_each'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.10/lib/active_record/relation/batches.rb:124:in `find_in_batches'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.10/lib/active_record/relation/batches.rb:50:in `find_each'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/activerecord-4.2.10/lib/active_record/querying.rb:9:in `find_each'
/home/git/gitlab/lib/backup/repository.rb:12:in `dump'
/home/git/gitlab/lib/tasks/gitlab/backup.rake:82:in `block (4 levels) in <top (required)>'
/home/git/gitlab/lib/tasks/gitlab/backup.rake:12:in `block (3 levels) in <top (required)>'
/home/git/gitlab/vendor/bundle/ruby/2.3.0/gems/rake-12.3.1/exe/rake:27:in `<top (required)>'
Tasks: TOP => gitlab:backup:repo:create
(See full trace by running task with --trace)
Dumping PostgreSQL database gitlabhq_production ... [DONE]
done
Dumping repositories ...