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: 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
如需了解所有细节,请参见:
gitlab-rake
命令期间创建数据库并成为超级用户。您可能需要在远程服务器上安装postgresql-contrib
。 - Kurt