Solve the problem of PostgreSQL 10 to 11, Permissions should be u=rwx (0700)
#Problem description
Today I plan to upgrade Gitlab from version 11 to version 12. I have tried the default steps many times without success.
I was really unwilling to give it up. After searching for a long time, I finally found an error in the PostgreSQL log.
The key two lines of log are as follows:
Search questions
Use Google to search “data directory has group or world access”
The first result is the solution, Postgres exits with “Permissions should be u=rwx (0700)” #45
command: "/usr/lib/postgresql/10/bin/pg_ctl" -w -l "pg_upgrade_server.log" -D "/var/lib/postgresql/10/main" -o "-p 50432 -c autovacuum=off -c autovacuum_freeze_max_age=2000000000 -c config_file=/var/lib/postgresql/10/main/postgresql.conf --hba_file=/var/lib/postgresql/10/main/pg_hba.conf --ident_file=/var/lib/postgresql/10/main/pg_ident.conf -c listen_addresses='' -c unix_socket_permissions=0700" start >> "pg_upgrade_server.log" 2>&1
pg_ctl: another server might be running; trying to start server anyway
waiting for server to start....2021-08-23 07:11:37.208 UTC [1385] FATAL: data directory "/var/lib/postgresql/10/main" has group or world access
2021-08-23 07:11:37.208 UTC [1385] DETAIL: Permissions should be u=rwx (0700).
stopped waiting
pg_ctl: could not start server
Examine the log output.
2021-08-23 07:11:37.208 UTC [1385] FATAL: data directory "/var/lib/postgresql/10/main" has group or world access
2021-08-23 07:11:37.208 UTC [1385] DETAIL: Permissions should be u=rwx (0700).
stopped waiting
Solve the problem
- Use the
rootaccount to execute the commandsudo chmod 700 -R /var/lib/postgresql/data - Re-execute the upgrade command of
pg_ctl
refer to
"/usr/lib/postgresql/10/bin/pg_ctl" -w -l "pg_upgrade_server.log" -D "/var/lib/postgresql/10/main" -o "-p 50432 -c autovacuum=off -c autovacuum_freeze_max_age=2000000000 -c config_file=/var/lib/postgresql/10/main/postgresql.conf --hba_file=/var/lib/postgresql/10/main/pg_hba.conf --ident_file=/var/lib/postgresql/10/main/pg_ident.conf -c listen_addresses='' -c unix_socket_permissions=0700" start >> "pg_upgrade_server.log" 2>&1