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

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

From
Cédric Dufour
Date:
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.dufour@freesurf.ch)

Re: Running PostgreSQL as a service under Windows XP Pro

From
Jason Tishler
Date:
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

ipc-daemon cannot run as an NT service under latest Cygwin CVS

From
Jason Tishler
Date:
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

Re: ipc-daemon cannot run as an NT service under latest

From
"Myles Bogner, Ph.D."
Date:

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@postgresql.org)
 

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

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

Re: ipc-daemon cannot run as an NT service under latest Cygwin CVS

From
Cédric Dufour
Date:
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@tishler.net]
> Sent: Monday, August 05, 2002 19:09
> To: Cédric Dufour
> Cc: pgsql-cygwin@postgresql.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
>



Re: ipc-daemon cannot run as an NT service under latest

From
Jason Tishler
Date:
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

unsubscribe

From
Adrian Calvin
Date:

unsubscribe



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