Postgres: Installing as a service

Started by CM Jalmost 17 years ago5 messagesgeneral
Jump to latest
#1CM J
postgres.newbie@gmail.com

Hi ,

I have extracted postgres from postgres-noinstaller.zip file. How do
i install postgres as a service from cmd line ? Are there are any binaries
provided by postgres to install it as a service ? Please note that i am
aware that msi installer automatically does all this. I want to know how to
acheive the same from the postgres db extracted from the zip file.

Thanks.

#2Craig Ringer
craig@2ndquadrant.com
In reply to: CM J (#1)
Re: Postgres: Installing as a service

CM J wrote:

Hi ,

I have extracted postgres from postgres-noinstaller.zip file. How do
i install postgres as a service from cmd line ?

Search: http://msdn.microsoft.com/

You can use the `net' command to start/stop services. I don't recall the
command(s) used to install them, if any, but you'll be able to find the
info on MSDN.

Are there are any binaries
provided by postgres to install it as a service ?

No.

Why not use the MSI installer's silent mode?

--
Craig Ringer

#3John R Pierce
pierce@hogranch.com
In reply to: Craig Ringer (#2)
Re: Postgres: Installing as a service

Craig Ringer wrote:

CM J wrote:

Hi ,

I have extracted postgres from postgres-noinstaller.zip file. How do
i install postgres as a service from cmd line ?

Search: http://msdn.microsoft.com/

You can use the `net' command to start/stop services. I don't recall the
command(s) used to install them, if any, but you'll be able to find the
info on MSDN.

sc is the command line tool for installing/configuring services. you'll
need to create a service account with NET USER, then configure the pgsql
service to run as that user.

the standard postgresql windows installer configures it to look like...

C:\>sc queryex pgsql-8.3

SERVICE_NAME: pgsql-8.3
TYPE : 10 WIN32_OWN_PROCESS
STATE : 4 RUNNING
(STOPPABLE,PAUSABLE,ACCEPTS_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x0
WAIT_HINT : 0x0
PID : 1256
FLAGS :

C:\>sc qc pgsql-8.3
[SC] GetServiceConfig SUCCESS

SERVICE_NAME: pgsql-8.3
TYPE : 10 WIN32_OWN_PROCESS
START_TYPE : 2 AUTO_START
ERROR_CONTROL : 1 NORMAL
BINARY_PATH_NAME : D:\postgres\8.3\bin\pg_ctl.exe runservice
-w -N "pgsql-8.3" -D "D:\postgres\8.3\data\"
LOAD_ORDER_GROUP :
TAG : 0
DISPLAY_NAME : PostgreSQL Database Server 8.3
DEPENDENCIES :
SERVICE_START_NAME : .\postgres

so the commands to create tthis would be something like...

C:\>net user postgres 3gesIjita%9 /add
C:\>sc create pgsql-8.3 binpath= "D:\postgres\8.3\bin\pg_ctl.exe
runservice -w -N pgsql-8.3 -D D:\postgres\8.3\data\" type= own start=
auto displayname= "PostgreSQL Database Server 8.3" obj= .\postgres
password= 3gesIjita%9
C:\>sc start pgsql-8.3

and pray. note I intentionally installed postgresql to a directory
with no spaces in its name to dodge issues with nested quotes.
3gesIjita%9 is just a random password I concocted.

note, those sc commands have a funny syntax, the = MUST have no space
before it and MUST have a space after it.

#4Thomas Kellerer
spam_eater@gmx.net
In reply to: CM J (#1)
Re: Postgres: Installing as a service

CM J wrote on 13.04.2009 07:48:

Hi ,

I have extracted postgres from postgres-noinstaller.zip file. How
do i install postgres as a service from cmd line ? Are there are any
binaries provided by postgres to install it as a service ? Please note
that i am aware that msi installer automatically does all this. I want
to know how to acheive the same from the postgres db extracted from the
zip file.

Thanks.

Use "pg_ctl register" (after you have created the postgres windows user as
described by John)

http://www.postgresql.org/docs/8.3/static/app-pg-ctl.html

#5CM J
postgres.newbie@gmail.com
In reply to: Craig Ringer (#2)
Re: Postgres: Installing as a service

Hi,

The following cmd can be used for installating postgres as a service:

pg_ctl.exe register -N <servicename> -U <user> -P <password> -D <datadir>

and "pgctl.exe unregister -N <servicename>" can be used to uninstall.

Thanks.

On Mon, Apr 13, 2009 at 12:15 PM, Craig Ringer
<craig@postnewspapers.com.au>wrote:

Show quoted text

CM J wrote:

Hi ,

I have extracted postgres from postgres-noinstaller.zip file. How

do

i install postgres as a service from cmd line ?

Search: http://msdn.microsoft.com/

You can use the `net' command to start/stop services. I don't recall the
command(s) used to install them, if any, but you'll be able to find the
info on MSDN.

Are there are any binaries
provided by postgres to install it as a service ?

No.

Why not use the MSI installer's silent mode?

--
Craig Ringer