'Use of uninitialized value $data_directory
Postgresql server doesn't start , I installed postgresql 9.6 [ubuntu 18.04.2 LTS]
systemctl status [email protected]
[email protected][16944]: Use of uninitialized value $data_directory in concatenation (.) or string at /usr/share/perl5/PgCommon.pm line 215.
[email protected][16944]: Error: Invalid data directory for cluster 9.6 main
How can I fix it?
update 1 :
pg_lsclusters
Ver Cluster Port Status Owner Data directory Log file
9.6 main 5432 down postgres /var/lib/postgresql/9.6/main /var/log/postgresql/postgresql-9.6-main.log
sudo pg_ctlcluster 9.6 main start
Job for [email protected] failed because the service did not take the steps required by its unit configuration.
See "systemctl status [email protected]" and "journalctl -xe" for details.
systemctl status [email protected]
Process: 7658 ExecStart=/usr/bin/pg_ctlcluster --skip-systemctl-redirect 9.6-main start (code=exited, status=1/FAILURE)
Apr 09 14:35:25 ubuntu207 systemd[1]: Starting PostgreSQL Cluster 9.6-main...
Apr 09 14:35:25 ubuntu207 [email protected][7658]: Use of uninitialized value $data_directory in concatenation (.) or string at /usr/share/perl5/PgCommon.pm line 215.
Apr 09 14:35:25 ubuntu207 [email protected][7658]: Use of uninitialized value $data_directory in concatenation (.) or string at /usr/share/perl5/PgCommon.pm line 215.
Apr 09 14:35:25 ubuntu207 [email protected][7658]: Error: Invalid data directory for cluster 9.6 main
Apr 09 14:35:25 ubuntu207 systemd[1]: [email protected]: Can't open PID file /run/postgresql/9.6-main.pid (yet?) after start: No such file or directory
Apr 09 14:35:25 ubuntu207 systemd[1]: [email protected]: Failed with result 'protocol'.
Apr 09 14:35:25 ubuntu207 systemd[1]: Failed to start PostgreSQL Cluster 9.6-main.
update 2 :
my postgresql.conf
data_directory = '/var/lib/postgresql/9.6/main' # use data in another directory
# (change requires restart)
hba_file = '/etc/postgresql/9.6/main/pg_hba.conf' # host-based authentication file
# (change requires restart)
ident_file = '/etc/postgresql/9.6/main/pg_ident.conf' # ident configuration file
# (change requires restart)
# If external_pid_file is not explicitly set, no extra PID file is written.
external_pid_file = '/var/run/postgresql/9.6-main.pid' # write an extra PID file
# (change requires restart)
~# sudo -u postgres psql
could not change directory to "/root": Permission denied
psql: error: could not connect to server: No such file or directory
Is the server running locally and accepting
connections on Unix domain socket "/var/run/postgresql/.s.PGSQL.5432"?
Solution 1:[1]
I have fixed it, it's a problem with the $data_directory permission:
sudo chmod -R u=rwx '/var/lib/postgresql/9.6/main/'
sudo chmod -R 0700 '/etc/postgresql/9.6/main'
pg_ctlcluster --foreground 9.6 main start
And the result pg_ctlcluster is :
Ver Cluster Port Status Owner Data directory Log file
9.6 main 5432 online postgres /var/lib/postgresql/9.6/main /var/log/postgresql/postgresql-9.6-main.log
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Moritz |
