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 you must ensure that any testing you perform is appropriate for your use case.
On any of the installed and configured nodes, log in and run psql to connect to the database. If you are using EDB Postgres Advanced Server, use the enterprisedb user, otherwise use postgres:
sudo -iu postgres psql pgddb
This command connects you directly to the database on host-1/node-1.
Quick test
- Preparation
- Ensure the cluster is ready:
- Log in to the database on host-1/node-1.
- 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 that the cluster is replicating is to log in to one node, create a table, and populate it.
- On node-1, create a table:
CREATE TABLE quicktest ( id SERIAL PRIMARY KEY, value INT );
- On node-1, populate the table:
INSERT INTO quicktest (value) SELECT random()*10000 FROM generate_series(1,10000);
- On node-1, monitor performance:
select * from bdr.node_replication_rates;
- On node-1, get a sum of the value column (for checking):
- On node-1, create a table: