ERserver Debian Simple HOWTO

Ivailo T. Ivanov - Mag Studio - www.magstudio.net

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

Software you will need

  • SUN Java 2 SDK 1.4 - j2sdk1.4.2_01 - my version. It can be downloaded from sun.com website
  • Perl 5.005_04 or greater
  • GNU gcc 2.95.3 or greater
  • GNU make 3.79.1 or greater
  • PostgreSQL and postgresql-dev packages
  • eRServer 1.2 (of course)
  • libxerces-java 1.4.4-2 - this can be fetched with apt-get install libxerces-java

    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.

    Installation steps

    1. As root, copy the erserver archive into /usr/src.
    	cp erserver_v1.2.tar.gz /usr/src
    
    2. Unpack it:
    	tar xzf erserver_v1.2.tar.gz
    
    3. Then unlink the archive - you will no longer need it here:
    	rm erserver_v1.2.tar.gz
    
    4. 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/lib
    
    5. 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
    6. Change directories to /usr/src/erserver_v12 and run:
    	configure --with-pgincludes=/usr/include/postgresql
    
    7. 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_HOME
    
    8. Run make. It should run cleanly.
    	make 
    
    9. Run make install. The erserver program is now copied and almost ready to work.
    	make install
    
    10. 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'.

    Setup steps

    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/bin
    
    From 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=5432
    
    2. 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=test
    
    4. 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 start
    
    Make 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.