Slony-I Installation

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.


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/pgsql839-freebsd-2008-09-03 \
./configure \
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. Since version 1.1, this has not been 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 versions from 8.0 onwards install the server header #include files by default; with version 7.4 and earlier, you needed 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 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 \

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. A patch for libpq version 7.4.2 can be found at 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, for versions of Slony-I up to 1.2.x:

  • $bindir/slon

  • $bindir/slonik

  • $libdir/slony1_funcs$(DLSUFFIX)

  • $libdir/xxid($DLSUFFIX)

  • $datadir/slony1_base.sql

  • $datadir/slony1_base.v73.sql

  • $datadir/slony1_base.v74.sql

  • $datadir/slony1_base.v80.sql

  • $datadir/slony1_funcs.sql

  • $datadir/slony1_funcs.v73.sql

  • $datadir/slony1_funcs.v74.sql

  • $datadir/slony1_funcs.v80.sql

(Note that as things have change, the list of version-specific files has tended to grow...)

The .sql files are not fully substituted yet. And yes, versions for all supported versions of PostgreSQL (e.g. - such as 7.3, 7.4 8.0) 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.)

In Slony-I version 2.0, this changes:

  • $bindir/slon

  • $bindir/slonik

  • $libdir/slony1_funcs$(DLSUFFIX)

  • $datadir/slony1_base.sql

  • $datadir/slony1_funcs.sql

Note: Note the loss of - the txid data type introduced in PostgreSQL 8.3 makes it obsolete.

Note: Slony-I 2.0 gives up compatibility with versions of PostgreSQL prior to 8.3, and hence "resets" the version-specific base function handling. There may be function files for version 8.3, 8.4, and such, as replication-relevant divergences of PostgreSQL functionality take place.

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 may not help you if you are using an elder version where this will never be rectified. Current Fedora releases have already addressed this issue.

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 and Fedora .

The RPMs are available at PostgreSQL RPM Repository. Please read the howto provided in the website for configuring yum to use that repository. 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.

yum install slony1

yum will pick up dependencies. This repository provides Slony-I binaries built against every supported PostgreSQL version.

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/slony1.

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>.

For further information about the Windows™ port, you may want to see the following URLs: