Thread: newbie question

newbie question

From
Xue-Feng Yang
Date:
Can anyone help me on the following problem?

$psql -h localhost

psql: PQconnectPoll() -- connect() failed: Connection
refused
        Is the postmaster running (with -i) at
'localhost'
        and accepting connections on TCP/IP port '5432'?

_______________________________________________________
Do You Yahoo!?
Get your free @yahoo.ca address at http://mail.yahoo.ca

Re: newbie question

From
Grant
Date:
Well is postmaster running with i?

ps auwx | grep post


Re: newbie question

From
Henry House
Date:
On Tue, Jul 10, 2001 at 08:26:56PM -0400, Xue-Feng Yang wrote:
> Can anyone help me on the following problem?
>
> $psql -h localhost
>
> psql: PQconnectPoll() -- connect() failed: Connection
> refused
>         Is the postmaster running (with -i) at
> 'localhost'
>         and accepting connections on TCP/IP port '5432'?

1. Is the postmaster process running? Check using 'ps'.

2. Is the postmaster not listening on TCP? Check using 'netstat -lnp'.
Example of what you should see:

 tcp        0      0 0.0.0.0:5432            0.0.0.0:*               LISTEN 31693/postmaster
 unix  0      [ ACC ]     STREAM     LISTENING     68763  31693/postmaster /var/run/postgresql/.s.PGSQL.5432


--
Henry House
OpenPGP key available from http://romana.hajhouse.org/hajhouse.asc

Attachment

Re: newbie question

From
Xue-Feng Yang
Date:
--- Henry House <hajhouse@houseag.com> wrote:
> On Tue, Jul 10, 2001 at 10:02:03PM -0400, Xue-Feng
> Yang wrote:
> > Sounds that the postmaster does not listen on TCP.
> > How can I add it to TCP?
>
> You need to pass the -i switch to the postmaster
> when starting it. Most
> likely your distribution provided an initscript
> (/etc/init.d/postgresql
> perhaps) to start and stop the postmaster; if so you
> will need to edit this
> file.
>
> --
> Henry House
> OpenPGP key available from
> http://romana.hajhouse.org/hajhouse.asc
>

> ATTACHMENT part 2 application/pgp-signature

Here is the file. Please give me more suggestions.

#! /bin/sh
# postgresql    This is the init script for starting
up the PostgreSQL
#               server

# Version 6.5.3-2 Lamar Owen
# Added code to determine if PGDATA exists, whether it
is current version
#     or not, and initdb if no PGDATA (initdb will not
overwrite a database).

# Version 7.0 Lamar Owen
# Added logging code
# Changed PGDATA.
#

# Version 7.0.2 Trond Eivind Glomsr�d <teg@redhat.com>
# use functions, add conditional restart


# chkconfig: 345 85 15
# description: Starts and stops the PostgreSQL backend
daemon that handles \
#              all database requests.
# processname: postmaster
# pidfile: /var/run/postmaster.pid
#

# Source function library.
. /etc/rc.d/init.d/functions

# Get config.
. /etc/sysconfig/network

# Check that networking is up.
# Pretty much need it for postmaster.
[ ${NETWORKING} = "no" ] && exit 0

[ -f /usr/bin/postmaster ] || exit 0


