Running PostgreSQL as a service under Windows XP Pro (using 'cygrunsrv')

Lists: pgsql-cygwin
From: Cédric Dufour <cedric(dot)dufour(at)freesurf(dot)ch>
To: <pgsql-cygwin(at)postgresql(dot)org>
Subject: Running PostgreSQL as a service under Windows XP Pro (using 'cygrunsrv')
Date: 2002-07-25 19:49:49
Message-ID: NDBBIFNBODNADCAOFDOAGEIHCDAA.cedric.dufour@freesurf.ch
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-cygwin

Hello there,

I've been struggling the last couple of hours to install PostgreSQL as a
service in Windows XP Pro and eventually suceeded, despite the lack of 'tips
& tricks' on the various mailing lists (though many people seem to have
problems too). I compiled a small HOWTO, which (part of the) content might
be helpful in the Windows part of the PostgreSQL installation documentation.
The main difficulties I encountered are:
1. 'ipc-daemon --install-as-service' doesn't seem to work on Windows XP (it
generates a timeout error when trying to start the service -> use
'cygrunsrv' instead to launch the daemon)
2. 'chown <PostgreSQL user> <...>/PostgreSQL/data' doesn't seem to work
either (one has to create the directory when logged in as the <PostgreSQL
user>, thanx M$)
3. <PostgreSQL user> has to be granted additional privileges (cf. Windows
security policies) in order to be able to launch a service
4. Cygwin temporary folder ('/tmp') and Cygrunsrv output files (cf
'--stdout' and '--stderr' options) must be read/write accessible to
<PostgreSQL user> (which is most likely not the case if <PostgreSQL user> is
not part of the 'administrators' group... and no user should actually be
part of this group unless absolutely necessary)

These issues might be obvious for some but seem to drive some other to
despair (as I almost did). I hope this information might be helpful to the
PostgreSQL community.

Regards,

Cédric Dufour

PostgreSQL under Windows XP
===========================
( NB: Tested on Windows XP Pro; no warranties for Windows XP Home )

In order to have PostegreSQL running as a service under Windows XP, follow
the instructions below.

CygWin and IPC:
---------------

1. Install CygWin
NB: Make sure to include 'cygipc' (ipc-daemon), 'cygrunsrv' and
'postgresql' modules during the installation

2. Install the IPC daemon as a Windows service
> cygrunsrv --install CygIPC --desc "CygWin IPC Daemon" --path
/usr/local/bin/ipc-daemon --termsig INT --shutdown
NB: 'ip-daemon --install-as-service' doesn't seem to work on Windows XP

PostgreSQL:
-----------

1. Create a 'SRV_PostgreSQL' user (or whatever other user name) using
Windows user manager
NB: Make sure this user has read/write access to the CygWin 'tmp'
directory and to the PostgreSQL log files (cf. '--stdout' and '--stderr'
options below)

2. Add the new user to CygWin password list
> mkpasswd -l -u SRV_PostgreSQL >> /etc/passwd

3. Create the PostgreSQL data directory
> mkdir <...>/PostgreSQL/data

4. Change the directory owner
> chown SRV_PostgreSQL <...>/PostgreSQL/data
NB: For some reasons, this doesn't work on Windows XP -> create the
directory manually, logging in as 'SRV_PostgreSQL' user

5. Initialize the database
> initdb -D <...>/PostgreSQL/data

6. Install PostgreSQL server as a Windows service
> cygrunsrv --install PostgreSQL --desc "PostgreSQL Database
Server" --path /usr/bin/postmaster --args "-D
<...>/PostgreSQL/data -i" --dep ipc-daemon --termsig INT --user
SRV_PostgreSQL --shutdown --stdout <...>/postgresql.log --stderr
<...>/postgresql.err
NB: In order to launch the service under the 'SRV_PostgreSQL' user, make
sure it has been granted the right to launch services (cf. Windows security
policies); one way to make sure of this is to open the Service Management
Console and edit the 'Log On' properties of the newly created service, so
that Windows automatically grant the required privileges to the 'Log On'
account

