My locale settings were not properly configured when PostgreSQL was installed. Purging and reinstalling didn't help. I followed the instructions here and that did the trick for me.
Essential parts of the linked information reproduced below:
The problem showed itself in the following manner:
warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
...
are supported and installed on your system.
The first one was very easy to solve by executing:
#dpkg-reconfigure locales
...and choosing the preferred locales.
But after that PostgreSQL still refused to start. This is due to the fact that the installation process tried to create a cluster at installation time but because of the bad locales this wasn't done. So we have to redo this step by executing:
#pg_createcluster 9.3 main --start
(For the 9.3 version of PostgreSQL)
After that step PostgreSQL starts flawlessly via
#/etc/init.d/postgresql start
how is it possible for the Slave to have more pg_xlog/ log files than the Master?
The whole point of archiving WAL on the master to some external location is to let the master then delete it to free space in its pg_xlog
, while replicas might still need it.
A replica can have more archives in pg_xlog
than the master, and older ones, if it's lagging behind the master due to failure to keep up with replay. However, with pg_standby
that shouldn't happen - the archive might contain more xlogs, but the replica should only be reading them on-demand.
It's hard to be specific, because you've given a broad description of the issue rather than actual directory listings, and haven't explained the exact steps you followed to set up the replica. Or shown the exact log file output from the replica. So the best I can do is "it sounds like the replica setup is broken somehw".
to resync the servers in warm standby mode: do I have to do pg_basebackup again (to essentially copy Master's /data
and /pg_xlog
directory) to the Slave?
Assuming that here /data
is the main datadir, containing global
, base
, pg_clog
, etc, and that pg_xlog
is the transaction logs from a different disk: Yes, that's right.
You must use the pg_basebackup
command, though, or follow the instructions in the manual for correct file system level copies using pg_start_backup()
and rsync/cp.
You also have to make sure you've stopped the replica first. Overwriting its datadir while it's running will make it quite upset.
Streaming replication vs warm standby
Hot vs warm standby is orthogonal to streaming vs log shipping replication.
What you're trying to do is use log shipping instead of streaming replication. It doesn't matter for this purpose if the replica is a hot standby or a warm standby, i.e. whether or not it's accepting queries.
Personally I recommend using both methods - use streaming, and fall back to log shipping if there's a problem with streaming. PostgreSQL does this automatically if both are configured.
Best Answer
pg_conftool
Debian and Ubuntu provide their own utilities. To get this information, use
pg_conftool
. Here is what it looks like,For reference,
pg_lsclusters
If you're running multiple versions of PostgreSQL on the same machine, you may find
pg_lsclusters
useful. It will show you all of the versions running.You can parse that pretty easy, here we use
awk
to get out theVer
andData directory
,If you have JSON.pm installed you can use
pg_lsclusters -j
to output JSON,