Обсуждение: Can't get postgresql to work

Поиск
Список
Период
Сортировка

Can't get postgresql to work

От
rdkurth@starband.net
Дата:
I keep getting this when I try to access the PostgreSQL database. The
funny thing is this used to work. I am using a cobalt Linux server.
And Postgresql is used for the GUI on that server . The GUI works I
just can't access this other Database.
How can I start the server with the -i . PostgreSQL is started at boot
up with the script down below how can I change that to use the -i
switch or do I even have to do that. I really don't understand this at
all. How can I get it to work

PHP Warning:  pg_pconnect() unable to connect to PostgreSQL server: PQconnec
tPoll() -- connect() failed: Connection refused
        Is the postmaster running (with -i) at '127.0.0.1'
        and accepting connections on TCP/IP port '5901'?

############THIS IS MY pg_hba.conf FILE#######################
local cobalt crypt
local eprop crypt
host eprop 127.0.0.1 255.255.255.255 crypt


#########THIS IS THE START UP SCRIPT#################
#!/bin/bash

# postgresql    This is the init script for starting up the PostgreSQL
#               server
#
# chkconfig:   345 73 73
# description: Starts and stops the PostgreSQL backend daemon
# processname: postmaster
# pidfile:     /var/run/postmaster.pid
#

[ -x /usr/bin/postmaster        ] || exit 1
[ -s /etc/rc.d/init.d/functions ] || exit 1
[ -s /etc/sysconfig/network     ] || exit 1

. /etc/rc.d/init.d/functions
. /etc/sysconfig/network

[ $NETWORKING = "no"     ] && exit 0
[ -s /etc/sysconfig/i18n ] && . /etc/sysconfig/i18n

VERBOSE=yes
[ "$2" = "quiet" ] && VERBOSE=

DOMAIN=initscripts
PIDFILE=/var/run/postmaster.pid
LOCKFILE=/var/lock/subsys/postgresql
PGDATA=/var/lib/pgsql/data
export PGDATA

case "$1" in
    start)
        if [ $VERBOSE ]; then
            LINE1=`getmsg postgresql_start_1`
            LINE2=`getmsg postgresql_start_2`
            $LCD_STOP
            $LCD_SWRITE "$LINE1" "$LINE2" &> /dev/null &
            echo -n "$LINE1 $LINE2: "
        fi

        if [ -s $PGDATA/PG_VERSION -a -d $PGDATA/base/template1 ]; then
            if [ `cat $PGDATA/PG_VERSION` != "7.0" ]; then
                [ $VERBOSE ] && echo "old version, upgrade to 7.0!"
                exit 1
            fi
        else
            [ $VERBOSE ] && echo "no database files found.  creating..."
            if [ ! -d $PGDATA ]; then
                mkdir -p $PGDATA
                chown postgres.postgres $PGDATA
            fi
            su postgres -c "/usr/bin/initdb --pglib=/usr/lib/pgsql --pgdata=$PGDATA"
        fi

        pid=`pidof postmaster`
        if [ $pid ]; then
            [ $VERBOSE ] && echo "postmaster already running!"
            exit 1
        fi

        rm -f /tmp/.s.PGSQL.*
        su postgres -c  "nohup /usr/bin/postmaster  >> /var/log/postgresql 2>&1 &"
        sleep 1

        pid=`pidof postmaster`
        if [ $pid ]; then
            [ $VERBOSE ] && echo "ok [$pid]"
            echo $pid > $PIDFILE
            touch $LOCKFILE
        else
            [ $VERBOSE     ] && echo "failed!"
            [ -f $PIDFILE  ] && rm -f $PIDFILE
            [ -f $LOCKFILE ] && rm -f $LOCKFILE
            exit 1
        fi

        if [ ! -d $PGDATA/base/cobalt ]; then
            /usr/local/sbin/setup-postgres
        fi
        ;;

    stop)
        if [ $VERBOSE ]; then
            LINE1=`getmsg postgresql_stop_1`
            LINE2=`getmsg postgresql_stop_2`
            $LCD_STOP
            $LCD_SWRITE "$LINE1" "$LINE2" &> /dev/null &
            echo -n "$LINE1 $LINE2: "
        fi

        pid=`pidof postmaster`
        if [ $pid ]; then
            if [ -s $PIDFILE ] && [ `cat $PIDFILE` != $pid ]; then
                [ $VERBOSE ] && echo -n "process ID mismatch! "
            fi
            kill $pid
            sleep 2
            killall /usr/bin/postgres >/dev/null 2>&1

            [ $VERBOSE ] && echo "ok"
        else
            [ $VERBOSE ] && echo "not running!"
        fi

        [ -f $PIDFILE  ] && rm -f $PIDFILE
        [ -f $LOCKFILE ] && rm -f $LOCKFILE
        ;;

    status)
        status postmaster
        ;;

    restart)
        EXTRA=
        [ $VERBOSE ] || EXTRA=quiet
        $0 stop $EXTRA
        $0 start $EXTRA
        ;;

    hard-restart)
        $0 stop quiet
        $0 start quiet
        ;;

    *)
        echo "Usage: postgresql {start|stop|status|restart} [quiet]"
        exit 1

esac

exit 0




--
Best regards,
 rdkurth                          mailto:rdkurth@starband.net


Re: Can't get postgresql to work

От
Darren Ferguson
Дата:
If you don't want to start with the -i you can always go to the

postgresql.conf file and uncomment the following line

# tcpip_socket = true

This will have the same effect as using the -i then you do not have to
worry about changing your bash script.

Also the server is not running on the norm pg port 5432 could this be any
cause ??

HTH

On Wed, 21 Aug 2002 rdkurth@starband.net wrote:

> I keep getting this when I try to access the PostgreSQL database. The
> funny thing is this used to work. I am using a cobalt Linux server.
> And Postgresql is used for the GUI on that server . The GUI works I
> just can't access this other Database.
> How can I start the server with the -i . PostgreSQL is started at boot
> up with the script down below how can I change that to use the -i
> switch or do I even have to do that. I really don't understand this at
> all. How can I get it to work
>
> PHP Warning:  pg_pconnect() unable to connect to PostgreSQL server: PQconnec
> tPoll() -- connect() failed: Connection refused
>         Is the postmaster running (with -i) at '127.0.0.1'
>         and accepting connections on TCP/IP port '5901'?
>
> ############THIS IS MY pg_hba.conf FILE#######################
> local cobalt crypt
> local eprop crypt
> host eprop 127.0.0.1 255.255.255.255 crypt
>
>
> #########THIS IS THE START UP SCRIPT#################
> #!/bin/bash
>
> # postgresql    This is the init script for starting up the PostgreSQL
> #               server
> #
> # chkconfig:   345 73 73
> # description: Starts and stops the PostgreSQL backend daemon
> # processname: postmaster
> # pidfile:     /var/run/postmaster.pid
> #
>
> [ -x /usr/bin/postmaster        ] || exit 1
> [ -s /etc/rc.d/init.d/functions ] || exit 1
> [ -s /etc/sysconfig/network     ] || exit 1
>
> . /etc/rc.d/init.d/functions
> . /etc/sysconfig/network
>
> [ $NETWORKING = "no"     ] && exit 0
> [ -s /etc/sysconfig/i18n ] && . /etc/sysconfig/i18n
>
> VERBOSE=yes
> [ "$2" = "quiet" ] && VERBOSE=
>
> DOMAIN=initscripts
> PIDFILE=/var/run/postmaster.pid
> LOCKFILE=/var/lock/subsys/postgresql
> PGDATA=/var/lib/pgsql/data
> export PGDATA
>
> case "$1" in
>     start)
>         if [ $VERBOSE ]; then
>             LINE1=`getmsg postgresql_start_1`
>             LINE2=`getmsg postgresql_start_2`
>             $LCD_STOP
>             $LCD_SWRITE "$LINE1" "$LINE2" &> /dev/null &
>             echo -n "$LINE1 $LINE2: "
>         fi
>
>         if [ -s $PGDATA/PG_VERSION -a -d $PGDATA/base/template1 ]; then
>             if [ `cat $PGDATA/PG_VERSION` != "7.0" ]; then
>                 [ $VERBOSE ] && echo "old version, upgrade to 7.0!"
>                 exit 1
>             fi
>         else
>             [ $VERBOSE ] && echo "no database files found.  creating..."
>             if [ ! -d $PGDATA ]; then
>                 mkdir -p $PGDATA
>                 chown postgres.postgres $PGDATA
>             fi
>             su postgres -c "/usr/bin/initdb --pglib=/usr/lib/pgsql --pgdata=$PGDATA"
>         fi
>
>         pid=`pidof postmaster`
>         if [ $pid ]; then
>             [ $VERBOSE ] && echo "postmaster already running!"
>             exit 1
>         fi
>
>         rm -f /tmp/.s.PGSQL.*
>         su postgres -c  "nohup /usr/bin/postmaster  >> /var/log/postgresql 2>&1 &"
>         sleep 1
>
>         pid=`pidof postmaster`
>         if [ $pid ]; then
>             [ $VERBOSE ] && echo "ok [$pid]"
>             echo $pid > $PIDFILE
>             touch $LOCKFILE
>         else
>             [ $VERBOSE     ] && echo "failed!"
>             [ -f $PIDFILE  ] && rm -f $PIDFILE
>             [ -f $LOCKFILE ] && rm -f $LOCKFILE
>             exit 1
>         fi
>
>         if [ ! -d $PGDATA/base/cobalt ]; then
>             /usr/local/sbin/setup-postgres
>         fi
>         ;;
>
>     stop)
>         if [ $VERBOSE ]; then
>             LINE1=`getmsg postgresql_stop_1`
>             LINE2=`getmsg postgresql_stop_2`
>             $LCD_STOP
>             $LCD_SWRITE "$LINE1" "$LINE2" &> /dev/null &
>             echo -n "$LINE1 $LINE2: "
>         fi
>
>         pid=`pidof postmaster`
>         if [ $pid ]; then
>             if [ -s $PIDFILE ] && [ `cat $PIDFILE` != $pid ]; then
>                 [ $VERBOSE ] && echo -n "process ID mismatch! "
>             fi
>             kill $pid
>             sleep 2
>             killall /usr/bin/postgres >/dev/null 2>&1
>
>             [ $VERBOSE ] && echo "ok"
>         else
>             [ $VERBOSE ] && echo "not running!"
>         fi
>
>         [ -f $PIDFILE  ] && rm -f $PIDFILE
>         [ -f $LOCKFILE ] && rm -f $LOCKFILE
>         ;;
>
>     status)
>         status postmaster
>         ;;
>
>     restart)
>         EXTRA=
>         [ $VERBOSE ] || EXTRA=quiet
>         $0 stop $EXTRA
>         $0 start $EXTRA
>         ;;
>
>     hard-restart)
>         $0 stop quiet
>         $0 start quiet
>         ;;
>
>     *)
>         echo "Usage: postgresql {start|stop|status|restart} [quiet]"
>         exit 1
>
> esac
>
> exit 0
>
>
>
>
>

--
Darren Ferguson