Skip to main content

Deploying PeerDB

We currently support deploying and testing PeerDB using our Docker Compose file.
Docker can be installed by referring to these instructions. The docker compose tool should also be present. The Postgres client tools (specifically psql) are used to test the PeerDB installation.
  1. Run the following commands in your terminal:
  2. Connect to PeerDB:
That’s it! You now have PeerDB up and running on your machine, ready to query away!

Quickstart

The following steps assume you have PeerDB running locally. We also need the Postgres client tools (specifically psql and pgbench) installed and available on your PATH.

Setup

This script reuses the PeerDB internal Postgres instance to setup two databases, which we can use to create two peers. It also creates some tables on both databases to use later in the quickstart. Run the following commands in your terminal:

Creating Peers

With PeerDB running, we can create our first peers. Connect to PeerDB via psql and run the below commands to create the source and target peers:

Real-time CDC

Run the following command to kick off Change Data Capture (CDC) based streaming from source peer to target peer for the test table.
Now that our CDC mirror is set up, it will automatically replicate data from the source to the target peer. Let’s insert a row in the source table via PeerDB itself.
Within a few seconds, the row should be replicated to the target table. Let’s verify this by running the following command:
The output should look like this:
The above MIRROR takes care of replicating all DML commands (INSERT, UPDATE, DELETE) from source to target.

Streaming Query from PostgreSQL

Run the following command to kick off query based streaming from source peer to target peer. You are able to mask c1,c2 and t columns by hashing them prior to streaming them to the target.
Now our mirror is set up. You should see the results of the above SELECT query replicated on the target peer.
The output should look like this:

Mirrors are continuous

As you add more rows to the test table on the source, the above MIRRORs take care of replicating the data to both test and test_transformed table on the target. Insert a new row on the source:
Check the new row added to target tables

FAQ

If you have any questions about the PeerDB setup and deployment process, don’t hesitate to reach out on Slack. We’re more than happy to assist and answer any questions, including:
  • What is the performance I can expect during CDC and query based replication?
  • How do I know my data sync is successful?
  • Can I set a specific time to start my data sync?
If there are any unanswered questions, we’d love to help you get started. Feel free to ask your questions on our community Slack channel. In addition to this, if you require direct access to our team for any assistance, don’t hesitate to contact us to discuss our premium support offerings.