HiveBrain v1.2.0
Get Started
← Back to all entries
debugsqlMinor

Postgres 10 replica service error on startup

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
errorpostgresreplicaservicestartup

Problem

I have migrated a database promoting the read-replica in a server with more capacity, this process worked smoothly. But I'm trying to create a read-replica now from this promoted server to have a similar setup than I had before. The problem is when I try to start Postgres server this happens.

● postgresql-10.service - PostgreSQL 10 database server
   Loaded: loaded (/usr/lib/systemd/system/postgresql-10.service; disabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since mar 2018-10-16 07:07:42 UTC; 10s ago
   Docs: https://www.postgresql.org/docs/10/static/
   Process: 22746 ExecStart=/usr/pgsql-10/bin/postmaster -D ${PGDATA} 
   (code=exited, status=2)
   Process: 22740 ExecStartPre=/usr/pgsql-10/bin/postgresql-10-check-db-dir ${PGDATA} (code=exited, status=0/SUCCESS)
   Main PID: 22746 (code=exited, status=2)


I'm going to describe my process as accurate as I can, I'm running on CentOS RHEL 7.

First I install Postgres 10:

rpm -Uvh https://yum.postgresql.org/10/redhat/rhel-7-x86_64/pgdg-centos10-10-2.noarch.rpm
yum install postgresql10-server postgresql10
yum install postgresql10-contrib
su - postgres
/usr/pgsql-10/bin/initdb
systemctl start postgresql-10.service


This works, the server is running so the installation worked, let's start with the replication. I stop the service and continue with this:

rm -r /var/lib/pgsql/10/data
 su - postgres
 /usr/pgsql-10/bin/pg_basebackup -h  -D /var/lib/pgsql/10/data/ -P -U replicate


replicate is the user with replication privileges in the main database.

The pg_basebackup finishes correctly, then I rename the recovery.done to recovery.conf.

```
drwx------. 6 postgres postgres 54 oct 16 06:45 base
-rw-------. 1 postgres postgres 30 oct 16 06:55 current_logfiles
drwx------. 2 postgres postgres 4,0K oct 16 06:45 global
drwx------. 2 postgres postgres 188 oct 16 06:53 log
drwx------. 2 postgres postgres 6 oct 16 06:45 pg_commit_ts
drwx------. 2 postgres postgres

Solution

Finally, I noticed where the problem was. The pg_basebackup copied a recovery.conf file that was originally from the source database, and this caused the break. Removing recovery.conf and creating it from scratch solved the issue.

The server is now running.

Context

StackExchange Database Administrators Q#220197, answer score: 2

Revisions (0)

No revisions yet.