start(){
        PSQL_CHECK="Checking postgresql installation:
"
        PSQL_START="Starting postgresql service: "

        echo -n "$PSQL_CHECK"

        # Check for older PGDATA location.
        if [ -f /var/lib/pgsql/PG_VERSION ] && [ -d
/var/lib/pgsql/base/template
1 ]
        then
                export PGDATA=/var/lib/pgsql
        else
                export PGDATA=/var/lib/pgsql/data
        fi

        # Check for the PGDATA structure
        if [ -f $PGDATA/PG_VERSION ] && [ -d
$PGDATA/base/template1 ]
        then
        # Check version of existing PGDATA

                if [ `cat $PGDATA/PG_VERSION` != '7.0'
]
                then
                        echo
                        echo "old version. Need to
Upgrade."
                        echo "See
/usr/share/doc/postgresql-7.0.2/README.rpm for
 more information."
                        exit 1
                else
                        success "$PSQL_CHECK"
                        echo
                fi

        # No existing PGDATA! Initdb it.

        else
                echo "no database files found."
                if [ ! -d $PGDATA ]
                then
                        mkdir -p $PGDATA
                        chown postgres.postgres
$PGDATA
                fi
                su -l postgres -c '/usr/bin/initdb
--pglib=/usr/lib/pgsql --pgda
ta=/var/lib/pgsql/data' < /dev/null
        fi

        # Check for postmaster already running...
        pid=`pidof postmaster`
        if [ $pid ]
        then
                echo "Postmaster already running."
        else
                #all systems go -- remove any stale
lock files
                rm -f /tmp/.s.PGSQL.* > /dev/null
                echo -n "$PSQL_START"
                su -l postgres -c "/usr/bin/pg_ctl  -D
$PGDATA -p /usr/bin/postm
aster start >/dev/null 2>&1" < /dev/null
                sleep 1
                pid=`pidof postmaster`
                if [ $pid ]
                then
                        success "$PSQL_START"
                        touch
/var/lock/subsys/postgresql
                        echo $pid >
/var/run/postmaster.pid
                        echo
                else
                        failure "$PSQL_START"
                        echo
                fi
        fi
}

stop(){
        echo -n "Stopping postgresql service: "
        killproc postmaster
        sleep 2
        rm -f /var/run/postmaster.pid
        rm -f /var/lock/subsys/postgresql
        echo
}

restart(){
        stop
        start
}

condrestart(){
    [ -e /var/lock/subsys/postgresql ] && restart || :
}


# This script is slightly unusual in that the name of
the daemon (postmaster)
# is not the same as the name of the subsystem
(postgresql)

# See how we were called.
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  status)
        status postmaster
        ;;
  restart)
        restart
        ;;
  condrestart)
        condrestart
        ;;
  *)
        echo "Usage: postgresql
{start|stop|status|restart|condrestart}"
        exit 1
esac

exit 0

_______________________________________________________
Do You Yahoo!?
Get your free @yahoo.ca address at http://mail.yahoo.ca

RE: newbie question

From
"Nick Fankhauser"
Date:
> Here is the file. Please give me more suggestions.

Actually, I think the best place to set this would be in the config file.
The right place depends on which version you are running.


If your version is lower than 7.1, put a line in postmaster.init that looks
like this:

PGALLOWTCPIP=yes


If your version is 7.1 or higher, put a line in postgresql.conf that looks
like this:

TCPIP_SOCKET = 1



On Debian Linux these files would be found in /etc/postgresql

I'm not sure where they live on other platforms.

-Nick



Re: newbie question

From
Xue-Feng Yang
Date:
Thanks all.
The problem is changed to

[xyang@d141-67-217 xyang]$ psql -h localhost
psql: Missing or erroneous pg_hba.conf file, see
postmaster log for details

Where are thses files?


