Let's explore now how to perform logical replication. In this section, we will prepare the environment we need to be able to perform our logical replication.
Logical replication environment settings
Suppose we have two machines that we will call pg1 and pg2. We must remember to set our internal DNS, or the /etc hosts file, so that pg1 can reach pg2; for example, for the pg1 server, the master server will have an IP of 192.168.122.20, and for the pg2 server, the replica server will have an IP of 192.168.122.36.
First of all, let's check whether there is a connection between the two servers:
pg1:~$ ping pg2
PING pg2.pgtraining.com (192.168.122.36) 56(84) bytes of data.
64 bytes from pg2.pgtraining.com (192.168.122.36): icmp_seq=1 ttl=64 time=0.893 ms
64 bytes from pg2.pgtraining.com (192.168.122.36): icmp_seq=2 ttl=64 time=0.639 ms
pg2:~$ ping pg1
64 bytes from pg1.pgtraining.com (192.168.122.20): icmp_seq=1 ttl=64 time=1.40 ms
64 bytes from pg1...