DONE !

25.07.2002 - C.Dufour (cedric(dot)dufour(at)freesurf(dot)ch)


From: Jason Tishler <jason(at)tishler(dot)net>
To: Cédric Dufour <cedric(dot)dufour(at)freesurf(dot)ch>
Cc: pgsql-cygwin(at)postgresql(dot)org
Subject: Re: Running PostgreSQL as a service under Windows XP Pro
Date: 2002-07-26 15:33:43
Message-ID: 20020726153343.GC1056@tishler.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-cygwin

Cédric,

On Thu, Jul 25, 2002 at 09:49:49PM +0200, Cédric Dufour wrote:
> I've been struggling the last couple of hours to install PostgreSQL as
> a service in Windows XP Pro and eventually suceeded, despite the lack
> of 'tips & tricks' on the various mailing lists ...

Did you read the following?

http://www.tishler.net/jason/software/postgresql/postgresql-7.2.1.README

Note that the above gets installed as

/usr/doc/Cygwin/postgresql-7.2.1.README

when you install PostgreSQL via Cygwin's setup.exe.

Unfortunately, it seems that it may need some updating for XP... Have
others experienced similar problems under XP?

Jason


From: Jason Tishler <jason(at)tishler(dot)net>
To: Cédric Dufour <cedric(dot)dufour(at)freesurf(dot)ch>
Cc: pgsql-cygwin(at)postgresql(dot)org, Cygwin <cygwin(at)cygwin(dot)com>
Subject: ipc-daemon cannot run as an NT service under latest Cygwin CVS
Date: 2002-08-05 17:08:40
Message-ID: 20020805170839.GC116@tishler.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-cygwin

Cédric,

On Thu, Jul 25, 2002 at 09:49:49PM +0200, Cédric Dufour wrote:
> 1. 'ipc-daemon --install-as-service' doesn't seem to work on Windows
> XP (it generates a timeout error when trying to start the service ->
> use 'cygrunsrv' instead to launch the daemon)

I just determined that I cannot run cygipc's ipc-daemon directly as an
NT service with Cygwin DLLs after 1.3.12 even under Windows 2000. What
version of Cygwin are you using (i.e., uname -a)? Are you using a post
1.3.12 snapshot or CVS?

I've will begin the binary search shortly -- any help will be greatly
appreciated.

Thanks,
Jason


From: "Myles Bogner, Ph(dot)D(dot)" <dr(dot)myles(dot)bogner(at)asolutions(dot)com>
To: pgsql-cygwin(at)postgresql(dot)org
Subject: Re: ipc-daemon cannot run as an NT service under latest
Date: 2002-08-05 18:59:27
Message-ID: 3D4ECB0F.8090204@asolutions.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-cygwin

Cédric/Jason,

I have also found that ipc-daemon with the --install-as-service
option does not install under Windows 2000 with later versions of
Cygwin. ipc-daemon does start fine, however, with the following command:

cygrunsrv --install ipc-daemon --path /usr/local/bin/ipc-daemon
--termsig INT --shutdown --desc "PostgreSQL Communication"

Myles

Jason Tishler wrote:

>Cédric,
>
>On Thu, Jul 25, 2002 at 09:49:49PM +0200, Cédric Dufour wrote:
>
>
>>1. 'ipc-daemon --install-as-service' doesn't seem to work on Windows
>>XP (it generates a timeout error when trying to start the service ->
>>use 'cygrunsrv' instead to launch the daemon)
>>
>>
>
>I just determined that I cannot run cygipc's ipc-daemon directly as an
>NT service with Cygwin DLLs after 1.3.12 even under Windows 2000. What
>version of Cygwin are you using (i.e., uname -a)? Are you using a post
>1.3.12 snapshot or CVS?
>
>I've will begin the binary search shortly -- any help will be greatly
>appreciated.
>
>Thanks,
>Jason
>
>---------------------------(end of broadcast)---------------------------
>TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
>
>
>

