- Table of Contents
- 3.1. Slony-I Building & Installation
- 3.2. Modifying Things in a Replication Cluster
- 3.2.1. Adding a Table To Replication
- 3.2.2. How To Add Columns To a Replicated Table
- 3.2.3. How to remove replication for a node
- 3.2.4. Adding a Replication Node
- 3.2.5. Adding a Cascaded Replica
- 3.2.6. How do I use Log Shipping?
- 3.2.7. How To Remove Replication For a Node
- 3.2.8. Changing a Nodes Provider
- 3.2.9. Moving The Master From One Node To Another
- 3.3. Database Schema Changes (DDL)
- 3.4. Doing switchover and failover with Slony-I
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. Prebuilt binaries are available from the StackBuilder application included in the EnterpriseDB PostgreSQL installer
There are also RPM binaries available in the PostgreSQL YUM repository site for recent versions of Slony-I for recent versions of PostgreSQL.
This section discusses building Slony-I from source.
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.
PGMAIN=/usr/local/pgsql839-freebsd-2008-09-03 \ ./configure \ --with-pgconfigdir=$PGMAIN/bin gmake all; gmake install
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.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.
It is sufficient, for the purposes of building a usable build, to run configure --with-pgconfigdir=/some/path/somewhere, where /some/path/somewhere is the directory where the PostgreSQL program pg_config is located. Based on the output of pg_config, the configure script determines the various locations where PostgreSQL components are found, which indicate where the essential components of Slony-I must be installed.
For a full listing of configuration options, run the command ./configure --help.
Beware: configure defaults to permit indicating values for various paths, including "generic" values:
There are also PostgreSQL-specific options specified, which should not be expressly set, as pg_config should already provide correct values:
The compile of PostgreSQL must be expressly configured with the option --enable-thread-safety to provide correct client libraries.
Slony-I requires that the PostgreSQL server headers be installed. Some binary distributions of PostgreSQL include this is a a -dev package.
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.
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.
To start the build process, type
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.
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
Building Slony-I on Win32 with the Microsoft SDK (Visual Studio) is different than building Slony-I on other platforms. Visual Studio builds can be done with out involving configure or gmake. To build Slony-I you need
The Slony-I source from a source distribution tar (The distribution tar files contain pre-built copies of the parser and scanner generated files. The Win32 makefiles do not currently support building these).
PostgreSQL binaries, headers and libraries.
Visual Studio(2017 has been tested against the current version of Slony and PostgreSQL 10 x64). The Microsoft SDK 6.1 or Visual Studio 2008 had been tested against earlier versions (other versions might work).
To compile the Slony-I binaries you will need to
Set the environment variables PGSHARE,PG_INC,PG_LIB, PTHREADS_INC,PTHREADS_LIB, GETTEXT_LIB to point to the proper locations based on where these applications were installed. You will also need to set SLONY_VERSION to the version of slony you are building. The PGVER environment variable should be set the PostgreSQL MAJOR number of the PostgreSQL instance you are compiling against(8.4 , 9.1, etc..). For example
set PG_INC=c:\Postgresql\9.0\include set PG_LIB=c:\Postgresql\9.0\lib set PGSHARE=c:\\Postgresql\\9.0\\share set PTHREADS_INC=c:\pthreads-win32\include set PTHREADS_LIB=c:\pthreads-win32\lib set GETTEXT_LIB=c:\gettext\lib set GETTEXT_INC=c:\gettext\include set SLONY_VERSION=2.2.0 set PGVER=9.2
Note that the backslash characters must be escaped for PGSHARE as in the above example
From the Visual Studio or Microsoft Windows SDK command prompt run
cd src\backend nmake /f win32.mak slony1_funcs.%SLONY_VERSION%.dll cd ..\slon nmake /f win32.mak slon.exe cd ..\slonik nmake /f win32.mak slonik.exe
src\backend\slony1_funcs.$SLONY_VERSION.dll and any of the .sql files in src\backend need to be installed in your postgresql $share directory. The SQL files also need to be renamed to contain the slony version number in them. For example the slony1_funcs.sql should be renamed slony1_funcs.2.2.1.sql
copy slony1_base.sql c:\Program Files\Postgresql\9.1\share\slony1_base.2.2.0.sql copy slony1_base.v83.sql c:\Program Files\Postgresql\9.1\share\slony1_base.v18.104.22.168.sql copy slony1_base.v84.sql c:\Program Files\Postgresql\9.1\share\slony1_base.v22.214.171.124.sql copy slony1_funcs.sql c:\Program Files\Postgresql\9.1\share\slony1_funcs.2.2.0.sql copy slony1_funcs.v83.sql c:\Program Files\Postgresql\9.1\share\slony1_funcs.v126.96.36.199.sql copy slony1_funcs.v84.sql c:\Program Files\Postgresql\9.1\share\slony1_funcs.v188.8.131.52.sql
pthreadVC.dll or pthreadVC2.dll from the pthreads-win32 package also needs to be copied to the directory you install the slon.exe and slonik.exe binaries in. The Visual C++ redistributable might also be required.
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 older Red Hat systems (RHEL4 and below) See Bug 159382 (For RHEL) See the INSTALL file for a workaround for Fedora...
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
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.
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.3\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.3\bin> slon -addengine my_slon 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: