Step 6 - Checking the cluster v5
Checking the cluster
With the cluster up and running, it is worthwhile running some basic checks on how effectively it is replicating.
In the following example, we show one quick way to do this but you should ensure that any testing you perform is appropriate for your use case.
- Preparation
- Ensure the cluster is ready
- Log into the database on host-one/node-one
- Run
select bdr.wait_slot_confirm_lsn(NULL, NULL);
- When the query returns the cluster is ready
- Ensure the cluster is ready
- Create data
The simplest way to test the cluster is replicating is to log into one node, create a table and populate it.
- On node-one create a table
- On node-one populate the table
- On node-one monitor performance
- On node-one get a sum of the value column (for checking)
- Check data
- Log into node-two
Log into the database on host-two/node-two - On node-two get a sum of the value column (for checking)
- Compare with the result from node-one
- Log into node-three Log into the database on host-three/node-three
- On node-three get a sum of the value column (for checking)
- Compare with the result from node-one and node-two
- Log into node-two
Worked example
Preparation
Log into host-one's Postgres server.
This is your connection to PGD's node-one.
Ensure the cluster is ready
To ensure that the cluster is ready to go, run:
This query will block while the cluster is busy initializing and return when the cluster is ready.
In another window, log into host-two's Postgres server
Create data
On node-one create a table
Run
On node-one populate the table
This will generate a table of 10000 rows of random values.
On node-one monitor performance
As soon as possible, run:
And you should see statistics on how quickly that data has been replicated to the other two nodes.
And it's already replicated.
On node-one get a checksum
Run:
to get some values from the generated data:
Check data
Log into host-two's Postgres server.
This is your connection to PGD's node-two.
On node-two get a checksum
Run:
to get node-two's values for the generated data:
Compare with the result from node-one
And the values will be identical.
You can repeat the process with node-three, or generate new data on any node and see it replicate to the other nodes.
Log into host-threes's Postgres server.
This is your connection to PGD's node-three.
On node-three get a checksum
Run:
to get node-three's values for the generated data:
Compare with the result from node-one and node-two
And the values will be identical.