Tuesday, June 4, 2013

Setting up everything at one time

While developping pgpool-II 3.3, I created a small script to make developer's life a little bit easier. However, the tool might be useful for PostgreSQL/pgpool-II beginners. So I decided to introduce it in my blog.

Disclaimer: the environment created by the tool below should never be used for production.

The script is called "pgpool_setup". It creates followings by just one command under current directory. The directory must be empty. PostgreSQL and pgpool binaries must be installed and in your command search path beforehand.

PostgreSQL clusters. You can choose "streaming replication mode" or "native replication mode". The former you already know, I assume. The latter is just a set of identical PostgreSQL clusters except the port numbers are different.

If you choose streaming replication mode, one primary server and standby servers are ready after the command runs (even with WAL archival is enabled).

By default those PostgreSQL cluster port number start from 11000 and continues 11001, 11002 and so on.

The port numbers of pgpool and pcp follow.

One pgpool server, with failover/online recovery/followmaster command are all set.

A test database "test" is created.

pcp commands(which are for pgpool administrator) account and password are ready for you.

By running pgpool_setup, you are ready to start pgpool and PostgreSQL with complete settings (at least for testing pupose) on your computer. I use this tool to create multiple groups of pgpool+PostgreSQL set on my laptop.