Results 1 to 9 of 9
  1. #1
    Join Date
    Aug 2009
    Posts
    17

    install postgre service manually

    hello,
    I need to use postgre on a desktop application, and I need to install the service manually and use another port than the standard "5432" to prevent a conflict

    please advice how I can do that with setup tools or without them

    Thanks

  2. #2
    Join Date
    Nov 2003
    Posts
    2,817
    This can be done by calling pg_ctl using the -register parameter.

    The port can specified when running initdb and is then put into postgresql.conf so so you don't really need to specify it for the service. But you can also specify the port with the -o option

    Details are here:
    http://www.postgresql.org/docs/current/static/app-pg-ctl.html

    But you don't really need a service, you can start the postgres server by simply running pg_ctl directly when you startup the application:
    Code:
    pg_ctl -o "-p 5433 -D \path\to\datadir" start

  3. #3
    Join Date
    Aug 2009
    Posts
    17
    This is a great answer,
    How I can thank you ??

    Appreciate your help

    one question, is there a way to bypass firewalls like kaspersky to prevent closing of the port ?
    Last edited by isaac_cm; 08-11-09 at 07:44.

  4. #4
    Join Date
    Nov 2003
    Posts
    2,817
    Quote Originally Posted by isaac_cm
    one question, is there a way to bypass firewalls like kaspersky to prevent closing of the port ?
    I don't think so although probably some virus hacker would be able to do that

    It is possible to run Postgres completely without it listening on a port. It will then only allow connections through Unix-domain sockets, but I don't believe this will work on Windows. Nor would I know how to use it.

    Edit: I have a set of batch files that automatically initialize a Postgres database and start the server from the commandline without a service. I created them to quickly setup a development server ("Postgres to go"). They are using the binary ZIP distribution from EnterpriseDB and not the installer

    If you are interested, I can post those files here.

  5. #5
    Join Date
    Aug 2009
    Posts
    17
    sure, plz do, but why only for developing, is there a problem to use them in customers pc ?

  6. #6
    Join Date
    Nov 2003
    Posts
    2,817
    Quote Originally Posted by isaac_cm
    but why only for developing, is there a problem to use them in customers pc ?
    Well that was the use case for me
    For a production environment with a dedicated Postgres server you will definitely want to have the service installation in order to make sure Postgres is always up and running.

    And the startup through a batch file has the disadvantage that you'll have a console window open which is also not ideal for a production environment.

    I have attached the batch files.

    They assume that the ZIP distribution is unzipped into the folder where the files are located into a sub-directory called "server". The data directory will be created in the same folder

    So the directory will be:

    Code:
    postgres
       datadir
       server
          (unzipped binary archive)
          bin
          share
          lib
          ...
    The bare minimum to be extracted from the ZIP archive are the directories bin, lib and share

    The other stuff (e.g pgAdmin) is optional and not required to run the server.

    The batch file initialize.cmd is also adjusting some of the more conservative parameters in the postgresql.conf file.

    For this it uses a tool called "Swiss File Knife" to replace the default values. You need to either comment those lines, or download sfk.exe from here.
    http://sourceforge.net/projects/swissfileknife/

    If you want to run Postgres on a different port, you can either supply the parameter in the commandline for initdb (initialize.cmd, line 24) or extend the section that changes the postgresql.conf file to replace the default port with your desired one.
    Attached Files Attached Files

  7. #7
    Join Date
    Aug 2009
    Posts
    17
    Ok, many thanks

    After I modify the postgresql.conf, what is the command to install the service permanently on the pc ?

  8. #8
    Join Date
    Nov 2003
    Posts
    2,817
    Quote Originally Posted by isaac_cm
    After I modify the postgresql.conf, what is the command to install the service permanently on the pc ?
    As I said, use pg_ctl with the -register parameter.
    See the link to the manual that I posted for details.

  9. #9
    Join Date
    Aug 2009
    Posts
    17
    oh sorry I forgot, many things to manage at same time

    Many thanks

Posting Permissions

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