You seem to be trying to replicate from one server to another that wasn't set up using a copy of the original server. That's why:
database system identifier differs between the primary and standby. The primary's identifier is 6022019027749040119, the standby's identifier is 6033562405193904122.
Because each newly initdb
'd PostgreSQL gets a new random system identifier. When you copy an existing PostgreSQL install, it keeps the same system identifier. That's how PostgreSQL can keep track of whether one server can replay WAL from another.
You can only use physical replication if the replica is a copy (file-system level backup e.g. pg_basebackup
) of the master. See the manual's detailed coverage on replication for more information.
Update:
The instructions shown above should be fine, but they're not as clear as they could be.
The standby server's data directory is supposed to be replaced by the base backup you create at step 8, if it exists in the first place.
You can't make an existing PostgreSQL instance into a standby for another without replacing its data directory. You need a copy of the master's data directory to run a standby. A common way to set that up is to take an existing standby, delete its data directory, replace it with a copy of the master's data directory, and then configure it as a replication slave. That's what I think step 8 is supposed to be doing.
Instead of doing that I think you probably used an existing data directory for the slave and tried to start it up as a replica of the master. That will not work, and will result in the errors you showed.
The main PostgreSQL documentation on replication is the recommended and primary resource for information. I suggest going there first.
You might also want to check out repmgr, which helps automate replication and failover tasks.
The problem is: "localhost" can be UNIX sockets, IPv4 or IPv6. The first rule you passed is for UNIX sockets. Try to add a rule for IPv4 and one for IPv6. It should work then.
Btw, a SIGHUP is enough in case you change pg_hba.conf.
Best Answer
createdb
needs to connect to a database to issue aCREATE DATABASE
SQL statement, and by default it will use:postgres
in your case)template1
as the databaseWhen it does that, in your case you get this error message:
It indicates that
postgres
as a database user does not have the permission to connect through a Unix domain socket (that's what[local]
means).This is unusual, since in general, postgres installers on Unix tend to install a
pg_hba.conf
starting with this rule:Meaning that the
postgres
Unix user has the right to connect locally to any database as thepostgres
database user, which suits the needs of administrating databases, including creating new ones.In fact your
pg_hba.conf
does not look like a default one. The simplest way to proceed to immediately solve the problem of database creation would be to edit it, add the above line as the first rule, and reload the postgres service.