This page in other versions: 0.9 / 1.0 / 1.0.3

3.2. Installing BDR from packages

Installation from packages is a good choice if you want the stable release, as it's easier to install and to keep track of your installation.

If you want the very latest BDR or if packages are not yet available for your operating system you may instead want to install from source code.

Note: These instructions are part of the BDR source code so they will be outdated if you are looking at documentation for an old BDR version. Installation from packages will typically install the latest stable BDR version.

3.2.1. RHEL, Fedora and CentOS

Packages for BDR are available for Red Hat derived distros - Fedora, RHEL, and CentOS.

3.2.1.1. Install the repository RPMs

To install BDR from RPMs you should first download and install the repository RPM for your distro. This RPM will configure the download location for the BDR packages and load the signing key into your RPM database so that the package digital signatures may be verified.

Note: The repository RPM is signed with 2ndQuadrant's master packaging/releases signing key. See Verifying digital signatures.

RHEL and CentOS users should download and install the appropriate repo rpm:

     # RHEL/CentOS users only:
     sudo yum install https://rpm.2ndquadrant.com/site/content/2ndquadrant-repo-bdr9.4-1-1.el7.noarch.rpm
    

Fedora users should download and install the Fedora RPM for Fedora 27, or run:

     # Fedora users only
     sudo yum install https://rpm.2ndquadrant.com/site/content/2ndquadrant-repo-bdr9.4-1-1.fc27.noarch.rpm
    

It is strongly recommended that you also enable the corresponding repository from yum.postgresql.org, as the BDR repositories only contain the BDR extension and the PostgreSQL server, client, PLs, and the rest of the core PostgreSQL release. They do not contain PostGIS, PgBarman, or any of the other components already included in yum.postgresql.org releases. BDR is fully compatible with these components.

Red Hat / CentOS users should also enable EPEL.

3.2.1.2. Installing PostgreSQL 9.4 and BDR from packages for RHEL, Fedora or CentOS

3.2.1.2.1. Remove the postgresql94 packages, if installed

Note: If you don't already have PostgreSQL 9.4 installed, simply skip this step.

BDR requires a patched version of PostgreSQL 9.4 that conflicts with the official packages from yum.postgresql.org. If you already have PostgreSQL 9.4installed from yum.postgresql.org, you will need to make a dump of all your databases, then uninstall the PGDG PostgreSQL 9.4 packages before you can install BDR

The BDR RPMs cannot co-exist with stock PostgreSQL 9.4, and BDR does not share the same data directory as stock 9.4, so it will not be able to read your existing databases. (They will not be deleted, and uninstalling BDR then reinstalling stock PGDG 9.4 will get you access to them again, but it is strongly recommended that you dump them before installing BDR).

Once you have fully backed up all your databases:

      yum remove postgresql94\*
     

Check the list of packages to be removed carefully, approve the removal if appropriate, and proceed with the removal.

Your data directory for PostgreSQL 9.4 will still exist in /var/lib/pgsql/9.4 but will not be used while BDR is installed.

3.2.1.2.2. Install the BDR packages

To install the BDR-enabled PostgreSQL server, BDR extension, and the client programs, simply:

      sudo yum check-update
      sudo yum install postgresql-bdr94-bdr
     

Note: If you attempt to install this package when you already have postgresql94 installed from yum.postgresql.org, yum will report a conflict refuse to install it.

Once BDR is installed you will need to initdb a new database, make any required changes to postgresql.conf and pg_hba.conf, etc, as per any new PostgreSQL install. See /usr/share/doc/postgresql-bdr94/README.rpm-dist for details.

You can then proceed with BDR-specific configuration per Configuration Settings and Quick-start guide.

3.2.2. Debian or Ubuntu

Packages for Debian and Ubuntu are available from https://apt.2ndquadrant.com/.

3.2.2.1. Adding the BDR repository

To install BDR from DEBs you first need to add the BDR repository to your server.

First, install and enable the PostgreSQL apt repository for PGDG. This repository is required by the Debian BDR packages.

If not already present, install the apt-transport-https package:

      sudo apt-get install apt-transport-https
    

Next, create /etc/apt/sources.list.d/2ndquadrant.list with the repository URL below, changing wheezy to the codename of the Debian/Ubuntu version you are using, as obtained with lsb_release -c:

      deb https://apt.2ndquadrant.com/ wheezy-2ndquadrant main
    

Import the repository key, update the package lists, and start installing packages:

     sudo apt-get install curl ca-certificates
     curl https://apt.2ndquadrant.com/site/keys/9904CD4BD6BAF0C3.asc | sudo apt-key add -
     sudo apt-get update
    

3.2.2.2. Installing PostgreSQL 9.4 and BDR from packages for Debian or Ubuntu

3.2.2.2.1. Remove the postgresql-9.4 packages, if installed

Note: If you don't already have PostgreSQL 9.4 installed, simply skip this step.

BDR requires a patched version of PostgreSQL 9.4 that conflicts with the official packages. If you already have PostgreSQL 9.4 installed either from apt.postgresql.org or your official distribution repository, you will need to make a dump of all your databases, then uninstall the official PostgreSQL 9.4 packages before you can install BDR.

The BDR Debian packages cannot co-exist with stock PostgreSQL 9.4. However BDR uses the same data directory as stock 9.4, to ensure the compatibility with system utilities, so you should always first backup the existing instalation before trying to install the BDR PostgreSQL packages.

Once you have fully backed up all your databases:

      sudo apt-get remove postgresql-9.4
     

Check the list of packages to be removed carefully, approve the removal if appropriate, and proceed with the removal.

3.2.2.2.2. Install the BDR packages

To differentiate between the BDR specific packages and vanilla PostgreSQL packages all the package names start with postgresql-bdr instead of plain postgresql. So if you want to install the PostgreSQL package with BDR patches you should run:

      sudo apt-get update
      sudo apt-get install postgresql-bdr-9.4 postgresql-bdr-9.4-bdr-plugin
     

Note: If you attempt to install this package when you already have postgresql-9.4 installed you will get informed that the official package will be removed and confirmation will be required. Do not remove the old packages if you have existing data directory!

Once BDR is installed you will need to initdb a new database, make any required changes to postgresql.conf and pg_hba.conf, etc, as per any new PostgreSQl install. This works with standard system utilities like pg_createcluster.

You can then proceed with BDR-specific configuration per Configuration Settings and Quick-start guide.

3.2.3. Installing from packages on Windows

Windows is not supported at this time. There is no major technical barrier to doing so but it has not been a time allocation priority. See BDR requirements.