首页 > 解决方案 > 无法将 gitlab 中的 postgresql 从 9.2 升级到 9.6

问题描述

我已将 gitlab 版本从 9 升级到最新版本,但出现故障并恢复更改以便运行。解决了大部分问题,但坚持这一点,下面给出了sudo gitlab-ctl tail的日志

    ==> /var/log/gitlab/unicorn/current <==
    2021-03-01_11:45:09.17544 failed to start a new unicorn master
    2021-03-01_11:45:09.18657 starting new unicorn master
    
    ==> /var/log/gitlab/postgresql/current <==
    2021-03-01_11:45:09.61584 FATAL:  database files are incompatible with server
    2021-03-01_11:45:09.61587 DETAIL:  The database cluster was initialized with PG_CONTROL_VERSION 960, but the server was compiled with PG_CONTROL_VERSION 922.
    2021-03-01_11:45:09.61587 HINT:  It looks like you need to initdb.
    
    ==> /var/log/gitlab/unicorn/unicorn_stderr.log <==
    I, [2021-03-01T11:45:09.808436 #16902]  INFO -- : Refreshing Gem list
    
    ==> /var/log/gitlab/postgresql/current <==
    2021-03-01_11:45:10.73457 FATAL:  database files are incompatible with server
    2021-03-01_11:45:10.73460 DETAIL:  The database cluster was initialized with PG_CONTROL_VERSION 960, but the server was compiled with PG_CONTROL_VERSION 922.
    2021-03-01_11:45:10.73460 HINT:  It looks like you need to initdb.
    2021-03-01_11:45:11.84962 FATAL:  database files are incompatible with server
    2021-03-01_11:45:11.84964 DETAIL:  The database cluster was initialized with PG_CONTROL_VERSION 960, but the server was compiled with PG_CONTROL_VERSION 922.
    2021-03-01_11:45:11.84964 HINT:  It looks like you need to initdb.
    2021-03-01_11:45:12.96683 FATAL:  database files are incompatible with server
    2021-03-01_11:45:12.96686 DETAIL:  The database cluster was initialized with PG_CONTROL_VERSION 960, but the server was compiled with PG_CONTROL_VERSION 922.
    2021-03-01_11:45:12.96687 HINT:  It looks like you need to initdb.


==> /var/log/gitlab/postgresql/current <==
2021-03-01_11:45:14.04158 FATAL:  database files are incompatible with server
2021-03-01_11:45:14.04160 DETAIL:  The database cluster was initialized with PG_CONTROL_VERSION 960, but the server was compiled with PG_CONTROL_VERSION 922.
2021-03-01_11:45:14.04161 HINT:  It looks like you need to initdb.
2021-03-01_11:45:15.17195 FATAL:  database files are incompatible with server
2021-03-01_11:45:15.17197 DETAIL:  The database cluster was initialized with PG_CONTROL_VERSION 960, but the server was compiled with PG_CONTROL_VERSION 922.
2021-03-01_11:45:15.17197 HINT:  It looks like you need to initdb.
2021-03-01_11:45:16.29761 FATAL:  database files are incompatible with server
2021-03-01_11:45:16.29762 DETAIL:  The database cluster was initialized with PG_CONTROL_VERSION 960, but the server was compiled with PG_CONTROL_VERSION 922.
2021-03-01_11:45:16.29763 HINT:  It looks like you need to initdb.
2021-03-01_11:45:17.42083 FATAL:  database files are incompatible with server
2021-03-01_11:45:17.42086 DETAIL:  The database cluster was initialized with PG_CONTROL_VERSION 960, but the server was compiled with PG_CONTROL_VERSION 922.
2021-03-01_11:45:17.42086 HINT:  It looks like you need to initdb.
2021-03-01_11:45:18.50755 FATAL:  database files are incompatible with server
2021-03-01_11:45:18.50757 DETAIL:  The database cluster was initialized with PG_CONTROL_VERSION 960, but the server was compiled with PG_CONTROL_VERSION 922.
2021-03-01_11:45:18.50757 HINT:  It looks like you need to initdb.
2021-03-01_11:45:19.63453 FATAL:  database files are incompatible with server
2021-03-01_11:45:19.63455 DETAIL:  The database cluster was initialized with PG_CONTROL_VERSION 960, but the server was compiled with PG_CONTROL_VERSION 922.
2021-03-01_11:45:19.63455 HINT:  It looks like you need to initdb.
2021-03-01_11:45:20.75152 FATAL:  database files are incompatible with server
2021-03-01_11:45:20.75154 DETAIL:  The database cluster was initialized with PG_CONTROL_VERSION 960, but the server was compiled with PG_CONTROL_VERSION 922.
2021-03-01_11:45:20.75154 HINT:  It looks like you need to initdb.
2021-03-01_11:45:21.85148 FATAL:  database files are incompatible with server
2021-03-01_11:45:21.85150 DETAIL:  The database cluster was initialized with PG_CONTROL_VERSION 960, but the server was compiled with PG_CONTROL_VERSION 922.
2021-03-01_11:45:21.85151 HINT:  It looks like you need to initdb.
2021-03-01_11:45:22.93649 FATAL:  database files are incompatible with server
2021-03-01_11:45:22.93651 DETAIL:  The database cluster was initialized with PG_CONTROL_VERSION 960, but the server was compiled with PG_CONTROL_VERSION 922.

sudo gitlab-ctl pg-upgrade给出

Checking for an omnibus managed postgresql: OK
Checking if we already upgraded: NOT OK
Checking for a newer version of PostgreSQL to install: OK
Upgrading PostgreSQL to 9.6.1
Checking if PostgreSQL bin files are symlinked to the expected location: OK
Toggling deploy page:/opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/omnibus-ctl-0.3.6/lib/omnibus-ctl.rb:533: warning: Insecure world writable dir /opt/gitlab/bin in PATH, mode 040777
cp /opt/gitlab/embedded/service/gitlab-rails/public/deploy.html /opt/gitlab/embedded/service/gitlab-rails/public/index.html
Toggling deploy page: OK
Toggling services:ok: down: gitaly: 1s, normally up
ok: down: logrotate: 0s, normally up
ok: down: sidekiq: 1s, normally up
Toggling services: OK
Waiting 30 seconds to ensure tasks complete before PostgreSQL upgrade
Please hit Ctrl-C now if you want to cancel the upgrade
..............................There wasn an error fetching locale and encoding information from the database
Please ensure the database is running and functional before running pg-upgrade
STDOUT: 
STDERR: psql: 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"?
Stopping the database:ok: down: postgresql: 1s, normally up, want up
Stopping the database: OK
Update the symlinks: OK
Creating temporary data directory: OK
Initializing the new database:Error initializing database for 9.6.1
STDOUT: The files belonging to this database system will be owned by user "gitlab-psql".
This user must also own the server process.

STDERR: initdb: invalid locale name "--encoding"
== Fatal error ==
Please check the output and try again
== Reverting ==
ok: down: postgresql: 2s, normally up
ok: run: postgresql: (pid 17920) 0s
== Reverted ==
== Reverted to 9.2.18. Please check output for what went wrong ==
Toggling deploy page:/opt/gitlab/embedded/lib/ruby/gems/2.3.0/gems/omnibus-ctl-0.3.6/lib/omnibus-ctl.rb:533: warning: Insecure world writable dir /opt/gitlab/bin in PATH, mode 040777
rm -f /opt/gitlab/embedded/service/gitlab-rails/public/index.html
Toggling deploy page: OK
Toggling services:ok: run: gitaly: (pid 17925) 0s
ok: run: logrotate: (pid 17930) 1s
ok: run: sidekiq: (pid 17937) 0s
Toggling services: OK

当前活动的postgresql版本是9.2.18,需要升级到9.6.1才能初始化数据库,请帮忙。提前致谢

标签: postgresqlgitlabgitlab-cipostgresql-9.2sysadmin

解决方案


推荐阅读