Setup new cluster for Postgres DB

I wanted to switch over my data directory for postgres DB from the main partition to save some space. After doing some investigation – here’s what I did in order to achieve the results:

1. Create a new DB Cluster – this would setup the config files and directory structure to the required location

sudo pg_createcluster -d /var/db/postgres 9.1 custom

This would also setup a configuration named “custom” under the version 9.1. Now the directory /etc/postgresql/9.1 contains two directories – “main” and “custom”. The directories have their specific configuration files – so that the ports, data directories, etc can be setup for each of these configurations. The port number for the custom cluster will have default port 5433 (could be different if you had setup more clusters on the box) and the main cluster has default Postgres Port 5432.

2. To connect to the default cluster using the postgres user, type in

psql

3. To connect to the new custom cluster using postgres user, type in

psql -p5433

The changes that you make in either of these clusters will be independent of the other. This way – you can have two different clusters running on the same server and have their independent databases, data directories, port numbers, etc.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s