Setting up Bucardo

Bucardo is another popular logical replication engine that actually seems to have originated earlier than Slony, in 2002. Like Slony, it also uses triggers to perform its synchronization activity, but its syntax is much simpler. Furthermore, it also provides multimaster capabilities; this means that changes made in either the primary or secondary node will appear in both copies of a replicated table.

There is something to be said for tools that encourage simplicity when maintaining a complex high availability architecture. Let's explore Bucardo further.

Getting ready

The latest stable version of Bucardo at the time of writing this book is 4.5.0. Obtain the latest source package from the following URL:

http://bucardo.org/wiki/Bucardo

Bucardo is written in Perl, so it requires quite a few Perl-based prerequisites. On Debian-based systems, install them using the following apt-get commands:

sudo apt-get install libdbix-safe-perl libdbd-pg-perl
sudo apt-get install postgresql-plperl-9.3

Red-Hat-based systems require a bit more work. Install the EPEL package for your Red Hat platform from the following URL:

https://fedoraproject.org/wiki/EPEL

Then, install these RPMs with the following yum command:

sudo yum install perl-DBI perl-DBD-Pg perl-DBIx-Safe

Next, if it isn't installed already, download and install the PostgreSQL repository by installing the appropriate RPM from this URL:

http://yum.pgrpms.org/repopackages.php

Then, install the plperl PostgreSQL procedural language with this yum command:

sudo yum install postgresql93-plperl

How to do it...

For these instructions, 192.168.56.10 is the master PostgreSQL node, and 192.168.56.30 is our desired subscriber. Follow these instructions on both servers to install Bucardo:

  1. Extract the source code and change to the resulting directory with these commands:
    tar -xzf Bucardo-4.5.0.tar.gz
    cd Bucardo-4.5.0
    
  2. Build and install Bucardo with these commands as a root-capable user:
    Perl Makefile.PL
    make
    sudo make install
    
  3. Next, install Bucardo onto the database by executing the following command as the postgres user on both servers:
    bucardo_ctl install
    

Follow these steps only on the primary server that will be running the Bucardo service:

  1. Create a directory for Bucardo to store pid files with these commands as a root-capable user:
    sudo mkdir /var/run/bucardo
    sudo chown postgres:postgres /var/run/bucardo
    
  2. Add the postgres database from both PostgreSQL servers with these commands as the postgres user:
    bucardo_ctl add db postgres name=pg1 host=192.168.56.10
    bucardo_ctl add db postgres name=pg2 host=192.168.56.30
    
  3. Finally, start the Bucardo service by executing this command as the postgres user:
    bucardo_ctl start
    

How it works...

While Bucardo has a lot of prerequisites, its installation and configuration process is actually much easier. It also provides a proper daemon control utility in bucardo_ctl. As proof of this, the usual process of extracting and building the source code is the most time-consuming part. When Bucardo is installed on both servers, we merely have to invoke bucardo_ctl with the install parameter to finish the process.

When Bucardo is installed, it creates a user named bucardo and a database named bucardo. The bucardo user acts like the rep_user user we created for replication, so it must be a PostgreSQL superuser. As such, we need to ensure that we use a superuser for the User configuration setting during the installation process. This is why we recommend that you run the bucardo_ctl utility as postgres when possible. Here's what our installation screen looked like for the second node:

How it works...

Once we press P and hit Enter, Bucardo is installed. This means the only steps that remain involve starting the Bucardo service itself.

To do this, we need to prepare the /var/run/bucardo directory so that Bucardo can create files there. As we are going to launch it as the postgres user, the postgres system user needs to own that directory.

Next, we configure Bucardo itself by adding an internal alias for the postgres database on each server. The bucardo_ctl command has a lot of operation modes, but for now, all we need to do is add the postgres database with a different name for each host. After doing so, we can start Bucardo by calling bucardo_ctl with the start parameter. If everything goes well, we can call bucardo_ctl with the status parameter and see that it's running, as shown in the following screenshot:

How it works...

See also

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.191.62.122