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 > install postgre service manually

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old
Registered User
 
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
Reply With Quote
  #2 (permalink)  
Old
Registered User
 
Join Date: Nov 2003
Posts: 2,779
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
Reply With Quote
  #3 (permalink)  
Old
Registered User
 
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.
Reply With Quote
  #4 (permalink)  
Old
Registered User
 
Join Date: Nov 2003
Posts: 2,779
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.
Reply With Quote
  #5 (permalink)  
Old
Registered User
 
Join Date: Aug 2009
Posts: 17
sure, plz do, but why only for developing, is there a problem to use them in customers pc ?
Reply With Quote
  #6 (permalink)  
Old
Registered User
 
Join Date: Nov 2003
Posts: 2,779
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
File Type: zip batchfiles.zip (2.3 KB, 75 views)
Reply With Quote
  #7 (permalink)  
Old
Registered User
 
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 ?
Reply With Quote
  #8 (permalink)  
Old
Registered User
 
Join Date: Nov 2003
Posts: 2,779
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.
Reply With Quote
  #9 (permalink)  
Old
Registered User
 
Join Date: Aug 2009
Posts: 17
oh sorry I forgot, many things to manage at same time

Many thanks
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