--- Henry House <hajhouse@houseag.com> wrote:
> On Tue, Jul 10, 2001 at 11:24:26PM -0400, Xue-Feng
> Yang wrote:
> [...]
> > Here is the file. Please give me more suggestions.
>
> Scroll down for the comments.
>
> > #! /bin/sh
> > # postgresql    This is the init script for
> starting
> > up the PostgreSQL
> > #               server
> >
> > # Version 6.5.3-2 Lamar Owen
> > # Added code to determine if PGDATA exists,
> whether it
> > is current version
> > #     or not, and initdb if no PGDATA (initdb will
> not
> > overwrite a database).
> >
> > # Version 7.0 Lamar Owen
> > # Added logging code
> > # Changed PGDATA.
> > #
> >
> > # Version 7.0.2 Trond Eivind Glomsr?d
> <teg@redhat.com>
> > # use functions, add conditional restart
> >
> >
> > # chkconfig: 345 85 15
> > # description: Starts and stops the PostgreSQL
> backend
> > daemon that handles \
> > #              all database requests.
> > # processname: postmaster
> > # pidfile: /var/run/postmaster.pid
> > #
> >
> > # Source function library.
> > . /etc/rc.d/init.d/functions
> >
> > # Get config.
> > . /etc/sysconfig/network
> >
> > # Check that networking is up.
> > # Pretty much need it for postmaster.
> > [ ${NETWORKING} = "no" ] && exit 0
> >
> > [ -f /usr/bin/postmaster ] || exit 0
> >
> >
> > start(){
> >         PSQL_CHECK="Checking postgresql
> installation:
> > "
> >         PSQL_START="Starting postgresql service: "
> >
> >         echo -n "$PSQL_CHECK"
> >
> >         # Check for older PGDATA location.
> >         if [ -f /var/lib/pgsql/PG_VERSION ] && [
> -d
> > /var/lib/pgsql/base/template
> > 1 ]
> >         then
> >                 export PGDATA=/var/lib/pgsql
> >         else
> >                 export PGDATA=/var/lib/pgsql/data
> >         fi
> >
> >         # Check for the PGDATA structure
> >         if [ -f $PGDATA/PG_VERSION ] && [ -d
> > $PGDATA/base/template1 ]
> >         then
> >         # Check version of existing PGDATA
> >
> >                 if [ `cat $PGDATA/PG_VERSION` !=
> '7.0'
> > ]
> >                 then
> >                         echo
> >                         echo "old version. Need to
> > Upgrade."
> >                         echo "See
> > /usr/share/doc/postgresql-7.0.2/README.rpm for
> >  more information."
> >                         exit 1
> >                 else
> >                         success "$PSQL_CHECK"
> >                         echo
> >                 fi
> >
> >         # No existing PGDATA! Initdb it.
> >
> >         else
> >                 echo "no database files found."
> >                 if [ ! -d $PGDATA ]
> >                 then
> >                         mkdir -p $PGDATA
> >                         chown postgres.postgres
> > $PGDATA
> >                 fi
> >                 su -l postgres -c '/usr/bin/initdb
> > --pglib=/usr/lib/pgsql --pgda
> > ta=/var/lib/pgsql/data' < /dev/null
> >         fi
> >
> >         # Check for postmaster already running...
> >         pid=`pidof postmaster`
> >         if [ $pid ]
> >         then
> >                 echo "Postmaster already running."
> >         else
> >                 #all systems go -- remove any
> stale
> > lock files
> >                 rm -f /tmp/.s.PGSQL.* > /dev/null
> >                 echo -n "$PSQL_START"
> >                 su -l postgres -c "/usr/bin/pg_ctl
>  -D
> > $PGDATA -p /usr/bin/postm
> > aster start >/dev/null 2>&1" < /dev/null
>
> The previous line (mangled by mailer word wrapping)
> starts the postmaster.
> Try changing it to:
>
>     su -l postgres -c "/usr/bin/pg_ctl -D $PGDATA -p
> /usr/bin/postmaster start -o "-i" >/dev/null 2>&1" <
> /dev/null
>
> The -o "<options>" tells the pg_ctl utility to pass
> the options in <options>
> to the postmaster when starting it. There is a
> manual page on pg_ctl; you may
> find it useful. You can pass any options to the
> postmaster, so you could make
> it listed to any tcp port you like.
>
> >                 sleep 1
> >                 pid=`pidof postmaster`
> >                 if [ $pid ]
> >                 then
> >                         success "$PSQL_START"
> >                         touch
> > /var/lock/subsys/postgresql
> >                         echo $pid >
> > /var/run/postmaster.pid
> >                         echo
> >                 else
> >                         failure "$PSQL_START"
> >                         echo
> >                 fi
> >         fi
> > }
> >
> > stop(){
> >         echo -n "Stopping postgresql service: "
> >         killproc postmaster
> >         sleep 2
> >         rm -f /var/run/postmaster.pid
> >         rm -f /var/lock/subsys/postgresql
> >         echo
> > }
> >
> > restart(){
> >         stop
> >         start
> > }
> >
> > condrestart(){
> >     [ -e /var/lock/subsys/postgresql ] && restart
> || :
> > }
> >
> >
> > # This script is slightly unusual in that the name
> of
> > the daemon (postmaster)
> > # is not the same as the name of the subsystem
> > (postgresql)
> >
> > # See how we were called.
> > case "$1" in
> >   start)
> >         start
> >         ;;
> >   stop)
> >         stop
> >         ;;
> >   status)
> >         status postmaster
> >         ;;
> >   restart)
> >         restart
> >         ;;
> >   condrestart)
> >         condrestart
> >         ;;
>
=== message truncated ===

