This document will try to explain installation and running of ERserver (the PostgreSQL replication server) on Debian 3.0. If you have any other questions - contact me at ivo at magstudio.net Many thanks are going to Mr. Andrew Sullivan
You will need to manually download only j2sdk and erserver - the other things
can be fetched with apt-get.
Note: After installation of Java package make sure that you have in your PATH java and javac commands. Try java -version to see that you are using 1.4.2. You may have other JDKs.
cp erserver_v1.2.tar.gz /usr/src2. Unpack it:
tar xzf erserver_v1.2.tar.gz3. Then unlink the archive - you will no longer need it here:
rm erserver_v1.2.tar.gz4. Copy a good libxerces file, because the provided in package is broken (of course remove old one):
rm /usr/src/erserver_v1.2/java/lib/xerces.jar; cp /usr/share/java/xerces-1.4.4.jar /usr/src/erserver_v1.2/java/lib5. Edit the /usr/src/erserver_v12/Makefile adding the second line below to override CPPFLAGS.
CPPFLAGS := -I/usr/local/include $(CPPFLAGS) CPPFLAGS := -I/usr/include/postgresql/server $(CPPFLAGS)this is only for Debian
configure --with-pgincludes=/usr/include/postgresql7. Set the JAVA_HOME variable. This shows my case. Substitute the path of your java home.
JAVA_HOME=/usr/lib/j2se/j2sdk1.4.2_01; export JAVA_HOME8. Run make. It should run cleanly.
make9. Run make install. The erserver program is now copied and almost ready to work.
make install10. The last thing is to fix a very small bug in the perl library of the erserver. Edit the file /usr/local/erserver/lib/eRServer.pm and replace the string 'sprint' (without f) to 'sprintf'.
If you are accomplished everything - well done! Your erserver is ready to do some cool work! Now you can setup it. This won't actually be a 'piece of cake'.
I will explain a very simple situation:
Create two databases on your local PostgreSQL server, called 'master' and 'slave'. Change directories to :
/usr/local/erserver/binFrom now on this will be the current directory.
1. Run the following one line command. (Lines have been sliced for display).
./ers_setup --masterserver=localhost --masteruser=[your user for the master db] --masterpass=[your pass for the master db] --masterdb=master --masterport=5432 --pgsuperuser=[postgres superuser] --pgsuperpass=[postgres superuser password] --slaveserver=localhost --slaveuser=[your user for the slave db] --slavepass= [your password for the slave db]--slavedb=slave --slaveport=54322. Use psql master to create the test table, connect to the slave and create the same table there.
CREATE TABLE test(id serial, txt text); \c slave CREATE TABLE test(id serial, txt text);3. Then from the shell run:
ers_addtable --table=test4. Now you have to make an exact duplicate of the table 'test' on the slave. Dump the table from the master and recreate it on the slave to create the slave table with the new field _ers_uniq added. [Editor's note: Unclear when this column was added to the master table.]
5. Use psql slave and execute following query:
INSERT INTO _rserv_slave_tables_ SELECT 'test', '_ers_uniq', pc.oid, pa.attnum FROM pg_class pc, pg_attribute pa WHERE pc.relname='test' AND pa.attname='_ers_uniq' AND pa.attrelid=pc.oid;6. Exit to back to bash and run:
erserver ./ers_ctl startMake sure that it's running and execute some queries in the master database on table test, then see if they are repeated on the table test in slave database.
That's all. I [Ivailo] have done this document very fast so it is possible I missed something but I will improve the document when I have enough time. Anyway if there is something unclear - contact me! Editor's Note: Full sequence of steps were not tested therefore editing may have introduced errors. Contact elein to make corrections.