If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > PostgreSQL > How to create two different postgresql services for configure database.. ??

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-06-11, 00:47
hirenlad hirenlad is offline
Registered User
 
Join Date: May 2011
Posts: 10
How to create two different postgresql services for configure database.. ??

Hello,
I want to create two different services using two different batch file to configure two different databases. And both services will active for respective databases. Is it possible ??? If yes then how ??

-- Hiren Lad

Last edited by hirenlad; 09-06-11 at 00:51.
Reply With Quote
  #2 (permalink)  
Old 09-06-11, 04:25
shammat shammat is offline
Registered User
 
Join Date: Nov 2003
Posts: 2,408
Just run the CREATE DATABASE statement twice.
Reply With Quote
  #3 (permalink)  
Old 09-07-11, 01:07
hirenlad hirenlad is offline
Registered User
 
Join Date: May 2011
Posts: 10
Quote:
Originally Posted by shammat View Post
Just run the CREATE DATABASE statement twice.
Thanks shammat for reply
May be you did not get my question.
I want to run multiple instance of postgresql in one machine.. Is it possible ?

I had tried to create two services on two different ports, like one is on 5432 and another one is 5433. The service on port 5432 get started and work correctly but the service on port 5433 get registered but not started and produced error like " The service did not report an error ".

-- Hiren Lad.
Reply With Quote
  #4 (permalink)  
Old 09-07-11, 02:35
shammat shammat is offline
Registered User
 
Join Date: Nov 2003
Posts: 2,408
Quote:
Originally Posted by hirenlad View Post
I want to run multiple instance of postgresql in one machine.. Is it possible ?
Yes that is possible.

Quote:
I had tried to create two services on two different ports, like one is on 5432 and another one is 5433. The service on port 5432 get started and work correctly but the service on port 5433 get registered but not started and produced error like " The service did not report an error ".
Did you create a second data directory using initdb for the second service?

This is a rough sketch of installing two services:

For the first one:

1) initdb c:\Data\Postgres1
2) pg_ctl register -N pg1 -U postgres -P somepassword -D c:\Data\Postgres1 -o "-p 5432"
3) net start pg1

For the second one

1) initdb c:\Data\Postgres2
2) Edit c:\Data\Postgres2\postgresql.conf and change the port number to 5433
2) pg_ctl register -N pg2 -U postgres -P somepassword -D c:\Data\Postgres2
3) net start pg2

As an alternative to editing postgresql.conf you could also specify the port number when registering the service, but putting it into .conf is more reliable. See the manual for initdb and pg_ctl for more details

Note that the username (postgres) and the password relate to the Windows user, not the database user.

Very important: you have to run initdb as that postgres (Windows) user otherwise the permissions on the data directory are not correct.

This is all very well documented in the manual:
Reply With Quote
  #5 (permalink)  
Old 09-07-11, 02:37
shammat shammat is offline
Registered User
 
Join Date: Nov 2003
Posts: 2,408
Quote:
Originally Posted by hirenlad View Post
I want to run multiple instance of postgresql in one machine.. Is it possible ?
Yes that is possible.

Quote:
I had tried to create two services on two different ports, like one is on 5432 and another one is 5433. The service on port 5432 get started and work correctly but the service on port 5433 get registered but not started and produced error like " The service did not report an error ".
Did you create a second data directory using initdb for the second service?

This is a rough sketch of installing two services:

For the first one:

1) initdb c:\Data\Postgres1
2) pg_ctl register -N pg1 -U postgres -P somepassword -D c:\Data\Postgres1 -o "-p 5432"
3) net start pg1

For the second one

1) initdb c:\Data\Postgres2
2) Edit c:\Data\Postgres2\postgresql.conf and change the port number to 5433
2) pg_ctl register -N pg2 -U postgres -P somepassword -D c:\Data\Postgres2
3) net start pg2

As an alternative to editing postgresql.conf you could also specify the port number when registering the service, but putting it into .conf is more reliable. See the manual for initdb and pg_ctl for more details

Note that the username (postgres) and the password relate to the Windows user, not the database user.

Very important: you have to run initdb as the Windows Postgres user (or whichever you specify for registering the service) otherwise the permissions on the data directory are not correct and you'll get strange errors during startup (maybe that's your current problem already)


This is all very well documented in the manual:

http://www.postgresql.org/docs/curre...pp-pg-ctl.html
http://www.postgresql.org/docs/curre...pp-initdb.html
Reply With Quote
  #6 (permalink)  
Old 09-07-11, 02:59
hirenlad hirenlad is offline
Registered User
 
Join Date: May 2011
Posts: 10
Thanks shammat for reply.

We used your alternative solution instead of editing postsql.conf, we specify the port number when registering the service. Because all these we have to done in application setup without user interaction. So weather this solution is reliable or not ??

-- Hiren Lad
Reply With Quote
  #7 (permalink)  
Old 09-07-11, 03:44
shammat shammat is offline
Registered User
 
Join Date: Nov 2003
Posts: 2,408
Quote:
Originally Posted by hirenlad View Post
We used your alternative solution instead of editing postsql.conf, we specify the port number when registering the service. Because all these we have to done in application setup without user interaction. So weather this solution is reliable or not
Should not be a problem. The only drawback is that if the server is started manually using pg_ctl one has to remember to supply the port number each time, but it that is not a problem, that method should be reliable
Reply With Quote
  #8 (permalink)  
Old 09-07-11, 03:47
hirenlad hirenlad is offline
Registered User
 
Join Date: May 2011
Posts: 10
Thanks shammat,

Thank you so much for your solution.

-- Hiren Lad
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On