Re: Starting PostgreSQL as an NT Service

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>
Subject: Re: Starting PostgreSQL as an NT Service
Date: 2004-06-30 18:39:39
Message-ID: 6EE64EF3AB31D5448D0007DD34EEB34101AEA1@Herge.rcsinc.local
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers-win32


> 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

Responses

Browse pgsql-hackers-win32 by date

  From Date Subject
Next Message Darko Prenosil 2004-06-30 21:00:55 Re: Starting PostgreSQL as an NT Service
Previous Message Tom Lane 2004-06-30 15:31:44 Re: [HACKERS] Compile Failue on win32 - pipe.c using ereport