Skip site navigation (1) Skip section navigation (2)

Re: Another Data directory for second database - feasible?

From: Chris Browne <cbbrowne(at)acm(dot)org>
To: pgsql-admin(at)postgresql(dot)org
Subject: Re: Another Data directory for second database - feasible?
Date: 2005-04-22 18:44:00
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-admin
htomeh(at)firstam(dot)com ("Tomeh, Husam") writes:
> I have a postgres installation with one database on a server. I'd need
> to create another database; however, I'm curious if there's a way to
> create the second database in a different directory than the existing
> one. Is that feasible and how? Or does postgres only point to one data
> directory?  Thanks in advance.

We have plenty of servers with multiple databases, handled in just
this fashion.

At the simplest level, it involves running initdb three times, on
three directories:

$ initdb -D /opt/DB1
$ initdb -D /opt/DB2
$ initdb -D /opt/DB3
$ vi /opt/DB?/postgresql.conf
[change port numbers for each]
$ for db in 1 2 3; do
  pg_ctl -D /opt/DB$db start

You probably want to set up some set of "init" scripts that manage
telling the instances where to stow log files and such, and which can
be auto-started upon system bootup.

One of my coworkers has built a really nice init script that's good at
building the directory structure where the DBs will be stowed, hence...

$ vi
[modify config]
$ ./ mkdir
[builds directory structure]
$ ./ initdb
[runs initdb for you]
$ ./ start

At one point, he was trying to come up with a way of releasing it to
the community; hopefully poking Drew can lead to that coming
available, someday...
(format nil "~S(at)~S" "cbbrowne" "")
Rules of the Evil Overlord #78.  "I will not tell my Legions of Terror
"And he must  be taken alive!" The command will be:  ``And try to take
him alive if it is reasonably practical.''"

In response to


pgsql-admin by date

Next:From: Michelle KonzackDate: 2005-04-22 20:11:56
Subject: Re: Another Data directory for second database - feasible?
Previous:From: Bruno Wolff IIIDate: 2005-04-22 17:23:07
Subject: Re: Reindex from command line linux

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group