4. Slony-I Installation

Note: For Windows™ users: Unless you are planning on hacking the Slony-I code, it is highly recommended that you download and install a prebuilt binary distribution and jump straight to the configuration section below. There are likely to be links and/or binaries at pgFoundry Slony-I site for official releases, the first of which is expected to be Slony-I version 1.2.0.

There are also RPM binaries available at that site for recent versions of Slony-I for recent versions of PostgreSQL.

Warning

If you need Slony-I to do an upgrade from some elderly version of PostgreSQL to a newer version, or if you need a late-breaking CVS version, outside the context of a major release, then be prepared to need to build both PostgreSQL and Slony-I from source. The remainder of this section assumes this...

You should have obtained the Slony-I source from the previous step. Unpack it.

gunzip slony.tar.gz;
tar xf slony.tar

This will create a directory under the current directory with the Slony-I sources. Head into that that directory for the rest of the installation procedure.

4.1. Short Version

PGMAIN=/usr/local/pgsql746-freebsd-2005-04-01 \
./configure \
    --with-pgconfigdir=$PGMAIN/bin
gmake all; gmake install

4.2. Configuration

Slony-I normally needs to be built and installed by the PostgreSQL Unix user. The installation target must be identical to the existing PostgreSQL installation particularly in view of the fact that several Slony-I components represent libraries and SQL scripts that need to be in the Slony-I lib and share directories.

The first step of the installation procedure is to configure the source tree for your system. This is done by running the configure script. In early versions, configure needed to know where your PostgreSQL source tree is, which was done with the --with-pgsourcetree= option. As of version 1.1, this is no longer necessary, as Slony-I has included within its own code base certain parts needed for platform portability. It now only needs to make reference to parts of PostgreSQL that are actually part of the installation. Therefore, Slony-I is configured by pointing it to the various PostgreSQL library, binary, and include directories. For a full list of these options, use the command ./configure --help.

Normally, it ought to be sufficient to run configure --with-pgconfigdir=/some/path/somewhere, where /some/path/somewhere is the place where the PostgreSQL program pg_config is located. From pg_config, the configure script can determine the various locations where PostgreSQL components are found, which indicates where the essential components of Slony-I must be installed.

On certain platforms (AIX and Solaris are known to need this; Linux does not), the compile of PostgreSQL must be expressly configured with the option --enable-thread-safety to provide correct client libraries.

PostgreSQL version 8 installs the server header #include files by default; with version 7.4 and earlier, you need to make sure that the build installation included doing make install-all-headers, otherwise the server headers will not be installed, and Slony-I will be unable to compile.

After running configure, you may wish to review the file Makefile.global to ensure it is looking in the right places for all of the components.

4.3. Example

After determining that the PostgreSQL instance to be used is installed in /opt/dbs/pgsql746-aix-2005-04-01:

PGMAIN=/opt/dbs/pgsql746-aix-2005-04-01 \
./configure \
    --with-pgconfigdir=$PGMAIN/bin 

The configure script will run a number of tests to guess values for various dependent variables and try to detect some quirks of your system. Slony-I is known to need a modified version of libpq on specific platforms such as Solaris2.X on SPARC. The patch for libpq version 7.4.2 can be found at http://developer.postgresql.org/~wieck/slony1/download/threadsafe-libpq-742.diff.gz Similar patches may need to be constructed for other versions; see the FAQ entry on thread safety .

For a full listing of configuration options, run the command ./configure --help.

4.4. Build

To start the build process, type

gmake all

Be sure to use GNU make; on BSD systems, it is called gmake; on Linux, GNU make is typically the "native" make, so the name of the command you type in may be either make or gmake. On other platforms, you may need additional packages or even install GNU make from scratch. The build may take anywhere from a few seconds to 2 minutes depending on how fast your hardware is at compiling things. The last line displayed should be

All of Slony-I is successfully made. Ready to install.

4.5. Installing Slony-I Once Built;

To install Slony-I, enter gmake install

This will install files into the postgresql install directory as specified by the configure --prefix option used in the PostgreSQL installation. Make sure you have appropriate permissions to write into that area. Commonly you need to do this either as root or as the postgres user.

The main list of files installed within the PostgreSQL instance is:

The .sql files are not fully substituted yet. And yes, both the 7.3 and the 7.4 files get installed on every system, irrespective of its version. The slonik admin utility does namespace/cluster substitutions within these files, and loads the files when creating replication nodes. At that point in time, the database being initialized may be remote and may run a different version of PostgreSQL than that of the local host.

At the very least, the two shared objects installed in the $libdir directory must be installed onto every computer that is supposed to become a Slony-I node. (Other components may be able to be loaded remotely from other hosts.)

4.6. Building Documentation: Admin Guide

The document you are reading now is a fairly extensive "Administrator's Guide" containing what wisdom has been discovered and written down about the care and feeding of Slony-I.

This is only built if you specify --with-docs

Note that you may have difficulty building the documentation on Red Hat-based systems due to NAMELEN being set way too low. Havoc Pennington opened a bug on this back in mid-2001, back in the days of Red Hat 7.1; Red Hat Software has assigned the bug, but there does not appear to have been much progress since then. The second URL below indicates that there is intent to address the issue by bumping up the value of NAMELEN in some future release of Red Hat Enterprise Linux, but that won't likely help you in 2005. Fedora Core 4 should have the issue addressed somewhat sooner.

Bug 36058

Bug 159382 (For RHEL)

A pre-built copy of the "admin guide" should be readily available, either in the form of a separate tarball nearby, or in the directory doc/adminguide/prebuilt

See the INSTALL file for a workaround for Fedora...

4.7. Installing Slony-I from RPMs

Even though Slony-I can be compiled and run on most Linux distributions, it is also possible to install Slony-I using binary packages. Slony Global Development Team provides official RPMs and SRPMs for many versions or Red Hat ana Fedora Core.

The RPMs are available at Slony-I at pgFoundry.org. Please read CURRENT_MAINTAINER file for the details of the RPMs. Please note that the RPMs will look for RPM installation of PostgreSQL, so if you install PostgreSQL from source, you should manually ignore the RPM dependencies related to PostgreSQL.

Installing Slony-I using these RPMs is as easy as installing any RPM.

rpm -ivh postgresql-slony1-engine-....rpm

If you want to upgrade the previous version, just use rpm -Uvh to upgrade it. But please remember to follow the usual upgrade procedure, too.

The RPM installs the files into their usual places. The configuration files are installed under /etc, the binary files are installed in /usr/bin, libraries are installed in /usr/lib/pgsql, and finally the docs are installed in /usr/share/doc/postgresql-slony1-engine.

4.8. Installing the Slony-I service on Windows

On Windows™ systems, instead of running one slon daemon per node, a single slon service is installed which can then be controlled through the Services control panel applet, or from a command prompt using the net command.

C:\Program Files\PostgreSQL\8.0\bin> slon -regservice my_slon
Service registered.
Before you can run Slony, you must also register an engine!

WARNING! Service is registered to run as Local System. You are
encouraged to change this to a low privilege account to increase
system security. 

Once the service is installed, individual nodes can be setup by registering slon configuration files with the service.

C:\Program Files\PostgreSQL\8.0\bin> slon -addengine c:\node1.conf
Engine added.

Other, self explanatory commands include slon -unregservice <service name>, slon -listengines <service name> and slon -delengine <service name> <config file>.