BDR Quick Start

From PostgreSQL wiki

(Difference between revisions)
Jump to: navigation, search
Line 7: Line 7:
 
* Install a patched copy of PostgreSQL that can support BDR;
 
* Install a patched copy of PostgreSQL that can support BDR;
 
* <tt>initdb</tt> a new data directory or upgrade your current one to support BDR;
 
* <tt>initdb</tt> a new data directory or upgrade your current one to support BDR;
* Configure one or more logical senders and receivers
+
* Start one or more additional BDR-patched PostgreSQL instances for replication
 +
* Logical senders and receivers on each node
  
Usually BDR is used to connect multiple separate PostgreSQL server instances. This guide will illustrate a simpler configuration that replicates between two databases ''on the same server instance'' so you don't have to juggle running multiple servers. It'll also assume you want to start a new server instance rather than BDR-enable an existing one. Those topics and more are covered in the main user guide.
+
For simplicitly this guide assumes that you want to start a new server instance rather than BDR-enable an existing one. As a further simplification, the instructions show the creation of multiple PostgreSQL instances on a single computer rather than the normal BDR deployment pattern of one instance per computer on multiple computers.
  
 
== Installing the patched PostgreSQL binaries ==
 
== Installing the patched PostgreSQL binaries ==
  
BDR is distributed as [http://git.postgresql.org/gitweb/?p=2ndquadrant_bdr.git;a=summary|source code in the <tt>2ndquadrant_bdr</tt> repository on <tt>git.postgresql.org</tt>]. Source and binary packages are in progress.
+
BDR is distributed as [http://git.postgresql.org/gitweb/?p=2ndquadrant_bdr.git;a=summary|source code in the <tt>2ndquadrant_bdr</tt> repository on <tt>git.postgresql.org</tt>]. Source and binary packages are in progress. A script to compile BDR for test use is provided below.
  
 
PostgreSQL 9.3 and below do not support BDR, and 9.4 requires patches, so this guide will not work for you if you are trying to use a normal install of PostgreSQL. (It is expected that PostgreSQL 9.5 will support the BDR extension without additional patches).
 
PostgreSQL 9.3 and below do not support BDR, and 9.4 requires patches, so this guide will not work for you if you are trying to use a normal install of PostgreSQL. (It is expected that PostgreSQL 9.5 will support the BDR extension without additional patches).
Line 61: Line 62:
 
that mentions BDR.
 
that mentions BDR.
  
== Creating a BDR-enabled PostgreSQL instance ==
+
== Creating BDR-enabled PostgreSQL instances ==
  
Since we're creating a new PostgreSQL instance for this example, run:
+
Since we're creating new PostgreSQL instances for this example, run:
  
  initdb -D $HOME/2ndquadrant_bdr/bdr-db -A trust -U postgres
+
  initdb -D $HOME/2ndquadrant_bdr/bdr5598 -A trust -U postgres
 +
 
 +
initdb -D $HOME/2ndquadrant_bdr/bdr5599 -A trust -U postgres
 +
 
 +
to make two new PostgreSQL database server instances ("clusters").
  
 
''The <tt>-A trust</tt> option tells PostgreSQL to turn off user authentication. This should never be used in production, it just keeps this quickstart simpler. Securely
 
''The <tt>-A trust</tt> option tells PostgreSQL to turn off user authentication. This should never be used in production, it just keeps this quickstart simpler. Securely
Line 72: Line 77:
 
== Start the server ==
 
== Start the server ==
  
Run:
+
We'll run the two servers on ports 5598 and 5599 respectively, so they don't conflict with each other or with PostgreSQL's default port 5432.
 +
 
 +
To start the servers, which won't yet be connected to each other, run:
 +
 
 +
PGPORT=5598 pg_ctl -l $HOME/2ndquadrant_bdr/bdr5598.log -D $HOME/2ndquadrant_bdr/bdr5598 -w start
  
  export PGPORT=5599
+
  PGPORT=5599 pg_ctl -l $HOME/2ndquadrant_bdr/bdr5599.log -D $HOME/2ndquadrant_bdr/bdr5599 -w start
pg_ctl -l $HOME/2ndquadrant_bdr/bdr-db.log -D $HOME/2ndquadrant_bdr/bdr-db -w start
+
  
The server will start up, printing:
+
Each server will start up, printing:
  
 
  waiting for server to start.... done
 
  waiting for server to start.... done
Line 88: Line 96:
 
  Examine the log output.
 
  Examine the log output.
  
''then take a look at <tt>$HOME/2ndquadrant_bdr/bdr-db.log</tt> to see what happened. Most likely you already have a server running on port <tt>5599</tt> or you're repeating a step and the BDR postgres server is already running on that port.''
+
''then take a look at <tt>$HOME/2ndquadrant_bdr/bdr5598.log</tt> or <tt>bdr5599.log</tt> (depending on which failed to start) to see what happened. Most likely you already have a server running on the target port or you're repeating a step and the BDR postgres server is already running on that port.''
  
 
== Create the databases ==
 
== Create the databases ==
  
We need two (or more) databases to test BDR with, since we're going to be running it between two databases within one PostgreSQL install. So run:
+
Each node needs a database to participate in BDR, so create them now:
  
  createdb -U postgres bdr1
+
  createdb -p 5598 -U postgres bdrdemo
  createdb -U postgres bdr2
+
  createdb -p 5599 -U postgres bdrdemo
  
to create the two databases.  
+
It is important that you leave the database on the server on port 5599 empty, since we'll be initializing it from the node on port 5598 shortly.
  
It is important that you leave <tt>bdr2</tt> empty, but if you like you can now make a few tables within <tt>bdr1</tt>, add some rows, etc.
+
You can create some tables on the node on port 5598 and add some data now, if you like. To connect with <tt>psql</tt>, use:
 +
 
 +
psql -p 5598 -U postgres bdrdemo
  
 
== Enable the BDR extension ==
 
== Enable the BDR extension ==
Line 105: Line 115:
 
You now have a running PostgreSQL server. It behaves like any ordinary PostgreSQL server at this point, but it's time to change that.
 
You now have a running PostgreSQL server. It behaves like any ordinary PostgreSQL server at this point, but it's time to change that.
  
Add the following lines to the end of <tt>$HOME/2ndquadrant_bdr/bdr-db/postgresql.conf</tt>:
+
Add the following lines to the end of <tt>postgresq.conf</tt> for ''both'' servers (<tt>$HOME/2ndquadrant_bdr/bdr5598/postgresql.conf</tt> and <tt>$HOME/2ndquadrant_bdr/bdr5599/postgresql.conf</tt>):
  
 
  # Generic settings required for BDR
 
  # Generic settings required for BDR
Line 122: Line 132:
 
  # Load BDR
 
  # Load BDR
 
  shared_preload_libraries = 'bdr'
 
  shared_preload_libraries = 'bdr'
 +
 +
This part of the configuration covers the generic settings required to use a two-node BDR configuration. They're discussed in more detail in the [[BDR Parameter Reference]].
 +
 +
Now append this to the end of node 5598's configuration file ($HOME/2ndquadrant_bdr/bdr-5598/postgresql.conf) only:
 +
 +
# BDR connection configuration for node 5598
 +
#-------------------------------------------
 
   
 
   
# BDR connection configuration
+
  bdr.connections = 'bdr5599'
#-----------------------------
+
+
  bdr.connections = 'nodeA, nodeB'
+
 
   
 
   
  bdr.nodeA_dsn = 'dbname=bdr2 user=postgres port=5599'
+
  bdr.bdr5599_dsn = 'dbname=bdrdemo user=postgres port=5599'
bdr.nodeA_local_dbname = 'bdr1'
+
 
   
 
   
 
  bdr.nodeB_dsn = 'dbname=bdr1 user=postgres  port=5599'
 
  bdr.nodeB_dsn = 'dbname=bdr1 user=postgres  port=5599'
Line 135: Line 148:
 
  bdr.nodeB_init_replica = on
 
  bdr.nodeB_init_replica = on
 
  bdr.nodeB_replica_local_dsn = 'dbname=bdr2 user=postgres port=5599'
 
  bdr.nodeB_replica_local_dsn = 'dbname=bdr2 user=postgres port=5599'
 +
 +
and this to the end of node 5599's configuration file ($HOME/2ndquadrant_bdr/bdr-5598/postgresql.conf) only:
 +
 +
# BDR connection configuration for node 5599
 +
#-------------------------------------------
 +
 +
bdr.connections = 'bdr5598'
 
   
 
   
The first part covers the generic settings required to use a two-node BDR configuration. They're discussed in more detail in the [[BDR Parameter Reference]].
+
bdr.bdr5598_dsn = 'dbname=bdrdemo user=postgres port=5598'
 +
bdr.bdr5598_init_replica = on
 +
bdr.bdr5598_replica_local_dsn = 'dbname=bdrdemo user=postgres port=5599'
  
The second part specifies a two-node BDR configuration where the node named <tt>nodeA</tt> runs from database <tt>bdr1</tt> and connects to database <tt>bdr2</tt>. The node named <tt>nodeB</tt> runs from the other database <tt>bdr2</tt> and connects back to database <tt>bdr1</tt>. <tt>init_replica</tt> means that when BDR first  starts, <tt>nodeB</tt>'s contents are automatically copied from <tt>nodeA</tt>'s database.
 
  
''This probably seems pretty confusing. That's because we're using two databases on the same PostgreSQL instance to save you the hassle of running multiple servers, which would be even more confusing. In a normal BDR deployment you would almost always run separate PostgreSQL servers, each on its own computer, where every BDR node has the same database name on a different PostgreSQL server. In that case the <tt>local_dbname</tt> parameters are no longer required.''
+
These parts specify a two-node BDR configuration in which the <tt>bdrdemo</tt> database on the PostgreSQL instance on port 5598 is replicated to and from the <tt>bdrdemo</tt> database on the instance on port 5599. Each node has to be told how to connect to the other node(s) in its configuration file.
  
''If you don't fully understand this section, don't worry, there are more examples in the admin guide.''
+
The <tt>init_replica</tt> option that appears only on node 5599 means that when BDR first starts on <tt>bdr5599</tt>, the <tt>bdrdemo</tt> database's contents are automatically copied from <tt>bdr5598</tt> into <tt>bdr5599</tt> so that replication can begin from a consistent point. (Explicit configuration of this will be removed in a later release).
  
 
== Add a <tt>pg_hba.conf</tt> entry to allow replication ==
 
== Add a <tt>pg_hba.conf</tt> entry to allow replication ==
  
PostgreSQL requires that you explicitly enable replication in the host-based access control file <tt>pg_hba.conf</tt>. So edit <tt>$HOME/2ndquadrant_bdr/bdr-db/pg_hba.conf<tt> and add the following lines (or uncomment the ones already there):
+
PostgreSQL requires that you explicitly enable replication in the host-based access control file <tt>pg_hba.conf</tt>. So edit <tt>$HOME/2ndquadrant_bdr/bdr5598/pg_hba.conf<tt> and add the following lines (or uncomment the ones already there):
  
 
  local replication postgres              trust
 
  local replication postgres              trust
 
  host  replication postgres 127.0.0.1/32 trust
 
  host  replication postgres 127.0.0.1/32 trust
 
  host  replication postgres ::1/128      trust
 
  host  replication postgres ::1/128      trust
 +
 +
... then do the same on <tt>bdr5599</tt>.
  
 
''To learn more about this, see the docs on <tt>[http://www.postgresql.org/docs/current/static/auth-pg-hba-conf.html|pg_hba.conf]</tt>''.
 
''To learn more about this, see the docs on <tt>[http://www.postgresql.org/docs/current/static/auth-pg-hba-conf.html|pg_hba.conf]</tt>''.
  
== Restart the server ==
+
== Restart the servers ==
 +
 
 +
Now that you've created the databases to use and configured BDR, it's time to restart the servers so BDR will get turned on. Use the same <tt>pg_ctl</tt> command, but with <tt>restart</tt> instead of <tt>start</tt>:
  
Now that you've created the databases to use and configured BDR, it's time to restart the server so BDR will get turned on. Use the same <tt>pg_ctl</tt> command, but with <tt>restart</tt> instead of <tt>start</tt>:
+
pg_ctl -l $HOME/2ndquadrant_bdr/bdr5598.log -D $HOME/2ndquadrant_bdr/bdr5598 -w restart
  
  pg_ctl -l $HOME/2ndquadrant_bdr/bdr-db.log -D $HOME/2ndquadrant_bdr/bdr-db -w restart
+
  pg_ctl -l $HOME/2ndquadrant_bdr/bdr5599.log -D $HOME/2ndquadrant_bdr/bdr5599 -w restart
  
 
== (Optional) Check the logs ==
 
== (Optional) Check the logs ==
  
Take a look at <tt>$HOME/2ndquadrant_bdr/bdr-db.log</tt>:
+
Take a look at <tt>$HOME/2ndquadrant_bdr/bdr5599.log</tt>:
  
 
  less $HOME/2ndquadrant_bdr/bdr-db.log
 
  less $HOME/2ndquadrant_bdr/bdr-db.log
Line 168: Line 193:
 
You should see a few lines like:
 
You should see a few lines like:
  
  Dumping remote database "dbname=bdr1 user=postgres  port=5599" with 1 concurrent workers to "/tmp/postgres-bdr-0000076D-1.11322"
+
  Dumping remote database "dbname=bdrdemo user=postgres  port=5598" with 1 concurrent workers to "/tmp/postgres-bdr-0000076D-1.11322"
  Restoring dump to local DB "dbname=bdr2 user=postgres port=5599" with 1 concurrent workers from "/tmp/postgres-bdr-0000076D-1.11322"
+
  Restoring dump to local DB "dbname=bdrdemo user=postgres port=5599" with 1 concurrent workers from "/tmp/postgres-bdr-0000076D-1.11322"
  
indicating that <tt>db1</tt> has been copied to <tt>db2</tt>, then  
+
indicating that <tt>db1</tt> has been copied to <tt>db2</tt>, then lines similar to:
  
LOG:  registering background worker "bdr (6028730235379497978,1,16385,): nodeb: apply"
+
  LOG:  starting background worker process "bdr (6028730235379497978,1,16385,): bdr5598: apply"
  LOG:  starting background worker process "bdr (6028730235379497978,1,16385,): nodeb: apply"
+
 
  DETAIL:  streaming transactions committing after 0/19D1588, reading WAL from 0/19D01D0
 
  DETAIL:  streaming transactions committing after 0/19D1588, reading WAL from 0/19D01D0
  
...
+
In the log <tt>$HOME/2ndquadrant_bdr/bdr5598.log</tt> you won't see the lines about the dump and restore, since it's the first master. Just:
  
  LOG:  starting background worker process "bdr (6028730235379497978,1,16384,): nodea: apply"
+
  LOG:  starting background worker process "bdr (6028730235379497978,1,16384,): bdr5599: apply"
LOG:  starting logical decoding for slot bdr_16385_6028730235379497978_1_16384__
+
 
  DETAIL:  streaming transactions committing after 0/19D01D0, reading WAL from 0/19D0198
 
  DETAIL:  streaming transactions committing after 0/19D01D0, reading WAL from 0/19D0198
  
 
They won't be exactly the same, but this indicates normal startup.
 
They won't be exactly the same, but this indicates normal startup.
  
''At time of writing it's normal to get a <tt>CONFLICT</tt> message, a <tt>FATAL: Role "myusername" does not exist</tt> and a few other messages. These are cosmetic and will be removed.''
+
''At time of writing it's normal to get a <tt>CONFLICT</tt> message, a <tt>FATAL: Role "myusername" does not exist</tt> and a few other messages. These are cosmetic and will be removed in later releases.''
  
 
== Using your new BDR server ==
 
== Using your new BDR server ==
  
You can now connect to either <tt>bdr1</tt> or <tt>bdr2</tt> and make changes. The changes you make will get replicated to the other database.
+
You can now connect to <tt>bdrdemo</tt> on port 5598 or port 5599 and make changes. The changes you make will get replicated to the other database.
  
To connect to <tt>bdr1</tt>, use:
+
To connect to 5598, use:
  
  psql "port=5599 user=postgres dbname=bdr1"
+
  psql "port=5598 user=postgres dbname=bdrdemo"
  
For <tt>bdr2</tt>, just change the database name.
+
For 5599, just change the port.
  
 
== Example session ==
 
== Example session ==

Revision as of 03:33, 27 June 2014

This guide discusses how to quickly configure a test install of Bi-Directional Replication (BDR) for experimentation and learning. These instructions are not suitable for a production install, as they neglect security considerations, proper system administration procedure, etc. If you're trying to set up a production BDR install, see the BDR Admin Guide.

Contents

Creating and starting a test BDR install

To set up BDR you'll need to:

  • Install a patched copy of PostgreSQL that can support BDR;
  • initdb a new data directory or upgrade your current one to support BDR;
  • Start one or more additional BDR-patched PostgreSQL instances for replication
  • Logical senders and receivers on each node

For simplicitly this guide assumes that you want to start a new server instance rather than BDR-enable an existing one. As a further simplification, the instructions show the creation of multiple PostgreSQL instances on a single computer rather than the normal BDR deployment pattern of one instance per computer on multiple computers.

Installing the patched PostgreSQL binaries

BDR is distributed as code in the 2ndquadrant_bdr repository on git.postgresql.org. Source and binary packages are in progress. A script to compile BDR for test use is provided below.

PostgreSQL 9.3 and below do not support BDR, and 9.4 requires patches, so this guide will not work for you if you are trying to use a normal install of PostgreSQL. (It is expected that PostgreSQL 9.5 will support the BDR extension without additional patches).

BDR only supports Linux and Mac OS X. You cannot use BDR on Windows yet. There are no fundamental technical barriers to supporting Windows, but it has not been a priority of the project.

Compiling PostgreSQL with BDR

A script to download and compile BDR is provided for your convenience. For those who prefer to do it by hand, see installing BDR from source.

To run the script:

   curl "http://git.postgresql.org/gitweb/?p=2ndquadrant_bdr.git;a=blob_plain;f=contrib/bdr/scripts/bdr_quickstart.sh;hb=refs/heads/bdr-next" | bash

(Now, on an aside, that script could've been almost anything. It's safer to download scripts like that, read them, then run the downloaded copy.)

When it finishes, the script will print:

---------------------------
BDR compiled and installed.

Sources at /home/myuser/2ndquadrant_bdr/bdr-src
Installed to /home/myuser/2ndquadrant_bdr/bdr

Now add it to your PATH:
    export PATH=/home/myuser/2ndquadrant_bdr/bdr/bin:$PATH
and carry on with the quickstart at https://wiki.postgresql.org/wiki/BDR_User_Guide
---------------------------


Adjusting your environment

To actually use these new binaries you will need to do as the quickstart script suggested and:

export PATH=$HOME/2ndquadrant_bdr/bdr/bin:$PATH

This only affects the terminal you ran it in and makes no permanent changes. For how to apply the change permanently see adjusting your environment.

Now check that you're using the BDR binaries by running:

   psql --version

It should print something like:

   psql (PostgreSQL) 9.4_bdr0601

that mentions BDR.

Creating BDR-enabled PostgreSQL instances

Since we're creating new PostgreSQL instances for this example, run:

initdb -D $HOME/2ndquadrant_bdr/bdr5598 -A trust -U postgres
initdb -D $HOME/2ndquadrant_bdr/bdr5599 -A trust -U postgres

to make two new PostgreSQL database server instances ("clusters").

The -A trust option tells PostgreSQL to turn off user authentication. This should never be used in production, it just keeps this quickstart simpler. Securely configuring BDR is covered in BDR Administration.

Start the server

We'll run the two servers on ports 5598 and 5599 respectively, so they don't conflict with each other or with PostgreSQL's default port 5432.

To start the servers, which won't yet be connected to each other, run:

PGPORT=5598 pg_ctl -l $HOME/2ndquadrant_bdr/bdr5598.log -D $HOME/2ndquadrant_bdr/bdr5598 -w start
PGPORT=5599 pg_ctl -l $HOME/2ndquadrant_bdr/bdr5599.log -D $HOME/2ndquadrant_bdr/bdr5599 -w start

Each server will start up, printing:

waiting for server to start.... done
server started

If you instead get:

waiting for server to start........ stopped waiting
pg_ctl: could not start server
Examine the log output.

then take a look at $HOME/2ndquadrant_bdr/bdr5598.log or bdr5599.log (depending on which failed to start) to see what happened. Most likely you already have a server running on the target port or you're repeating a step and the BDR postgres server is already running on that port.

Create the databases

Each node needs a database to participate in BDR, so create them now:

createdb -p 5598 -U postgres bdrdemo
createdb -p 5599 -U postgres bdrdemo

It is important that you leave the database on the server on port 5599 empty, since we'll be initializing it from the node on port 5598 shortly.

You can create some tables on the node on port 5598 and add some data now, if you like. To connect with psql, use:

psql -p 5598 -U postgres bdrdemo

Enable the BDR extension

You now have a running PostgreSQL server. It behaves like any ordinary PostgreSQL server at this point, but it's time to change that.

Add the following lines to the end of postgresq.conf for both servers ($HOME/2ndquadrant_bdr/bdr5598/postgresql.conf and $HOME/2ndquadrant_bdr/bdr5599/postgresql.conf):

# Generic settings required for BDR
#----------------------------------

# Allow two other peer nodes, plus one for init_replica
max_replication_slots = 3

# Two peer nodes, plus two slots for pg_basebackup
max_wal_senders = 4 

# Record data for logical replication
wal_level = 'logical'
track_commit_timestamp = on

# Load BDR
shared_preload_libraries = 'bdr'

This part of the configuration covers the generic settings required to use a two-node BDR configuration. They're discussed in more detail in the BDR Parameter Reference.

Now append this to the end of node 5598's configuration file ($HOME/2ndquadrant_bdr/bdr-5598/postgresql.conf) only:

# BDR connection configuration for node 5598
#-------------------------------------------

bdr.connections = 'bdr5599'

bdr.bdr5599_dsn = 'dbname=bdrdemo user=postgres port=5599'

bdr.nodeB_dsn = 'dbname=bdr1 user=postgres  port=5599'
bdr.nodeB_local_dbname = 'bdr2'
bdr.nodeB_init_replica = on
bdr.nodeB_replica_local_dsn = 'dbname=bdr2 user=postgres port=5599'

and this to the end of node 5599's configuration file ($HOME/2ndquadrant_bdr/bdr-5598/postgresql.conf) only:

# BDR connection configuration for node 5599
#-------------------------------------------

bdr.connections = 'bdr5598'

bdr.bdr5598_dsn = 'dbname=bdrdemo user=postgres port=5598' 
bdr.bdr5598_init_replica = on
bdr.bdr5598_replica_local_dsn = 'dbname=bdrdemo user=postgres port=5599'


These parts specify a two-node BDR configuration in which the bdrdemo database on the PostgreSQL instance on port 5598 is replicated to and from the bdrdemo database on the instance on port 5599. Each node has to be told how to connect to the other node(s) in its configuration file.

The init_replica option that appears only on node 5599 means that when BDR first starts on bdr5599, the bdrdemo database's contents are automatically copied from bdr5598 into bdr5599 so that replication can begin from a consistent point. (Explicit configuration of this will be removed in a later release).

Add a pg_hba.conf entry to allow replication

PostgreSQL requires that you explicitly enable replication in the host-based access control file pg_hba.conf. So edit $HOME/2ndquadrant_bdr/bdr5598/pg_hba.conf<tt> and add the following lines (or uncomment the ones already there):

local replication postgres              trust
host  replication postgres 127.0.0.1/32 trust
host  replication postgres ::1/128      trust

... then do the same on <tt>bdr5599.

To learn more about this, see the docs on [1].

Restart the servers

Now that you've created the databases to use and configured BDR, it's time to restart the servers so BDR will get turned on. Use the same pg_ctl command, but with restart instead of start:

pg_ctl -l $HOME/2ndquadrant_bdr/bdr5598.log -D $HOME/2ndquadrant_bdr/bdr5598 -w restart
pg_ctl -l $HOME/2ndquadrant_bdr/bdr5599.log -D $HOME/2ndquadrant_bdr/bdr5599 -w restart

(Optional) Check the logs

Take a look at $HOME/2ndquadrant_bdr/bdr5599.log:

less $HOME/2ndquadrant_bdr/bdr-db.log

You should see a few lines like:

Dumping remote database "dbname=bdrdemo user=postgres  port=5598" with 1 concurrent workers to "/tmp/postgres-bdr-0000076D-1.11322"
Restoring dump to local DB "dbname=bdrdemo user=postgres port=5599" with 1 concurrent workers from "/tmp/postgres-bdr-0000076D-1.11322"

indicating that db1 has been copied to db2, then lines similar to:

LOG:  starting background worker process "bdr (6028730235379497978,1,16385,): bdr5598: apply"
DETAIL:  streaming transactions committing after 0/19D1588, reading WAL from 0/19D01D0

In the log $HOME/2ndquadrant_bdr/bdr5598.log you won't see the lines about the dump and restore, since it's the first master. Just:

LOG:  starting background worker process "bdr (6028730235379497978,1,16384,): bdr5599: apply"
DETAIL:  streaming transactions committing after 0/19D01D0, reading WAL from 0/19D0198

They won't be exactly the same, but this indicates normal startup.

At time of writing it's normal to get a CONFLICT message, a FATAL: Role "myusername" does not exist and a few other messages. These are cosmetic and will be removed in later releases.

Using your new BDR server

You can now connect to bdrdemo on port 5598 or port 5599 and make changes. The changes you make will get replicated to the other database.

To connect to 5598, use:

psql "port=5598 user=postgres dbname=bdrdemo"

For 5599, just change the port.

Example session

Here's an example showing a psql session:

...

Where to go from here?

You should now read the BDR Admin Guide, or just start experimenting.

Personal tools