Обсуждение: starting postgres with several Data directories

Поиск
Список
Период
Сортировка

starting postgres with several Data directories

От
Julius T
Дата:
Hello, pgsql guru

I have windows version of postgres 8.4 for experiments.
At first - what I have done so far:
1. Copied content of Data directory to Data2
2. Changed the port to 5433 in Data2\postgresql.conf
3. Started postgres from commant prompt like (F:/Program
Files/PostgreSQL/8.4/bin/pg_ctl.exe start -N "postgresql-8.42" -D
"F:/Program Files/PostgreSQL/8.4/data2" -w)
4. Started service of postgres (witch uses Data directory).
5. Test the connection with PgAdmin. Connection OK. Inserting into table of
one server instance doesn't effect second one. Everything seems to work OK.

I wanted to ask if it is OK to start several instances of postgres pointing
to different data directories? I guess thats what the data directories are
after all, but because I failed to find some assurance while google'ing I'm
asking the question. It would be a crying shame to ruin production DB
because of experimental stuff. :)

Thank you in advance.

Julius Tuskenis



Re: starting postgres with several Data directories

От
Scott Marlowe
Дата:
On Mon, Dec 21, 2009 at 1:46 PM, Julius T <julius@nsoft.lt> wrote:
> Hello, pgsql guru
>
> I have windows version of postgres 8.4 for experiments.
> At first - what I have done so far:
> 1. Copied content of Data directory to Data2
> 2. Changed the port to 5433 in Data2\postgresql.conf
> 3. Started postgres from commant prompt like (F:/Program
> Files/PostgreSQL/8.4/bin/pg_ctl.exe start -N "postgresql-8.42" -D
> "F:/Program Files/PostgreSQL/8.4/data2" -w)
> 4. Started service of postgres (witch uses Data directory).
> 5. Test the connection with PgAdmin. Connection OK. Inserting into table of
> one server instance doesn't effect second one. Everything seems to work OK.
>
> I wanted to ask if it is OK to start several instances of postgres pointing
> to different data directories? I guess thats what the data directories are
> after all, but because I failed to find some assurance while google'ing I'm
> asking the question. It would be a crying shame to ruin production DB
> because of experimental stuff. :)

Yes, it's fine.  Make a different data dir, point the postgresql.conf
gile to a different tcp port and off ya go.  I do it all the time to
test slony setup at work.

Re: starting postgres with several Data directories

От
Scott Mead
Дата:

On Mon, Dec 21, 2009 at 4:17 PM, Scott Marlowe <scott.marlowe@gmail.com> wrote:


Yes, it's fine.  Make a different data dir, point the postgresql.conf
gile to a different tcp port and off ya go.  I do it all the time to
test slony setup at work.

Agreed, I've actually used it for a couple of different reasons, including production in a couple of different architectures, no worries about it, other than making sure you have enough memory on the box to support them all, along with the remembering which instance you're logged into at a given time :)

--Scott

Re: starting postgres with several Data directories

От
Scott Marlowe
Дата:
On Mon, Dec 21, 2009 at 2:26 PM, Scott Mead
<scott.lists@enterprisedb.com> wrote:
>
> On Mon, Dec 21, 2009 at 4:17 PM, Scott Marlowe <scott.marlowe@gmail.com>
> wrote:
>>
>>
>> Yes, it's fine.  Make a different data dir, point the postgresql.conf
>> gile to a different tcp port and off ya go.  I do it all the time to
>> test slony setup at work.
>
> Agreed, I've actually used it for a couple of different reasons, including
> production in a couple of different architectures, no worries about it,
> other than making sure you have enough memory on the box to support them
> all, along with the remembering which instance you're logged into at a given
> time :)

Yeah, I create a different "admin" account for each one, that has the
PGPORT and stuff already set, and setup pg_hba.conf to reject the
admin accounts from other instances so I don't do anything too stupid.

Re: starting postgres with several Data directories

От
Scott Mead
Дата:
On Mon, Dec 21, 2009 at 4:35 PM, Scott Marlowe <scott.marlowe@gmail.com> wrote:
On Mon, Dec 21, 2009 at 2:26 PM, Scott Mead
<scott.lists@enterprisedb.com> wrote:
>
> On Mon, Dec 21, 2009 at 4:17 PM, Scott Marlowe <scott.marlowe@gmail.com>
> wrote:
>>


Yeah, I create a different "admin" account for each one, that has the
PGPORT and stuff already set, and setup pg_hba.conf to reject the
admin accounts from other instances so I don't do anything too stupid.

The other useful trick is to change set your psql prompt (via .psqlrc) so that it shows which port the db you're logged into is listening on:

\set PROMPT1 '%/:%>=%# '

This will give you a prompt of:

postgres:5432=#

Take a look at http://www.postgresql.org/docs/8.3/static/app-psql.html for more prompt options.


--Scott


Re: starting postgres with several Data directories

От
Julius Tuskenis
Дата:
Thank you, Scott & Scott :)

I appreciate your help.

--
Julius Tuskenis
Programavimo skyriaus vadovas
UAB nSoft
mob. +37068233050