postmaster, but not pg_ctl -i -i

Started by Aurangzeb M. Aghaover 23 years ago6 messagesgeneral
Jump to latest
#1Aurangzeb M. Agha
aagha@bigfoot.com

I'm having an odd problem where I can start up postmaster just fine with
the following command:

$ /usr/local/pgsql/bin/postmaster -D .
DEBUG: database system was shut down at 2002-11-14 05:04:25 EST
DEBUG: checkpoint record is at 0/115894
DEBUG: redo record is at 0/115894; undo record is at 0/0; shutdown TRUE
DEBUG: next transaction id: 91; next oid: 16556
DEBUG: database system is ready

This also works fine if I do a pg_ctl without using the "-o -i" option, I
get the same.

No, I stop the postmaster that's running, do a 'ps -ef', and make sure NO
postmasters are running. Then, I execute:

$ pg_ctl -D . stop
pg_ctl: cannot find ./postmaster.pid
Is postmaster running?

$ pg_ctl start -D . -o -i
postmaster successfully started
FATAL: StreamServerPort: bind() failed: Address already in use
Is another postmaster already running on port 5432?
If not, wait a few seconds and retry.
/usr/local/pgsql/bin/postmaster: cannot create INET stream port

BUT, if I do:

$ postmaster -D . -o -i -p 5432
DEBUG: database system was shut down at 2002-11-14 05:35:49 EST
DEBUG: checkpoint record is at 0/115954
DEBUG: redo record is at 0/115954; undo record is at 0/0; shutdown TRUE
DEBUG: next transaction id: 91; next oid: 16556
DEBUG: database system is ready

Why is this happening? Why is pg_ctl behaving differently when I specify
"-o -i"? If I run pg_ctl without the -o -i options, it runs fine, so I'm
pretty sure that that's it. Also, I don't think it's a port issue,
otherwise postmaster would have the same problem on the 5432.

This issue was posted at:

http://archives.postgresql.org/pgsql-admin/1998-11/msg00044.php

And I checked my /tmp dir, but there's nothing there.

Any thoughts?

Thanks in Advance,
Aurangzeb

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Aurangzeb M. Agha (#1)
Re: postmaster, but not pg_ctl -i -i

"Aurangzeb M. Agha" <aagha@bigfoot.com> writes:

$ pg_ctl start -D . -o -i
postmaster successfully started
FATAL: StreamServerPort: bind() failed: Address already in use
Is another postmaster already running on port 5432?
If not, wait a few seconds and retry.
/usr/local/pgsql/bin/postmaster: cannot create INET stream port

BUT, if I do:

$ postmaster -D . -o -i -p 5432

These are not the same command: in particular -o means completely
different things. I expect that

$ postmaster -D . -i -p 5432

(which is what pg_ctl will do) will fail.

You may be able to find what process is using TCP port 5432 by using
netstat or lsof or some such tool.

regards, tom lane

#3Aurangzeb M. Agha
aagha@bigfoot.com
In reply to: Tom Lane (#2)
Re: postmaster, but not pg_ctl -i -i

Tom, you're right. The postmaster command specifying the port failed as
well, but I can run fine on a different port (5433).

Where can I find a list of the different options I can pass postmaster and
pg_ctl?

I looked in the reference doc but all I see there is:

-o options
Specifies options to be passed directly to postmaster.
The parameters are usually surrounded by single or double quotes to ensure that they are passed
through as a group.

I'm specifically interested in knowing how to specify the port for pg_ctl,
but would like to know what the options for the two commands is as well.

Thx,
Aurangzeb

On Thu, 14 Nov 2002, Tom Lane wrote:

:"Aurangzeb M. Agha" <aagha@bigfoot.com> writes:
:> $ pg_ctl start -D . -o -i
:> postmaster successfully started
:> FATAL: StreamServerPort: bind() failed: Address already in use
:> Is another postmaster already running on port 5432?
:> If not, wait a few seconds and retry.
:> /usr/local/pgsql/bin/postmaster: cannot create INET stream port
:
:> BUT, if I do:
:
:> $ postmaster -D . -o -i -p 5432
:
:These are not the same command: in particular -o means completely
:different things. I expect that
:
:$ postmaster -D . -i -p 5432
:
:(which is what pg_ctl will do) will fail.
:
:You may be able to find what process is using TCP port 5432 by using
:netstat or lsof or some such tool.
:
: regards, tom lane

#4Tom Lane
tgl@sss.pgh.pa.us
In reply to: Aurangzeb M. Agha (#3)
Re: postmaster, but not pg_ctl -i -i

"Aurangzeb M. Agha" <aagha@bigfoot.com> writes:

Where can I find a list of the different options I can pass postmaster and
pg_ctl?

On the reference pages ---
http://www.ca.postgresql.org/users-lounge/docs/7.2/postgres/reference-server.html

I think the thing you were missing is that for pg_ctl, -o means "here
are some switches to give to the postmaster", but for the postmaster
-o means "here are some switches to give to postgres (ie, the backends
the postmaster spawns)". So the switches following -o have different
meanings.

regards, tom lane

#5Neil Conway
neilc@samurai.com
In reply to: Tom Lane (#4)
Re: postmaster, but not pg_ctl -i -i

Tom Lane <tgl@sss.pgh.pa.us> writes:

I think the thing you were missing is that for pg_ctl, -o means "here
are some switches to give to the postmaster", but for the postmaster
-o means "here are some switches to give to postgres (ie, the backends
the postmaster spawns)". So the switches following -o have different
meanings.

[ tangentially related ... ]

Should we deprecate the switches to the postmaster that are just
alternate ways to specify GUC options (e.g. '-i', '-F', '-B', '-N')?
IMHO, splitting configuration between init scripts and postgresql.conf
only serves to make things more complicated...

Cheers,

Neil

--
Neil Conway <neilc@samurai.com> || PGP Key ID: DB3C29FC

#6Tom Lane
tgl@sss.pgh.pa.us
In reply to: Neil Conway (#5)
Re: postmaster, but not pg_ctl -i -i

Neil Conway <neilc@samurai.com> writes:

[ tangentially related ... ]

Should we deprecate the switches to the postmaster that are just
alternate ways to specify GUC options (e.g. '-i', '-F', '-B', '-N')?

I don't see a need for that. If people are using the switches, it's
because they find it more convenient to do it that way.

Here's an example of a slightly unusual use of the PM command-line
switches: I make a habit of running the postmaster with an explicit -p
(port) switch. This is because I usually have a bunch of postmasters
of different versions on my development machine:

$ ps -ef | grep postmaster
postgres 28784 1 0 Oct 1 ? 0:23 postmaster -p 5472
postgres 932 1 0 Sep 24 ? 0:00 /opt/postgres/bin/postmaster -p 5432
postgres 19376 1 0 14:48:01 ttyp4 0:00 postmaster -p 5473
postgres 15612 1 0 Oct 1 ? 0:00 postmaster -p 5471
postgres 11279 1 0 13:56:35 ttyp4 0:00 postmaster
$

It's easy for me to tell which is which in a "ps" listing. Without the
switch I'd have to find some other way to tell 'em apart.

regards, tom lane