--
Myles Bogner, Ph.D. : VP Research & Development
PN: 314.678.2222
FX: 314.436.2559
Email: dr(dot)myles(dot)bogner(at)asolutions(dot)com

Asynchrony Solutions, Inc.
1709 Washington Ave. // Suite 200
St. Louis, MO 63103
www.asolutions.com


From: Cédric Dufour <cedric(dot)dufour(at)freesurf(dot)ch>
To: "Jason Tishler" <jason(at)tishler(dot)net>
Cc: <pgsql-cygwin(at)postgresql(dot)org>, "Cygwin" <cygwin(at)cygwin(dot)com>
Subject: Re: ipc-daemon cannot run as an NT service under latest Cygwin CVS
Date: 2002-08-05 19:05:33
Message-ID: NDBBIFNBODNADCAOFDOAOEKDCDAA.cedric.dufour@freesurf.ch
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-cygwin

Hello Jason,

Answer to your question is:

$ uname -a
CYGWIN_NT-5.1 CED-001 1.3.12(0.54/3/2) 2002-07-06 02:16 i686 unknown

Installed from standard cygwin setup procedure (no CVS version).

Note that as Myles Bogner mentionned in the next mail's thread item,
ipc-daemon starts just fine using 'cygrunsrv'.

;-)

Cédric Dufour

> -----Original Message-----
> From: Jason Tishler [mailto:jason(at)tishler(dot)net]
> Sent: Monday, August 05, 2002 19:09
> To: Cédric Dufour
> Cc: pgsql-cygwin(at)postgresql(dot)org; Cygwin
> Subject: ipc-daemon cannot run as an NT service under latest Cygwin CVS
>
>
> Cédric,
>
> On Thu, Jul 25, 2002 at 09:49:49PM +0200, Cédric Dufour wrote:
> > 1. 'ipc-daemon --install-as-service' doesn't seem to work on Windows
> > XP (it generates a timeout error when trying to start the service ->
> > use 'cygrunsrv' instead to launch the daemon)
>
> I just determined that I cannot run cygipc's ipc-daemon directly as an
> NT service with Cygwin DLLs after 1.3.12 even under Windows 2000. What
> version of Cygwin are you using (i.e., uname -a)? Are you using a post
> 1.3.12 snapshot or CVS?
>
> I've will begin the binary search shortly -- any help will be greatly
> appreciated.
>
> Thanks,
> Jason
>


From: Jason Tishler <jason(at)tishler(dot)net>
To: Cédric Dufour <cedric(dot)dufour(at)freesurf(dot)ch>
Cc: pgsql-cygwin(at)postgresql(dot)org, Cygwin <cygwin(at)cygwin(dot)com>
Subject: Re: ipc-daemon cannot run as an NT service under latest
Date: 2002-08-07 19:04:14
Message-ID: 20020807190414.GC2228@tishler.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-cygwin

Cédric,

On Mon, Aug 05, 2002 at 09:05:33PM +0200, Cédric Dufour wrote:
> Answer to your question is:
>
> $ uname -a
> CYGWIN_NT-5.1 CED-001 1.3.12(0.54/3/2) 2002-07-06 02:16 i686 unknown
>
> Installed from standard cygwin setup procedure (no CVS version).

Thanks for the above. Unfortunately, it appears that your XP problem is
different.

> Note that as Myles Bogner mentionned in the next mail's thread item,
> ipc-daemon starts just fine using 'cygrunsrv'.

Noted, but it would be nice to better understand why ipc-daemon cannot
be run directly as a service under XP.

Jason


From: Adrian Calvin <acexec(at)yahoo(dot)com>
To: pgsql-cygwin(at)postgresql(dot)org, cygwin(at)cygwin(dot)com
Subject: unsubscribe
Date: 2002-09-23 15:44:34
Message-ID: 20020923154434.52602.qmail@web13007.mail.yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Lists: pgsql-cygwin


unsubscribe

---------------------------------
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!