Start-up script for few clusters: just add water?

Started by Piotr Kublickialmost 16 years ago9 messagesgeneral
Jump to latest
#1Piotr Kublicki
Piotr.Kublicki@iop.org

Hi all,

I've installed Postgres with few instances/clusters, however I've got a
problem with start-up scripts for all clusters. As far as I know the file
postgresql should be modified in the /etc/sysconfig/pgsql directory. The
question is as follows:
Can I paste few clusters in this file? Currently I've got something like
this:

PGPORT=5566
PGDATA=/db/one_cluster

Such script will start only one cluster during server rebooting. Can I just
add more clusters in PGDATA in the file, something like this:

PGPORT=5566
PGDATA=/db/first_cluster
PGPORT=5567
PGDATA=/db/second_cluster
PGPORT=5568
PGDATA=/db/third_cluster

Will it work?

Thanks in advance, Eustace
--
View this message in context: http://old.nabble.com/Start-up-script-for-few-clusters%3A-just-add-water--tp28363883p28363883.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.

#2Scott Marlowe
scott.marlowe@gmail.com
In reply to: Piotr Kublicki (#1)
Re: Start-up script for few clusters: just add water?

On Mon, Apr 26, 2010 at 5:45 AM, Eustace Scrubb <piotr.kublicki@iop.org> wrote:

Hi all,

I've installed Postgres with few instances/clusters, however I've got a
problem with start-up scripts for all clusters. As far as I know the file
postgresql should be modified in the /etc/sysconfig/pgsql directory. The
question is as follows:
Can I paste few clusters in this file? Currently I've got something like
this:

This is all very dependent on how you installed pgsql and what OS
you're running. In debian / ubuntu it's trivial to add > 1 cluster.
In RHEL not so much. In solaris, windows, etc I'm not entirely sure.
Without knowing your OS it's hard to say.

#3Alvaro Herrera
alvherre@2ndquadrant.com
In reply to: Piotr Kublicki (#1)
Re: Start-up script for few clusters: just add water?

Eustace Scrubb wrote:

Such script will start only one cluster during server rebooting. Can I just
add more clusters in PGDATA in the file, something like this:

PGPORT=5566
PGDATA=/db/first_cluster
PGPORT=5567
PGDATA=/db/second_cluster
PGPORT=5568
PGDATA=/db/third_cluster

Will it work?

Certainly not. You could add a loop that sets the variables and calls
the start code, but it's new code you'd add, not just those lines above.

--
Alvaro Herrera http://www.CommandPrompt.com/
The PostgreSQL Company - Command Prompt, Inc.

#4Guillaume Lelarge
guillaume@lelarge.info
In reply to: Piotr Kublicki (#1)
Re: Start-up script for few clusters: just add water?

Le 26/04/2010 13:45, Eustace Scrubb a �crit :

[...]
I've installed Postgres with few instances/clusters, however I've got a
problem with start-up scripts for all clusters. As far as I know the file
postgresql should be modified in the /etc/sysconfig/pgsql directory. The
question is as follows:
Can I paste few clusters in this file? Currently I've got something like
this:

PGPORT=5566
PGDATA=/db/one_cluster

Such script will start only one cluster during server rebooting. Can I just
add more clusters in PGDATA in the file, something like this:

PGPORT=5566
PGDATA=/db/first_cluster
PGPORT=5567
PGDATA=/db/second_cluster
PGPORT=5568
PGDATA=/db/third_cluster

Will it work?

According to the /etc/sysconfig/pgsql directory you're talking about, I
suppose you are on Fedora.

You need to create one init.d script by cluster and one file in the
/etc/sysconfig/pgsql directory per cluster.

Suppose I have a second cluster. I'll have to do this :

cd /etc/init.d
cp postgresql postgresql2
cd /etc/sysconfig/pgsql
cp postgresql postgresql2
$EDITOR postgresql2

In $EDITOR, I'll change the different environment values I want. For
example:
PGPORT=5567
PGDATA=/db/second_cluster

If I need a third cluster, I will do the exact same step but give a
different name for the init.d script (and also the PostgreSQL sysconf
file, don't forget they need to have the exact same name).

--
Guillaume.
http://www.postgresqlfr.org
http://dalibo.com

#5Piotr Kublicki
Piotr.Kublicki@iop.org
In reply to: Guillaume Lelarge (#4)
Re: Start-up script for few clusters: just add water?

Hi Guillaume,

Excellent point:

Suppose I have a second cluster. I'll have to do this :

cd /etc/init.d
cp postgresql postgresql2
cd /etc/sysconfig/pgsql
cp postgresql postgresql2
$EDITOR postgresql2

In $EDITOR, I'll change the different environment values I want. For
example:

PGPORT=5567
PGDATA=/db/second_cluster

In such case the new created start-up script postgresql2 should not be
modified in the following line:

# Override defaults from /etc/sysconfig/pgsql if file is present
[ -f /etc/sysconfig/pgsql/${NAME} ] && . /etc/sysconfig/pgsql/${NAME}

export PGDATA
export PGPORT

Or it will automatically match-up names from both directories, i.e.:
/etc/init.d/postgresql will get variables from /etc/sysconfig/pgsql
/postgresql?

/etc/init.d/postgresql2 will get variables from /etc/sysconfig/pgsql
/postgresql2

Pete

From: Guillaume Lelarge <guillaume@lelarge.info>
To: Eustace Scrubb <piotr.kublicki@iop.org>
Cc: pgsql-general@postgresql.org
Date: 26/04/2010 22:18
Subject: Re: [GENERAL] Start-up script for few clusters: just add water?

Le 26/04/2010 13:45, Eustace Scrubb a écrit :

[...]
I've installed Postgres with few instances/clusters, however I've got a
problem with start-up scripts for all clusters. As far as I know the file
postgresql should be modified in the /etc/sysconfig/pgsql directory. The
question is as follows:
Can I paste few clusters in this file? Currently I've got something like
this:

PGPORT=5566
PGDATA=/db/one_cluster

Such script will start only one cluster during server rebooting. Can I

just

add more clusters in PGDATA in the file, something like this:

PGPORT=5566
PGDATA=/db/first_cluster
PGPORT=5567
PGDATA=/db/second_cluster
PGPORT=5568
PGDATA=/db/third_cluster

Will it work?

According to the /etc/sysconfig/pgsql directory you're talking about, I
suppose you are on Fedora.

You need to create one init.d script by cluster and one file in the
/etc/sysconfig/pgsql directory per cluster.

Suppose I have a second cluster. I'll have to do this :

cd /etc/init.d
cp postgresql postgresql2
cd /etc/sysconfig/pgsql
cp postgresql postgresql2
$EDITOR postgresql2

In $EDITOR, I'll change the different environment values I want. For
example:
PGPORT=5567
PGDATA=/db/second_cluster

If I need a third cluster, I will do the exact same step but give a
different name for the init.d script (and also the PostgreSQL sysconf
file, don't forget they need to have the exact same name).

--
Guillaume.
http://www.postgresqlfr.org
http://dalibo.com

This email (and attachments) are confidential and intended for the addressee(s) only. If you are not the intended recipient please notify the sender,
delete any copies and do not take action in reliance on it. Any views expressed are the author's and do not represent those of IOP, except where specifically
stated. IOP takes reasonable precautions to protect against viruses but accepts no responsibility for loss or damage arising from virus infection.
For the protection of IOP's systems and staff emails are scanned automatically.”

Institute of Physics Registered in England under Registration No 293851
Registered Office: 76/78 Portland Place, London W1B 1NT

#6Guillaume Lelarge
guillaume@lelarge.info
In reply to: Piotr Kublicki (#1)
Re: Start-up script for few clusters: just add water?

Le 28/04/2010 14:05, Piotr Kublicki a �crit :

Hi Guillaume,

Excellent point:

Suppose I have a second cluster. I'll have to do this :

cd /etc/init.d
cp postgresql postgresql2
cd /etc/sysconfig/pgsql
cp postgresql postgresql2
$EDITOR postgresql2

In $EDITOR, I'll change the different environment values I want. For
example:

PGPORT=5567
PGDATA=/db/second_cluster

In such case the new created start-up script postgresql2 should not be
modified in the following line:

# Override defaults from /etc/sysconfig/pgsql if file is present
[ -f /etc/sysconfig/pgsql/${NAME} ] && . /etc/sysconfig/pgsql/${NAME}

export PGDATA
export PGPORT

Or it will automatically match-up names from both directories, i.e.:
/etc/init.d/postgresql will run /etc/sysconfig/pgsql/postgresql?

/etc/init.d/postgresql2 will run /etc/sysconfig/pgsql/postgresql2

The latter. It will automatically match the script file name and the
config file name.

--
Guillaume.
http://www.postgresqlfr.org
http://dalibo.com

#7Piotr Kublicki
Piotr.Kublicki@iop.org
In reply to: Guillaume Lelarge (#6)
Re: Start-up script for few clusters: just add water?

Merci!

Pete

From: Guillaume Lelarge <guillaume@lelarge.info>
To: Piotr Kublicki <Piotr.Kublicki@iop.org>, pgsql-general
<pgsql-general@postgresql.org>
Date: 28/04/2010 15:04
Subject: Re: [GENERAL] Start-up script for few clusters: just add water?

Le 28/04/2010 14:05, Piotr Kublicki a écrit :

Hi Guillaume,

Excellent point:

Suppose I have a second cluster. I'll have to do this :

cd /etc/init.d
cp postgresql postgresql2
cd /etc/sysconfig/pgsql
cp postgresql postgresql2
$EDITOR postgresql2

In $EDITOR, I'll change the different environment values I want. For
example:

PGPORT=5567
PGDATA=/db/second_cluster

In such case the new created start-up script postgresql2 should not be
modified in the following line:

# Override defaults from /etc/sysconfig/pgsql if file is present
[ -f /etc/sysconfig/pgsql/${NAME} ] && . /etc/sysconfig/pgsql/${NAME}

export PGDATA
export PGPORT

Or it will automatically match-up names from both directories, i.e.:
/etc/init.d/postgresql will run /etc/sysconfig/pgsql/postgresql?

/etc/init.d/postgresql2 will run /etc/sysconfig/pgsql/postgresql2

The latter. It will automatically match the script file name and the
config file name.

--
Guillaume.
http://www.postgresqlfr.org
http://dalibo.com

This email (and attachments) are confidential and intended for the addressee(s) only. If you are not the intended recipient please notify the sender,
delete any copies and do not take action in reliance on it. Any views expressed are the author's and do not represent those of IOP, except where specifically
stated. IOP takes reasonable precautions to protect against viruses but accepts no responsibility for loss or damage arising from virus infection.
For the protection of IOP's systems and staff emails are scanned automatically.”

Institute of Physics Registered in England under Registration No 293851
Registered Office: 76/78 Portland Place, London W1B 1NT

#8Piotr Kublicki
Piotr.Kublicki@iop.org
In reply to: Guillaume Lelarge (#6)
Re: Start-up script for few clusters: just add water?

Guillaume Lelarge <guillaume@lelarge.info> wrote on 28/04/2010 15:04:07:

In such case the new created start-up script postgresql2 should not be
modified in the following line:

# Override defaults from /etc/sysconfig/pgsql if file is present
[ -f /etc/sysconfig/pgsql/${NAME} ] && . /etc/sysconfig/pgsql/${NAME}

export PGDATA
export PGPORT

Or it will automatically match-up names from both directories, i.e.:
/etc/init.d/postgresql will run /etc/sysconfig/pgsql/postgresql?

/etc/init.d/postgresql2 will run /etc/sysconfig/pgsql/postgresql2

The latter. It will automatically match the script file name and the
config file name.

Thanks again. By the way, if I want to start instances with few optional
arguments, as -S or -B where can I include these? In the same config file,
i.e. /etc/sysconfig/pgsql/postgresql (speaking about RedHat directories
structure)?

Pete

This email (and attachments) are confidential and intended for the addressee(s) only. If you are not the intended recipient please notify the sender,
delete any copies and do not take action in reliance on it. Any views expressed are the author's and do not represent those of IOP, except where specifically
stated. IOP takes reasonable precautions to protect against viruses but accepts no responsibility for loss or damage arising from virus infection.
For the protection of IOP's systems and staff emails are scanned automatically.”

Institute of Physics Registered in England under Registration No 293851
Registered Office: 76/78 Portland Place, London W1B 1NT

#9Guillaume Lelarge
guillaume@lelarge.info
In reply to: Piotr Kublicki (#8)
Re: Start-up script for few clusters: just add water?

Le 29/04/2010 10:40, Piotr Kublicki a �crit :

Guillaume Lelarge <guillaume@lelarge.info> wrote on 28/04/2010 15:04:07:

In such case the new created start-up script postgresql2 should not be
modified in the following line:

# Override defaults from /etc/sysconfig/pgsql if file is present
[ -f /etc/sysconfig/pgsql/${NAME} ] && . /etc/sysconfig/pgsql/${NAME}

export PGDATA
export PGPORT

Or it will automatically match-up names from both directories, i.e.:
/etc/init.d/postgresql will run /etc/sysconfig/pgsql/postgresql?

/etc/init.d/postgresql2 will run /etc/sysconfig/pgsql/postgresql2

The latter. It will automatically match the script file name and the
config file name.

Thanks again. By the way, if I want to start instances with few optional
arguments, as -S or -B where can I include these? In the same config file,
i.e. /etc/sysconfig/pgsql/postgresql (speaking about RedHat directories
structure)?

I don't think so. I suppose you will have to change the
/etc/init.d/postgresql script (or the one of your other instances).

--
Guillaume.
http://www.postgresqlfr.org
http://dalibo.com