> ATTACHMENT part 2 application/pgp-signature



_______________________________________________________
Do You Yahoo!?
Get your free @yahoo.ca address at http://mail.yahoo.ca

Re: newbie question

From
Xue-Feng Yang
Date:
Thanks all.
The problem is changed to

[xyang@d141-67-217 xyang]$ psql -h localhost
psql: Missing or erroneous pg_hba.conf file, see
postmaster log for details

Where are thses files?


--- Henry House <hajhouse@houseag.com> wrote:
> On Tue, Jul 10, 2001 at 11:24:26PM -0400, Xue-Feng
> Yang wrote:
> [...]
> > Here is the file. Please give me more suggestions.
>
> Scroll down for the comments.
>
> > #! /bin/sh
> > # postgresql    This is the init script for
> starting
> > up the PostgreSQL
> > #               server
> >
> > # Version 6.5.3-2 Lamar Owen
> > # Added code to determine if PGDATA exists,
> whether it
> > is current version
> > #     or not, and initdb if no PGDATA (initdb will
> not
> > overwrite a database).
> >
> > # Version 7.0 Lamar Owen
> > # Added logging code
> > # Changed PGDATA.
> > #
> >
> > # Version 7.0.2 Trond Eivind Glomsr?d
> <teg@redhat.com>
> > # use functions, add conditional restart
> >
> >
> > # chkconfig: 345 85 15
> > # description: Starts and stops the PostgreSQL
> backend
> > daemon that handles \
> > #              all database requests.
> > # processname: postmaster
> > # pidfile: /var/run/postmaster.pid
> > #
> >
> > # Source function library.
> > . /etc/rc.d/init.d/functions
> >
> > # Get config.
> > . /etc/sysconfig/network
> >
> > # Check that networking is up.
> > # Pretty much need it for postmaster.
> > [ ${NETWORKING} = "no" ] && exit 0
> >
> > [ -f /usr/bin/postmaster ] || exit 0
> >
> >
> > start(){
> >         PSQL_CHECK="Checking postgresql
> installation:
> > "
> >         PSQL_START="Starting postgresql service: "
> >
> >         echo -n "$PSQL_CHECK"
> >
> >         # Check for older PGDATA location.
> >         if [ -f /var/lib/pgsql/PG_VERSION ] && [
> -d
> > /var/lib/pgsql/base/template
> > 1 ]
> >         then
> >                 export PGDATA=/var/lib/pgsql
> >         else
> >                 export PGDATA=/var/lib/pgsql/data
> >         fi
> >
> >         # Check for the PGDATA structure
> >         if [ -f $PGDATA/PG_VERSION ] && [ -d
> > $PGDATA/base/template1 ]
> >         then
> >         # Check version of existing PGDATA
> >
> >                 if [ `cat $PGDATA/PG_VERSION` !=
> '7.0'
> > ]
> >                 then
> >                         echo
> >                         echo "old version. Need to
> > Upgrade."
> >                         echo "See
> > /usr/share/doc/postgresql-7.0.2/README.rpm for
> >  more information."
> >                         exit 1
> >                 else
> >                         success "$PSQL_CHECK"
> >                         echo
> >                 fi
> >
> >         # No existing PGDATA! Initdb it.
> >
> >         else
> >                 echo "no database files found."
> >                 if [ ! -d $PGDATA ]
> >                 then
> >                         mkdir -p $PGDATA
> >                         chown postgres.postgres
> > $PGDATA
> >                 fi
> >                 su -l postgres -c '/usr/bin/initdb
> > --pglib=/usr/lib/pgsql --pgda
> > ta=/var/lib/pgsql/data' < /dev/null
> >         fi
> >
> >         # Check for postmaster already running...
> >         pid=`pidof postmaster`
> >         if [ $pid ]
> >         then
> >                 echo "Postmaster already running."
> >         else
> >                 #all systems go -- remove any
> stale
> > lock files
> >                 rm -f /tmp/.s.PGSQL.* > /dev/null
> >                 echo -n "$PSQL_START"
> >                 su -l postgres -c "/usr/bin/pg_ctl
>  -D
> > $PGDATA -p /usr/bin/postm
> > aster start >/dev/null 2>&1" < /dev/null
>
> The previous line (mangled by mailer word wrapping)
> starts the postmaster.
> Try changing it to:
>
>     su -l postgres -c "/usr/bin/pg_ctl -D $PGDATA -p
> /usr/bin/postmaster start -o "-i" >/dev/null 2>&1" <
> /dev/null
>
> The -o "<options>" tells the pg_ctl utility to pass
> the options in <options>
> to the postmaster when starting it. There is a
> manual page on pg_ctl; you may
> find it useful. You can pass any options to the
> postmaster, so you could make
> it listed to any tcp port you like.
>
> >                 sleep 1
> >                 pid=`pidof postmaster`
> >                 if [ $pid ]
> >                 then
> >                         success "$PSQL_START"
> >                         touch
> > /var/lock/subsys/postgresql
> >                         echo $pid >
> > /var/run/postmaster.pid
> >                         echo
> >                 else
> >                         failure "$PSQL_START"
> >                         echo
> >                 fi
> >         fi
> > }
> >
> > stop(){
> >         echo -n "Stopping postgresql service: "
> >         killproc postmaster
> >         sleep 2
> >         rm -f /var/run/postmaster.pid
> >         rm -f /var/lock/subsys/postgresql
> >         echo
> > }
> >
> > restart(){
> >         stop
> >         start
> > }
> >
> > condrestart(){
> >     [ -e /var/lock/subsys/postgresql ] && restart
> || :
> > }
> >
> >
> > # This script is slightly unusual in that the name
> of
> > the daemon (postmaster)
> > # is not the same as the name of the subsystem
> > (postgresql)
> >
> > # See how we were called.
> > case "$1" in
> >   start)
> >         start
> >         ;;
> >   stop)
> >         stop
> >         ;;
> >   status)
> >         status postmaster
> >         ;;
> >   restart)
> >         restart
> >         ;;
> >   condrestart)
> >         condrestart
> >         ;;
>
=== message truncated ===

