我这个postgresql服务启动脚本在/etc/init.d/目录下,我用service postgresql start启动postgresql可以正常启动和关闭。
8 个解决方案
#1
把/etc/init.d/postgresql 拷贝到/etc/ha.d/resource.d 并且chmod +x /etc/ha.d/resource.d/postgresql
#2
还是不行,我的haresource文件时这样的:
node1.localdomain IPaddr::192.168.126.200/24/eth1/ drbddisk::pgdata Filesystem::/dev/drbd1::/usr/local/pgdata::ext4 postgresql
我开启heartbeat服务后执行完ilesystem::/dev/drbd1::/usr/local/pgdata::ext4后没有执行start postgresql服务,我手动将postgresql开启,关闭heartbeat服务就不会出现ERROR: Return code 1 from /etc/init.d/postgresql的错误,而且系统正常,不会自动重启。下面是我postgresql的脚本:
#! /bin/sh
# chkconfig: 2345 68 02
# description: PostgreSQL RDBMS
# This is an example of a start/stop script for SysV-style init, such
# as is used on Linux systems. You should edit some of the variables
# and maybe the 'echo' commands.
#
# Place this file at /etc/init.d/postgresql (or
# /etc/rc.d/init.d/postgresql) and make symlinks to
# /etc/rc.d/rc0.d/K02postgresql
# /etc/rc.d/rc1.d/K02postgresql
# /etc/rc.d/rc2.d/K02postgresql
# /etc/rc.d/rc3.d/S98postgresql
# /etc/rc.d/rc4.d/S98postgresql
# /etc/rc.d/rc5.d/S98postgresql
# Or, if you have chkconfig, simply:
# chkconfig --add postgresql
#
# Proper init scripts on Linux systems normally require setting lock
# and pid files under /var/run as well as reacting to network
# settings, so you should treat this with care.
# Original author: Ryan Kirkpatrick <pgsql@rkirkpat.net>
# $PostgreSQL: pgsql/contrib/start-scripts/linux,v 1.8 2006/07/13 14:44:33 petere Exp $
## EDIT FROM HERE
# Installation prefix
prefix=/usr/local/pgsql
# Data directory
PGDATA="/usr/local/pgsql/data"
# Who to run the postmaster as, usually "postgres". (NOT "root")
PGUSER=postgres
# Where to keep a log file
PGLOG="$PGDATA/serverlog"
## STOP EDITING HERE
# The path that is to be used for the script
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# What to use to start up the postmaster (we do NOT use pg_ctl for this,
# as it adds no value and can cause the postmaster to misrecognize a stale
# lock file)
DAEMON="$prefix/bin/postmaster"
# What to use to shut down the postmaster
PGCTL="$prefix/bin/pg_ctl"
set -e
# Only start if we can find the postmaster.
test -x $DAEMON || exit 0
# Parse command line parameters.
case $1 in
start)
echo -n "Starting PostgreSQL: "
su - $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1
echo "ok"
;;
stop)
echo -n "Stopping PostgreSQL: "
su - $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast"
echo "ok"
;;
restart)
echo -n "Restarting PostgreSQL: "
su - $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast -w"
su - $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1
echo "ok"
;;
reload)
echo -n "Reload PostgreSQL: "
su - $PGUSER -c "$PGCTL reload -D '$PGDATA' -s"
echo "ok"
;;
status)
su - $PGUSER -c "$PGCTL status -D '$PGDATA'"
;;
*)
# Print help
echo "Usage: $0 {start|stop|restart|reload|status}" 1>&2
exit 1
;;
esac
exit 0
求解决啊,急急急!
#3
heartbeat 什么版本?看看运行日志里面有什么信息不 /var/log/ha-log
#4
我用的heartbeat版本是4.0.3,
/var/log/ha-log日志里面没有显示/etc/init.d/postgresql打印信息,执行完其他几个脚本IPaddr、drbddisk和Filesystem之后就直接complete了,
我在/etc/init.d/postgresql脚本里面加了一些打印信息,我执行service heartbeat start之后,能看到这些打印信息,但是执行的命令并不是/etc/init.d/postgresql start,而是/etc/init.d/postgresql status,这让我很费解,因为我单独使用service 和/etc/init.d/postgresql start是完全没问题的。
#5
打错了 我用的heartbeat是3.0.4版本
#6
heartbeat 3 貌似不再使用haresources文件,好像使用一个cib.xml配置文件来管理资源
#7
我也是第一次搞,都是参考的网上的资料,但是我在haresource里面把postgresql替换成其他的服务脚本却可以正常启动和关闭服务!
#8
问题解决了,不能使用安装postgresql生成的启动脚本,使用安装heartbeat服务后安装目录中自带的ocf脚本能够运行!
#1
把/etc/init.d/postgresql 拷贝到/etc/ha.d/resource.d 并且chmod +x /etc/ha.d/resource.d/postgresql
#2
还是不行,我的haresource文件时这样的:
node1.localdomain IPaddr::192.168.126.200/24/eth1/ drbddisk::pgdata Filesystem::/dev/drbd1::/usr/local/pgdata::ext4 postgresql
我开启heartbeat服务后执行完ilesystem::/dev/drbd1::/usr/local/pgdata::ext4后没有执行start postgresql服务,我手动将postgresql开启,关闭heartbeat服务就不会出现ERROR: Return code 1 from /etc/init.d/postgresql的错误,而且系统正常,不会自动重启。下面是我postgresql的脚本:
#! /bin/sh
# chkconfig: 2345 68 02
# description: PostgreSQL RDBMS
# This is an example of a start/stop script for SysV-style init, such
# as is used on Linux systems. You should edit some of the variables
# and maybe the 'echo' commands.
#
# Place this file at /etc/init.d/postgresql (or
# /etc/rc.d/init.d/postgresql) and make symlinks to
# /etc/rc.d/rc0.d/K02postgresql
# /etc/rc.d/rc1.d/K02postgresql
# /etc/rc.d/rc2.d/K02postgresql
# /etc/rc.d/rc3.d/S98postgresql
# /etc/rc.d/rc4.d/S98postgresql
# /etc/rc.d/rc5.d/S98postgresql
# Or, if you have chkconfig, simply:
# chkconfig --add postgresql
#
# Proper init scripts on Linux systems normally require setting lock
# and pid files under /var/run as well as reacting to network
# settings, so you should treat this with care.
# Original author: Ryan Kirkpatrick <pgsql@rkirkpat.net>
# $PostgreSQL: pgsql/contrib/start-scripts/linux,v 1.8 2006/07/13 14:44:33 petere Exp $
## EDIT FROM HERE
# Installation prefix
prefix=/usr/local/pgsql
# Data directory
PGDATA="/usr/local/pgsql/data"
# Who to run the postmaster as, usually "postgres". (NOT "root")
PGUSER=postgres
# Where to keep a log file
PGLOG="$PGDATA/serverlog"
## STOP EDITING HERE
# The path that is to be used for the script
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
# What to use to start up the postmaster (we do NOT use pg_ctl for this,
# as it adds no value and can cause the postmaster to misrecognize a stale
# lock file)
DAEMON="$prefix/bin/postmaster"
# What to use to shut down the postmaster
PGCTL="$prefix/bin/pg_ctl"
set -e
# Only start if we can find the postmaster.
test -x $DAEMON || exit 0
# Parse command line parameters.
case $1 in
start)
echo -n "Starting PostgreSQL: "
su - $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1
echo "ok"
;;
stop)
echo -n "Stopping PostgreSQL: "
su - $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast"
echo "ok"
;;
restart)
echo -n "Restarting PostgreSQL: "
su - $PGUSER -c "$PGCTL stop -D '$PGDATA' -s -m fast -w"
su - $PGUSER -c "$DAEMON -D '$PGDATA' &" >>$PGLOG 2>&1
echo "ok"
;;
reload)
echo -n "Reload PostgreSQL: "
su - $PGUSER -c "$PGCTL reload -D '$PGDATA' -s"
echo "ok"
;;
status)
su - $PGUSER -c "$PGCTL status -D '$PGDATA'"
;;
*)
# Print help
echo "Usage: $0 {start|stop|restart|reload|status}" 1>&2
exit 1
;;
esac
exit 0
求解决啊,急急急!
#3
heartbeat 什么版本?看看运行日志里面有什么信息不 /var/log/ha-log
#4
我用的heartbeat版本是4.0.3,
/var/log/ha-log日志里面没有显示/etc/init.d/postgresql打印信息,执行完其他几个脚本IPaddr、drbddisk和Filesystem之后就直接complete了,
我在/etc/init.d/postgresql脚本里面加了一些打印信息,我执行service heartbeat start之后,能看到这些打印信息,但是执行的命令并不是/etc/init.d/postgresql start,而是/etc/init.d/postgresql status,这让我很费解,因为我单独使用service 和/etc/init.d/postgresql start是完全没问题的。
#5
打错了 我用的heartbeat是3.0.4版本
#6
heartbeat 3 貌似不再使用haresources文件,好像使用一个cib.xml配置文件来管理资源
#7
我也是第一次搞,都是参考的网上的资料,但是我在haresource里面把postgresql替换成其他的服务脚本却可以正常启动和关闭服务!
#8
问题解决了,不能使用安装postgresql生成的启动脚本,使用安装heartbeat服务后安装目录中自带的ocf脚本能够运行!