Re: Starting PostgreSQL as an NT Service

From: "Darko Prenosil" <Darko(dot)Prenosil(at)finteh(dot)hr>
To: "Merlin Moncure" <merlin(dot)moncure(at)rcsonline(dot)com>, "John Meinel" <john(at)johnmeinel(dot)com>
Cc: <pgsql-hackers-win32(at)postgresql(dot)org>
Subject: Re: Starting PostgreSQL as an NT Service
Date: 2004-06-30 21:00:55
Message-ID: 004301c45ee5$813e4500$3289bfd5@darko
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers-win32

I registerd the service using the bat file:

d:
cd pgsql\bin
"pg_ctl.exe" unregister -N postgres
"d:\pgsql\bin\pg_ctl.exe" register -N postgres -U postgres -P
elephant5432 -D d:\pgsql\data"
net start postgres

I got :
The description for Event ID ( 0 ) in Source ( PostgreSQL ) cannot be found.
The local computer may not have the necessary registry information or
message DLL files to display messages from a remote computer. The following
information is part of the event: Unable to find exe.

message written to event viewer.

d:\pgsql\bin is in the path.

Path to executable in the service manager is:

d:/pgsql/bin/pg_ctl.exe runservice -N "postgres" -D "d:/pgsql/data"

initdb finished OK, postgres is opened as unpriviledged user etc...

Why pg_ctl can't find postmaster ? Any sugestions ?

Regards !

----- Original Message -----
From: "Merlin Moncure" <merlin(dot)moncure(at)rcsonline(dot)com>
To: "John Meinel" <john(at)johnmeinel(dot)com>
Cc: <pgsql-hackers-win32(at)postgresql(dot)org>
Sent: Wednesday, June 30, 2004 8:39 PM
Subject: Re: [pgsql-hackers-win32] Starting PostgreSQL as an NT Service

> I just downloaded the latest binary (as of today). I can get it to
> register with pg_ctl register. I had to create an account for it to
run
> as, since you don't allow a user with admin rights.
>
> If I just do
> pg_ctl register -U postgres
> C:\postgres>net start postgresql
> System error 1069 has occurred.
>
> The service did not start due to a logon failure.
>
> I get this if the password for postgres is empty.
> So I added a password for user postgres ('a'), and tried again:
>
> C:\postgres>pg_ctl unregister -N PostgreSQL
>
> C:\postgres>pg_ctl register -U LILIANA\postgres -P a
>
> C:\postgres>net start postgresql
> The service is not responding to the control function.
>
> More help is available by typing NET HELPMSG 2186.
>
> I can start the service manually using:
>
> C:\postgres>runas /env /user:postgres "pg_ctl start -l logfile"
> Enter the password for postgres:
> Attempting to start pg_ctl start -l logfile as user
"LILIANA\postgres"..
>
> However, this leaves a dos-box running with "postmaster starting". I'm
> pretty sure this is because postmaster is running as a child of cmd.
> Because I can't stop this box, but if I run:
>
> C:\postgres>runas /env /user:postgres "pg_ctl stop"
> Enter the password for postgres:
> Attempting to start pg_ctl stop as user "LILIANA\postgres" ...

There are couple of gotchas:
1. The account that is starting postgresql can not have administrator
privileges. This is a safety issue...works the same on unix.

2. The account starting postgresql must have 'log on as a service'
privilege. More about this in a sec.

3. Make sure the postgresql NT user (in your case: 'postgres') has
permissions to the data folder. Add this user to the folder and make
sure you apply the permissions to the subfolders. It goes without
saying that the data folder should *not* be shared to the outside world
in any way.

4. Make sure you ran initdb previous to attempting to resister server.

You can omit the -U parameter to pg_ctl and play around with the
accounts with the service directly (select log on as... in service
properties). It's easier there because you get more detailed error
information and you don't have to keep re-registering the server.

Merlin

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend

In response to

Browse pgsql-hackers-win32 by date

  From Date Subject
Next Message Merlin Moncure 2004-06-30 21:08:25 Re: Starting PostgreSQL as an NT Service
Previous Message Merlin Moncure 2004-06-30 18:39:39 Re: Starting PostgreSQL as an NT Service