封尘网

让学习成为一种习惯!

重装新版gitlab时遇到gitlab-rails database初始化失败

gitlab使用了很久了,一直没有什么升级,自己测试环境的版本一直是8.8.5版,由于功能满足了就没有更新。本次因为测试需要,所以更换了一个比较新的版本。

环境说明
Centos7: 3.10.0-327.el7.x86_64
gitlab版本:原来是8.8.5版本

问题发生的原因:在同一台Centos7机器上卸载了旧版本的gitlab后,接着又重新安装新版本的gitlab-ce 在安装完后修改配置,初始化配置时出现以下错误:

Running handlers:
There was an error running gitlab-ctl reconfigure:

bash[migrate gitlab-rails database] (gitlab::database_migrations line 49) had an error: Mixlib::ShellOut::ShellCommandFailed: Expected process to exit with [0], but received '1'
---- Begin output of "bash"  "/tmp/chef-script20190628-7065-vx17en" ----
STDOUT: rake aborted!
PG::ConnectionBad: could not connect to server: No such file or directory
    Is the server running locally and accepting
    connections on Unix domain socket "/var/opt/gitlab/postgresql/.s.PGSQL.5432"?
/opt/gitlab/embedded/service/gitlab-rails/lib/tasks/gitlab/db.rake:49:in `block (3 levels) in <top (required)>'
/opt/gitlab/embedded/bin/bundle:23:in `load'
/opt/gitlab/embedded/bin/bundle:23:in `<main>'
Tasks: TOP => gitlab:db:configure
(See full trace by running task with --trace)
STDERR:
---- End output of "bash"  "/tmp/chef-script20190628-7065-vx17en" ----
Ran "bash"  "/tmp/chef-script20190628-7065-vx17en" returned 1

因为在卸载旧版本的时候没有把旧的数据删除,所以直接安装时,程序检测到配置文件,数据文件时就会跳过没有覆盖,新版本使用旧版本的数据文件[因为版本相差太多了]就会无法识别导致。

解决方法

卸载完旧版本后,记得删除旧的安装数据[配置文件,安装目录,数据目录等]

[root@rhel7 opt]# rm -rf /var/opt/gitlab/
[root@rhel7 opt]# rm -rf /opt/gitlab/
[root@rhel7 opt]# rm -rf /etc/gitlab/

删除上面几个旧的目录后,重新安装新版的gitlab-ce即可正常启动。

提醒:本文最后更新于 1549 天前,文中所描述的信息可能已发生改变,请谨慎使用。