Step 6 - Checking the cluster v4
Checking the cluster
With the cluster up and running, it's worthwhile to run some basic checks to see how effectively it's replicating.
The following example shows one quick way to do this, but make sure 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.
- Log into the database on
- 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):
- On
- Check data
- Log into
node-two
. Log into the database onhost-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 onhost-three
/node-three
. - On
node-three
, get a sum of the value column (for checking): - Compare with the result from
node-one
andnode-two
.
- Log into
Worked example
Preparation
Log into the host-one
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 the host-two
Postgres server:
Create data
On node-one create a table
Run:
On node-one populate the table
This command generates a table of 10000 rows of random values.
On node-one monitor performance
As soon as possible, run:
This command returns statistics on how quickly that data was replicated to the other two nodes:
And it's already replicated.
On node-one get a checksum
To get some values from the generated data, run:
This command returns:
Check data
Log into host-two's Postgres server.
This is your connection to PGD's node-two
.
On node-two get a checksum
To get node-two's values for the generated data, run:
This command returns:
Compare with the result from node-one
When you compare with the result from node-one
, 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-three's Postgres server
This is your connection to PGD's node-three
.
On node-three get a checksum
To get the node-three
values for the generated data, run:
This command returns:
Compare with the result from node-one and node-two
When you compare the results, the values will be identical.