Multiple Postgres Instances

Started by David Giffinabout 27 years ago4 messagesgeneral
Jump to latest
#1David Giffin
david@agent911.com

Hello,

I'm trying to run postgres on two different post 5432 and port 5433 with
different data directories for each instance:

[ -x /usr/local/pgsql/bin/postmaster ] && {
su -l postgres -c '/usr/local/pgsql/bin/postmaster -S -i'
echo -n ' pgsql'
}

[ -x /usr/local/pgsql/bin/postmaster ] && {
su -l postgres -c '/usr/local/pgsql/bin/postmaster
-D/usr/local/pgsql/data_5433 -p5433 -S -i'
echo -n ' pgsql'
}

But when I do a psql -p 5433 and drop a table it seems to drop in both
instances. If anyone has attempted this before I like to hear how it
worked.

David

#2Jeff Hoffmann
jeff@remapcorp.com
In reply to: David Giffin (#1)
Re: [GENERAL] Multiple Postgres Instances

David Giffin wrote:

Hello,

I'm trying to run postgres on two different post 5432 and port 5433 with
different data directories for each instance:

[ -x /usr/local/pgsql/bin/postmaster ] && {
su -l postgres -c '/usr/local/pgsql/bin/postmaster -S -i'
echo -n ' pgsql'
}

[ -x /usr/local/pgsql/bin/postmaster ] && {
su -l postgres -c '/usr/local/pgsql/bin/postmaster
-D/usr/local/pgsql/data_5433 -p5433 -S -i'
echo -n ' pgsql'
}

But when I do a psql -p 5433 and drop a table it seems to drop in both
instances. If anyone has attempted this before I like to hear how it
worked.

David

just a guess on my part, but i think what you're going to want to do is
set the PG_DATA environment variable to /usr/local/pgsql/data_5433 in
your script before you start the second instance. they screwed around
with the ability to specify absolute paths to the data directory in
6.4.x and didn't document it, so i'm not sure what the truth is about
it. i'm not sure if that's what is causing the problem in _this case_,
but it has happened with other cases. (it makes good sense to require
you to use environment variables in all cases, as far as i'm
concerned.) i submitted some doc patches, but apparently they haven't
shown up yet.

again, this is just a guess, but an educated one.

jeff

jeff@remapcorp.com

#3Alex P. Rudnev
alex@Relcom.EU.net
In reply to: Jeff Hoffmann (#2)
Re: [GENERAL] Multiple Postgres Instances

Looks like you are running two PSQL server with THE SAME DATA BASE
DIRECTORY!

On Thu, 21 Jan 1999, Jeff Hoffmann wrote:

Date: Thu, 21 Jan 1999 08:46:56 -0600
From: Jeff Hoffmann <jeff@remapcorp.com>
To: David Giffin <david@agent911.com>
Cc: pgsql-general@hub.org
Subject: Re: [GENERAL] Multiple Postgres Instances

David Giffin wrote:

Hello,

I'm trying to run postgres on two different post 5432 and port 5433 with
different data directories for each instance:

[ -x /usr/local/pgsql/bin/postmaster ] && {
su -l postgres -c '/usr/local/pgsql/bin/postmaster -S -i'
echo -n ' pgsql'
}

[ -x /usr/local/pgsql/bin/postmaster ] && {
su -l postgres -c '/usr/local/pgsql/bin/postmaster
-D/usr/local/pgsql/data_5433 -p5433 -S -i'
echo -n ' pgsql'
}

But when I do a psql -p 5433 and drop a table it seems to drop in both
instances. If anyone has attempted this before I like to hear how it
worked.

David

just a guess on my part, but i think what you're going to want to do is
set the PG_DATA environment variable to /usr/local/pgsql/data_5433 in
your script before you start the second instance. they screwed around
with the ability to specify absolute paths to the data directory in
6.4.x and didn't document it, so i'm not sure what the truth is about
it. i'm not sure if that's what is causing the problem in _this case_,
but it has happened with other cases. (it makes good sense to require
you to use environment variables in all cases, as far as i'm
concerned.) i submitted some doc patches, but apparently they haven't
shown up yet.

again, this is just a guess, but an educated one.

jeff

jeff@remapcorp.com

Aleksei Roudnev, Network Operations Center, Relcom, Moscow
(+7 095) 194-19-95 (Network Operations Center Hot Line),(+7 095) 230-41-41, N 13729 (pager)
(+7 095) 196-72-12 (Support), (+7 095) 194-33-28 (Fax)

#4David Giffin
david@agent911.com
In reply to: Jeff Hoffmann (#2)
Re: [GENERAL] Multiple Postgres Instances

It looks like the .profile and /etc/profile were overriding the -D option.
I set the profile to this:

PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/bin:/usr/local/pgsql/bin
MANPATH=:/usr/local/pgsql/bin
PGLIB=/usr/local/pgsql/lib
# note: PGDATA overwrites the -D startup option
# PGDATA=/usr/local/pgsql/data

I also had to take the PGDATA value out of the /etc/profile (I had it set
there because most of the users on the system are database users). Then
changed the rc script to this:

[ -x /usr/local/pgsql/bin/postmaster ] && {
su -l postgres -c '/usr/local/pgsql/bin/postmaster -p5432 -D
/usr/local/pgsql/data_5432 -S -i'
echo -n ' pgsql 5432'
}
[ -x /usr/local/pgsql/bin/postmaster ] && {
su -l postgres -c '/usr/local/pgsql/bin/postmaster -p5433 -D
/usr/local/pgsql/data_5433 -S -i'
echo -n ' pgsql 5433'
}

Presto! Everything seems to be working! Thanks for the suggestions!

David

On Thu, 21 Jan 1999, Jeff Hoffmann wrote:

Show quoted text

David Giffin wrote:

Hello,

I'm trying to run postgres on two different post 5432 and port 5433 with
different data directories for each instance:

[ -x /usr/local/pgsql/bin/postmaster ] && {
su -l postgres -c '/usr/local/pgsql/bin/postmaster -S -i'
echo -n ' pgsql'
}

[ -x /usr/local/pgsql/bin/postmaster ] && {
su -l postgres -c '/usr/local/pgsql/bin/postmaster
-D/usr/local/pgsql/data_5433 -p5433 -S -i'
echo -n ' pgsql'
}

But when I do a psql -p 5433 and drop a table it seems to drop in both
instances. If anyone has attempted this before I like to hear how it
worked.

David

just a guess on my part, but i think what you're going to want to do is
set the PG_DATA environment variable to /usr/local/pgsql/data_5433 in
your script before you start the second instance. they screwed around
with the ability to specify absolute paths to the data directory in
6.4.x and didn't document it, so i'm not sure what the truth is about
it. i'm not sure if that's what is causing the problem in _this case_,
but it has happened with other cases. (it makes good sense to require
you to use environment variables in all cases, as far as i'm
concerned.) i submitted some doc patches, but apparently they haven't
shown up yet.

again, this is just a guess, but an educated one.

jeff

jeff@remapcorp.com