I've followed the instructions to set up a replica server of PostgreSQL with repmgr
, But I can't start the PostgreSQL service because of a permission problem.
On the stand by server, I have this on my /etc/repmgr.conf
file:
node_id=2
node_name=aws-replica
conninfo='host=<REDACTED> user=repmgr dbname=repmgr port=5432'
data_directory='/mnt/data/postgres/data'
log_file='/var/log/repmgr.log'
As you can see, I've changed the location of the data directory to /mnt/data/postgres/data
and also updated the postgresql.conf
file with the same information.
When I try to start the PostgreSQL service, I get this error on journalctl
:
FATAL: data directory "/mnt/data/postgres/data" has wrong ownership
HINT: The server must be started by the user that owns the data directory.
The folder in question is owned by a normal user, the same one that runs repmgr
. If I set the ownership of the folder to postgres:postgres
, then repmgr
can't perform any operations because it can't access the folder. I tried joining the postgres
group, but the service won't start unless the folder has 700
permissions, so it's pointless to join the group.
So, I'm either not being able to start postgresql
or repmgr
. What can I do to make it work?
The problem was that I created a postgres DB using
innitdb
, which wasn't necessary. I deleted the database and then ranrepmgr
as thepostgres
user, and it worked.