This page in other versions: 0.9 / 1.0 / 1.0.3

3.3. Installing BDR or UDR from source

3.3.1. Prerequisites for installing from source

To install either BDR or UDR the prerequisites for compiling PostgreSQL must be installed. These are described in PostgreSQL's documentation on build requirements and build requirements for documentation.

On several systems the prerequisites for compiling PostgreSQL and BDR/UDR can be installed using simple commands.

3.3.2. Getting BDR source code

There are two ways to get the BDR source code: with git, or by downloading tarballs of released versions.

3.3.2.1. Using git to get the BDR sources

Use git if you expect to update often, you want to keep track of development or if you want to contribute changes to BDR. There is no reason not to use git if you're familiar with it.

The source for BDR is maintained at git.postgresql.org in the 2ndquadrant_bdr repository. There are actually two independent source trees in this repository - one tree for the BDR plugin, and one for the modified version of PostgreSQL 9.4 that it requires to run. At the time of writing the main branches are:

  • bdr-plugin/RELX_Y_STABLE: the stable releases of the BDR plugin (for example bdr-plugin/REL0_9_STABLE is latest source of 0.9.x).

  • bdr-plugin/next: the in-progress development version of the BDR plugin

  • bdr-pg/REL9_4_STABLE: the current stable release of the modified PostgreSQL that BDR requires.

There are also tags for each BDR release, e.g. bdr-plugin/0.8.0.

To clone the source code using git you will need to run two clones, one for the BDR plugin sources and one for the patched PostgreSQL sources, e.g. (for the 0.9.x version of BDR):

     git clone -b bdr-pg/REL9_4_STABLE git://git.postgresql.org/git/2ndquadrant_bdr.git postgresql-bdr
     git clone -b bdr-plugin/REL0_9_STABLE git://git.postgresql.org/git/2ndquadrant_bdr.git bdr-plugin
    

For more information on using git see git-scm.org.

3.3.2.2. Downloading release source tarballs

Official BDR release source code is uploaded as tarballs to the BDR website along with a tarball checksum and a matching GnuPG signature. Download from http://packages.2ndquadrant.com/postgresql-bdr94-2ndquadrant/tarballs/. See Verifying digital signatures for information on verifying digital signatures.

You will need to download both the patched PostgreSQL source (postgresql-bdr-[...].tar.gz) and the associated BDR release (bdr-[...].tar.gz).

You may optionally verify the package checksums from the .md5 files and/or verify the GnuPG signatures per Verifying digital signatures.

After you unpack the source code archives using tar xf the installation process is the same as if you were installing from a git clone.

3.3.3. Installation of BDR from source

Installing BDR from source consists out of two steps: First compile and install PostgreSQL with the BDR additions; secondly compile and install the BDR plugin.

The patched PostgreSQL required for BDR can be compiled using the normal documented procedures. That will usually be something like:

    cd /path/to/bdr-pg-source/
    ./configure --prefix=/path/to/install --enable-debug --with-openssl
    make -j4 -s install-world
   

To then install BDR execute its configure script with the pg_config installed by the patched PostgreSQL in the PATH environment variable, e.g.:

    cd /path/to/bdr-plugin-source/
    PATH=/path/to/postgres/install/bin:"$PATH" ./configure
    make -j4 -s all
    make -s install
   

3.3.4. Installation of UDR from source

Installing UDR is simpler than installing BDR. It compiles against a stock (unmodified) PostgreSQL 9.4 if the relevant headers are installed.

Most Linux distributions put the required header files in a "dev" or "devel" package. Exactly what to install depends on how you installed PostgreSQL in the first place.

To compile UDR execute its configure script with PostgreSQL's pg_config in the PATH.

    cd /path/to/bdr-plugin-source/
    PATH=/path/to/pg/install:"$PATH" ./configure
    make -j16 -s all
   

On Debian/Ubuntu systems pg_config is on the default PATH so you can just run

    ./configure
   

On RHEL/CentOS systems you will need to put /usr/pgsql-9.4/bin on the PATH, e.g.:

    PATH=/usr/pgsql-9.4/bin:$PATH ./configure