Results 1 to 8 of 8
  1. #1
    Join Date
    May 2011
    Posts
    10

    Unanswered: 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 01:51.

  2. #2
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    Just run the CREATE DATABASE statement twice.

  3. #3
    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.

  4. #4
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    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.

    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:

  5. #5
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    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.

    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

  6. #6
    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

  7. #7
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    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

  8. #8
    Join Date
    May 2011
    Posts
    10
    Thanks shammat,

    Thank you so much for your solution.

    -- Hiren Lad

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •