Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postgresql - No PostgreSQL clusters exist; see "man pg_createcluster" during service restart

I'm trying to stop a Postgresql 9.3 database that is already running on an Ubuntu server but I receive the following message :

root@myprodserver:~# sudo /etc/init.d/postgresql stop

 * No PostgreSQL clusters exist; see "man pg_createcluster"

If I try to list the clusters I get an empty result :

root@myprodserver:~# pg_lsclusters
Ver Cluster Port Status Owner Data directory Log file

I've tried to run a createcluster :

root@myprodserver:~# pg_createcluster 9.3 main

Configuring already existing cluster (configuration: /etc/postgresql/9.3/main, data: /var/lib/postgresql/9.3/main, owner: 106:114)
Error: move_conffile: required configuration file /var/lib/postgresql/9.3/main/postgresql.conf does not exist

The database is up and running. The response shows that a cluster exists. I've restarted many times the service in the past without error messages.

Here follows the result of sudo ps aux | grep postgres :

root       673  0.0  0.0  11748  2232 pts/5    R+   15:57   0:00 grep --color=auto postgres

postgres  1044  0.0  0.2 293560 17868 ?        S     2017  87:45 /usr/lib/postgresql/9.3/bin/postgres -D /var/lib/postgresql/9.3/main -c config_file=/etc/postgresql/9.3/main/postgresql.conf
postgres  1288  0.2  1.7 294156 142248 ?       Ss    2017 657:18 postgres: checkpointer process
postgres  1289  0.2  1.7 293700 140836 ?       Ss    2017 694:24 postgres: writer process
postgres  1290  0.0  0.0 293560  7476 ?        Ss    2017 140:10 postgres: wal writer process
postgres  1291  0.0  1.3 294508 107148 ?       Ss    2017  55:46 postgres: autovacuum launcher process
postgres  1292  0.0  0.0 105220  3772 ?        Ss    2017 172:17 postgres: stats collector process
postgres  7669  0.0  0.2 296244 17700 ?        Ss   12:04   0:02 postgres: adempiere postgres ::1(49525) idle
postgres  7671  0.0  0.6 298716 54004 ?        Ss   12:04   0:00 postgres: adempiere adempiere_produzione ::1(49526) idle
postgres  7855  0.0  0.4 295844 38160 ?        Ss   12:04   0:00 postgres: adempiere adempiere_produzione ::1(49527) idle
postgres  8068  0.0  0.2 294884 18324 ?        Ss   12:06   0:00 postgres: adempiere adempiere_produzione ::1(49528) idle
postgres 10115  0.0  1.9 308236 159916 ?       Ss   14:25   0:05 postgres: adempiere adempiere_produzione 192.107.YY.XXX(55631) idle
(continues)
like image 779
AlexZ Avatar asked Jan 31 '18 23:01

AlexZ


1 Answers

After the shutdown of the server PG was unable to start, the cluster (the instance of the database) was missing.

At the end I've been able to recover it. I had to correct something (see below) then I've executed :

sudo pg_createcluster 9.3 main

Then you should start it

sudo /etc/init.d/postgresql start

The system replied with : Configuring already existing cluster ....

Things to do in those cases : - check that all the configuration files and data files are in the correct folders - check that the files postmaster.opts are pointing to the correct locations

If the primary cluster (usually 'main') is still not starting you can create a new cluster with :

pg_createcluster 9.3 cluster2

Then restore the database backup to the new cluster.

Commands to control PG clusters :

list clusters

pg_lsclusters 

start/stop a cluster

pg_ctlcluster <pg version> <cluster name> <start|stop>
pg_ctlcluster 9.3 main start 
pg_ctlcluster 9.3 clust2 stop 

stop a cluster - drop active connections

pg_ctlcluster -m fast 9.3 clust2 stop 
like image 53
AlexZ Avatar answered Sep 24 '22 03:09

AlexZ