Using repmgr to create replica
As mentioned earlier in this chapter, repmgr is a management suite to manage replication setups and also to create replicas and add them to the existing PostgreSQL clusters. In this recipe, we are going to create a new clone of the primary server.
This recipe builds on from the previous recipe. Here we are going to create a replica of the primary server pg-primary
and as we said we need two machines participating in this configuration. Our replica server will be titled pg-clone
and the /data
location will be our data directory.
How to do it...
All the following commands in this recipe are carried out in the replica server pg-clone. Here are the complete steps:
First log in as the Postgres user and generate a RSA key-pair and send the credentials to the primary server
pg-primary
:ssh-keygen -t rsa -N ' ' ssh-copy-id postgres@pg-primary
In the next step, we are going to clone the data on the pg-primary server with the following command:
...