> ATTACHMENT part 2 application/pgp-signature



_______________________________________________________
Do You Yahoo!?
Get your free @yahoo.ca address at http://mail.yahoo.ca

Re: newbie question

From
Henry House
Date:
On Wed, Jul 11, 2001 at 11:08:00PM -0400, Xue-Feng Yang wrote:
> Thanks all.
> The problem is changed to
>
> [xyang@d141-67-217 xyang]$ psql -h localhost
> psql: Missing or erroneous pg_hba.conf file, see
> postmaster log for details
>
> Where are thses files?

I don't know --- it depends out your distribution. Try using rpm to find out.
On Debian it is /etc/postgresql/pg_hba.conf.

--
Henry House
OpenPGP key available from http://romana.hajhouse.org/hajhouse.asc

Attachment

R: newbie question

From
"Andrea Suisani"
Date:
> Where are thses files?

I'm using postgres 7.1.1
On my linux box pg_hba.conf is in the directory $PGDATA.
You can find samething about the syntax of this in the admin's guide.

andrea





Re: newbie question

From
"Adam"
Date:
Yea  it worked for me, as well.

Xue-Feng Yang <just4look@yahoo.com> wrote in article
<20010711032426.26933.qmail@web14601.mail.yahoo.com>...
| --- Henry House <hajhouse@houseag.com> wrote:
...cut