Pierre 的解决方案适用于新安装,但如果数据库中已有数据,则需要进行迁移。最干净、最安全的方法是创建一个备份,其中也包含数据库:
gitlab-rake gitlab:backup:create
备份文件将位于/var/opt/gitlab/backups。
或者,您可以尝试:
sudo -u gitlab-psql /opt/gitlab/embedded/bin/pg_dumpall --username=gitlab-psql --host=/var/opt/gitlab/postgresql
然后您可以将数据库导入现有的 Postgres 实例:
psql -f /tmp/database.sql
那么你也需要重新配置和重启:
gitlab-ctl start && gitlab-ctl reconfigure && gitlab-ctl restart
它以start 开头,因为您需要确保 GitLab 正在运行。这是因为,无论听起来多么奇怪,如果 GitLab 停止,reconfigure 就会失败:
Errno::ENOENT: No such file or directory - connect(2) for /var/opt/gitlab/redis/redis.socket
这有点违反直觉,因为传统上您会在实例停止时更改配置。
但是无论是迁移还是全新安装,第一次 GitLab 升级都会出现问题:
gitlab preinstall: Automatically backing up only the GitLab SQL database (excluding everything else!)
Dumping database ...
Dumping PostgreSQL database gitlabhq_production ... pg_dump: server version: 10.4; pg_dump version: 9.6.8
pg_dump: aborting because of server version mismatch
Backup failed
[FAILED]
按照它的指示,你必须:
sudo touch /etc/gitlab/skip-auto-migrations
所以现在这个包更新成功了,但是 GitLab 还是不行,你得重来一遍:
gitlab-ctl reconfigure
自动执行此操作:
yum install yum-plugin-post-transaction-actions
echo 'gitlab-ce:any:/bin/gitlab-ctl reconfigure' > /etc/yum/post-actions/gitlab-ce.action
有关所有细节,请参阅: