Please disregard this. I found where was the problem and here is the
more appropriate patch for pgsql RA. Please test it and let me know if
you see any other problems.
On Dec 14, 2007 7:18 AM, Serge Dubrouski <[EMAIL PROTECTED]> wrote:
> I just installed PostgeSQL 8.2.5 and don't see any problems with that check:
>
> [EMAIL PROTECTED] add-on]# pgrep -u postgres postmaster
> 3655
> 3657
> 3659
> 3660
> [EMAIL PROTECTED] add-on]# ps -ef | grep post
> postgres 3655 1 0 07:15 pts/1 00:00:00 /usr/bin/postmaster -p
> 5432 -D /var/lib/pgsql/data
> postgres 3657 3655 0 07:15 ? 00:00:00 postgres: logger process
> postgres 3659 3655 0 07:15 ? 00:00:00 postgres: writer process
> postgres 3660 3655 0 07:15 ? 00:00:00 postgres: stats
> collector process
> root 3676 3359 0 07:17 pts/1 00:00:00 grep post
> [EMAIL PROTECTED] add-on]#
>
>
>
>
>
> On Dec 13, 2007 7:32 PM, HIDEO YAMAUCHI <[EMAIL PROTECTED]> wrote:
>
> > Hi,
> >
> > There is a problem to a contributed patch.(pgsql.patch)
> >
> > In postgres of 8.2 system, I cannot judge it from postmaster.
> >
> > ---------pgsql.patch-----------------------------------
> > pgrep -u postgres postmaster >/dev/null 2>&1
> > -------------------------------------------------------
> >
> > I ask for a revision.
> >
> > Regards,
> > Hideo Yamauchi.
> > _______________________________________________________
> > Linux-HA-Dev: [email protected]
> > http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
> > Home Page: http://linux-ha.org/
> >
>
>
>
> --
> Serge Dubrouski.
>
--
Serge Dubrouski.
--- resources/OCF/pgsql.old 2007-12-10 11:16:48.000000000 -0500
+++ resources/OCF/pgsql 2007-12-14 09:38:27.000000000 -0500
@@ -267,22 +267,7 @@
#
pgsql_status() {
- if [ -f $PIDFILE ]
- then
- PID=`head -n 1 $PIDFILE`
- process_running $PID
- else
- : No pid file
- false
- fi
-}
-
-
-#
-# return TRUE if a process with given PID is running
-#
-process_running() {
- kill -0 "$1" >/dev/null 2>&1
+ pgrep -u $OCF_RESKEY_pgdba "postmaster|postgres" >/dev/null 2>&1
}
#
@@ -298,9 +283,9 @@
if [ "x" = "x$OCF_RESKEY_pghost" ]
then
- $OCF_RESKEY_psql -p $OCF_RESKEY_pgport -U $OCF_RESKEY_pgdba
$OCF_RESKEY_pgdb -c 'select now();' >/dev/null 2>&1
+ runasowner "$OCF_RESKEY_psql -p $OCF_RESKEY_pgport -U $OCF_RESKEY_pgdba
$OCF_RESKEY_pgdb -c 'select now();' >/dev/null 2>&1"
else
- $OCF_RESKEY_psql -h $OCF_RESKEY_pghost -p $OCF_RESKEY_pgport -U
$OCF_RESKEY_pgdba $OCF_RESKEY_pgdb -c 'select now();' >/dev/null 2>&1
+ runasowner "$OCF_RESKEY_psql -h $OCF_RESKEY_pghost -p
$OCF_RESKEY_pgport -U $OCF_RESKEY_pgdba $OCF_RESKEY_pgdb -c 'select now();'
>/dev/null 2>&1"
fi
if [ $? -ne 0 ]
@@ -314,11 +299,22 @@
# Validate most critical parameters
pgsql_validate_all() {
+ if ! have_binary $SH
+ then
+ return $OCF_ERR_INSTALLED
+ fi
- check_binary $SH
- check_binary $OCF_RESKEY_pgctl
- check_binary $OCF_RESKEY_psql
+ if ! have_binary $OCF_RESKEY_pgctl
+ then
+ return $OCF_ERR_INSTALLED
+ fi
+
+ if ! have_binary $OCF_RESKEY_psql
+ then
+ return $OCF_ERR_INSTALLED
+ fi
+
return $OCF_SUCCESS
}
@@ -354,14 +350,6 @@
exit 1
fi
-US=`id -u -n`
-
-if [ $US != root ]
-then
- ocf_log err "$0 must be run as root"
- exit 1
-fi
-
: ${OCF_RESKEY_pgctl=/usr/bin/pg_ctl}
: ${OCF_RESKEY_psql=/usr/bin/psql}
: ${OCF_RESKEY_pgdata=/var/lib/pgsql/data}
@@ -380,13 +368,45 @@
meta-data) meta_data
exit $OCF_SUCCESS;;
+ stop) if ! pgsql_status || ! pgsql_validate_all
+ then
+ exit $OCF_SUCCESS
+ fi;;
+
+ monitor) if ! pgsql_validate_all
+ then
+ echo "Not running!"
+ exit $OCF_NOT_RUNNING
+ else
+ pgsql_monitor
+ exit $?
+ fi;;
+
+ status) if pgsql_status
+ then
+ ocf_log info "PostgreSQL is up"
+ exit $OCF_SUCCESS
+ else
+ ocf_log info "PostgreSQL is down"
+ exit $OCF_NOT_RUNNING
+ fi
+ exit $?;;
+
validate-all) pgsql_validate_all
exit $?;;
esac
+US=`id -u -n`
+
+if [ $US != root ]
+then
+ ocf_log err "$0 must be run as root"
+ exit 1
+fi
+
if ! pgsql_validate_all
then
- exit $OCF_ERR_CONFIGURED
+ exit $OCF_ERR_INSTALLED
fi
# What kind of method was invoked?
@@ -396,19 +416,6 @@
stop) pgsql_stop
exit $?;;
-
- status) if pgsql_status
- then
- ocf_log info "PostgreSQL is up"
- exit $OCF_SUCCESS
- else
- ocf_log info "PostgreSQL is down"
- exit $OCF_NOT_RUNNING
- fi
- exit $?;;
-
- monitor) pgsql_monitor
- exit $?;;
esac
usage
_______________________________________________________
Linux-HA-Dev: [email protected]
http://lists.linux-ha.org/mailman/listinfo/linux-ha-dev
Home Page: http://linux-ha.org/