pacemaker corosync lsb 资源脚本(Sybase 数据库 ASE 服务器和备份服务器)

pacemaker corosync lsb 资源脚本(Sybase 数据库 ASE 服务器和备份服务器)

我正在尝试在 rhel7.2 上使用 pcs 创建 lsb 资源 “sybase”脚本是关于 Sybase 数据库 ASE 服务器和备份服务器启动 & 停止 & 重新启动 $ 状态脚本

[root@pldbsv01 ~]# pcs status 
    Cluster name: PLDBSV_CLUSTER
    Last updated: Tue Apr 19 23:18:44 2016      Last change: Tue Apr 19 22:59:07 2016 by root via cibadmin on pldbsv02-cr
    Stack: corosync
    Current DC: pldbsv02-cr (version 1.1.13-10.el7-44eb2dd) - partition with quorum
    2 nodes and 9 resources configured
    
    Online: [ pldbsv01-cr pldbsv02-cr ]
    
    Full list of resources:
    
     Resource Group: PLDBSV_RESOURCE
         PLDBSV_VIP (ocf::heartbeat:IPaddr2):   Started pldbsv01-cr
     idrac-pldbsv01 (stonith:fence_ipmilan):    Started pldbsv02-cr
     idrac-pldbsv02 (stonith:fence_ipmilan):    Started pldbsv01-cr
     Clone Set: dlm-clone [dlm]
         Started: [ pldbsv01-cr ]
         Stopped: [ pldbsv02-cr ]
     Clone Set: clvmd-clone [clvmd]
         Started: [ pldbsv01-cr ]
         Stopped: [ pldbsv02-cr ]
     Clone Set: gfs2sybasedata_res-clone [gfs2sybasedata_res]
         Started: [ pldbsv01-cr ]
         Stopped: [ pldbsv02-cr ]
    
    PCSD Status:
      pldbsv01-cr: Online
      pldbsv02-cr: Online
    
    Daemon Status:
      corosync: active/enabled
      pacemaker: active/enabled
      pcsd: active/enabled

我添加 sybase lsb 资源调用 ase157_res

[root@pldbsv01 ~]# pcs resource create ase157_res lsb:sybase op monitor interval=30s
[root@pldbsv01 ~]# pcs constraint order start gfs2sybasedata_res-clone then ase157_res
    Adding gfs2sybasedata_res-clone ase157_res (kind: Mandatory) (Options: first-action=start then-action=start)
    
[root@pldbsv01 ~]# pcs constraint colocation add ase157_res with gfs2sybasedata_res-clone
[root@pldbsv01 ~]# pcs status
Cluster name: PLDBSV_CLUSTER
Last updated: Wed Apr 20 12:22:51 2016      Last change: Wed Apr 20 12:20:18 2016 by root via cibadmin on pldbsv01-cr
Stack: corosync
Current DC: pldbsv01-cr (version 1.1.13-10.el7-44eb2dd) - partition with quorum
2 nodes and 10 resources configured

Online: [ pldbsv01-cr pldbsv02-cr ]

Full list of resources:

 Resource Group: PLDBSV_RESOURCE
     PLDBSV_VIP (ocf::heartbeat:IPaddr2):   Started pldbsv02-cr
 idrac-pldbsv01 (stonith:fence_ipmilan):    Started pldbsv01-cr
 idrac-pldbsv02 (stonith:fence_ipmilan):    Started pldbsv01-cr
 Clone Set: dlm-clone [dlm]
     Started: [ pldbsv02-cr ]
     Stopped: [ pldbsv01-cr ]
 Clone Set: clvmd-clone [clvmd]
     Started: [ pldbsv02-cr ]
     Stopped: [ pldbsv01-cr ]
 Clone Set: gfs2sybasedata_res-clone [gfs2sybasedata_res]
     Started: [ pldbsv02-cr ]
     Stopped: [ pldbsv01-cr ]
 ase157_res (lsb:sybase):   Stopped

Failed Actions:
* ase157_res_start_0 on pldbsv02-cr 'unknown error' (1): call=41, status=Timed Out, exitreason='none',
    last-rc-change='Wed Apr 20 12:21:35 2016', queued=0ms, exec=20002ms
* ase157_res_start_0 on pldbsv01-cr 'unknown error' (1): call=45, status=Timed Out, exitreason='none',
    last-rc-change='Wed Apr 20 12:19:56 2016', queued=0ms, exec=20002ms


PCSD Status:
  pldbsv01-cr: Online
  pldbsv02-cr: Online

Daemon Status:
  corosync: active/enabled
  pacemaker: active/enabled
  pcsd: active/enabled

错误

失败的操作:

  • pldbsv02-cr 上的 ase157_res_start_0“未知错误”(1): call=41、status=Timed Out、exitreason='none'、last-rc-change='Wed Apr 20 12:21:35 2016'、queued=0ms、exec=20002ms
  • pldbsv01-cr 上的 ase157_res_start_0“未知错误”(1): call=45、status=Timed Out、exitreason='none'、last-rc-change='Wed Apr 20 12:19:56 2016'、queued=0ms、exec=20002ms

所以我按照附录 G. 初始化脚本 LSB 合规性检查我的 sybase 脚本。

当我测试这些步骤中的第 5 项时,我的输出打印结果:0

状态(已停止):

/etc/init.d/some_service 状态;回显“结果:$?”

我的问题:

  • 脚本是否接受了命令?
  • 脚本是否表明服务未运行?
  • 该命令是否打印结果:3(除了其通常的输出)?
  • 我该如何修复它?
#!/bin/sh
#
# Startup script for Sybase ASE
# Description: Service script for starting/stopping/monitoring \
#              Sybase Adaptive Server on: \
#                            Red Hat Enterprise Linux 6 \
# Release date 2015-08-11
# Version 1 
# Processname: dataserver
# (1) Before running this script, we assume that user has installed
#     Sybase ASE 15.0.2 or higher version on the machine.
# (2) This script should be put under /etc/init.d. Its owner should be "root" with 
#     execution permission.
# (3) You must define the variables "SYBASE" "SERVER" BACKUPSERVER"
# (4) You can change Adaptive Server login name and password in line 96,
#     defaults are "sa" and "sybase"



SYBASE=/opt/sybase
SERVER=PLDBSV
BACKUPSERVER=PLDBSV_BS

# Source environment variables.
. $SYBASE/SYBASE.sh


# Find the name of the script
NAME=`basename $0`


# For SELinux we need to use 'runuser' not 'su'
if [ -x /sbin/runuser ]
then
  SU=runuser
else
  SU=su
fi


# Start sybase Adaptive Server and Backup Server
start() {
  SYBASE_ASE_START=$"Starting ${NAME} Adaptive Server: "
  $SU sybase -c ". $SYBASE/SYBASE.sh; $SYBASE/$SYBASE_ASE/install/startserver \
-f $SYBASE/$SYBASE_ASE/install/RUN_${SERVER} > /dev/null"
  ret=$? 
  if [ $ret -eq 0 ]
  then    
      echo -n "$SYBASE_ASE_START                    ["
      echo -n -e "\033[32m Success \033[0m"  
      echo "]"
  else
      echo -n "$SYBASE_ASE_START           ["
      echo -n -e "\033[31m Failed \033[0m"
      echo "]"
                exit 1
  fi
  
  for ((i=1; i<31; i++))
  do
        sleep 1
        echo "waitting $i sec to prepare Backup Server!"
  done
  
  SYBASE_BS_START=$"Starting ${NAME} Backup Server: "
  $SU sybase -c ". $SYBASE/SYBASE.sh; $SYBASE/$SYBASE_ASE/install/startserver \
-f $SYBASE/$SYBASE_ASE/install/RUN_${BACKUPSERVER} > /dev/null"
  ret=$? 
  if [ $ret -eq 0 ]
  then
      echo -n "$SYBASE_BS_START                    ["
      echo -n -e "\033[32m Success \033[0m"
      echo "]"
  else
      echo -n "$SYBASE_BS_START                    ["
      echo -n -e "\033[31m Failed \033[0m"
      echo "]"
                exit 1
  fi  
}

#stop sybase adaptive server and backup server
stop() {
  SYBASE_BS_STOP=$"Stopping ${NAME} Backup Server"
  pid=$(pidof backupserver)
  if [ $pid > 0 ]
  then
  $SU root -c "kill -9 $pid > /dev/null"
      echo -n "$SYBASE_BS_STOP                     ["
      echo -n -e "\033[32m Success \033[0m"
      echo "]"
  else
      echo -n "$SYBASE_BS_STOP                     ["
      echo -n -e "\033[31m Failed \033[0m"
      echo "]"
  fi
 
  SYBASE_ASE_STOP=$"Stopping ${NAME} Adaptive Server: "
  $SU sybase -c ". $SYBASE/SYBASE.sh; isql -S $SERVER -U sa -P sybase < \
$SYBASE/$SYBASE_ASE/upgrade/shutdown.sql > /dev/null"
  ret=$?
  if [ $ret -eq 0 ]
  then
      echo -n "$SYBASE_ASE_STOP            ["
      echo -n -e "\033[32m Success \033[0m"
      echo "]"
  else
      echo -n "$SYBASE_ASE_STOP            ["
      echo -n -e "\033[31m Failed \033[0m"
      echo "]"
      exit 1
  fi
}

restart() {
  stop
  start
}

# Check Sybase Adaptive Server and Backup Server status
status() {
  dataserver=$(pidof dataserver)
  backupserver=$(pidof backupserver)
  if [ -n "$dataserver" ]; then
      echo "sybase Adaptive Server is running!" && exit 0 || exit $?
  else
      echo "sybase Adaptive Server is stopped!"
      
  fi

  if [ -n "$backupserver" ]; then     
      echo "sybase Backup Server is running!" && exit 0 || exit $?
  else
      echo "sybase Backup Server is stopped!"
      exit 1
  fi
}

case "$1" in
  start)
      start
      ;;
  stop)
      stop
      ;;
  restart)
      restart
      ;;
  status) 
      status
      ;;
  *)
      echo $"Usage: $0 {start|stop|restart|status}"
      exit 1
esac

剧本全部通过LSB 兼容,但是它不起作用!

#!/bin/sh
#
# Startup script for Sybase ASE
# Description: Service script for starting/stopping/monitoring \
#              Sybase Adaptive Server on: \
#                            Red Hat Enterprise Linux 6 \
# Release date 2015-08-11
# Version 1 
# Processname: dataserver
# (1) Before running this script, we assume that user has installed
#     Sybase ASE 15.0.2 or higher version on the machine.
# (2) This script should be put under /etc/init.d. Its owner should be "root" with 
#     execution permission.
# (3) You must define the variables "SYBASE" "SERVER" BACKUPSERVER"
# (4) You can change Adaptive Server login name and password in line 96,
#     defaults are "sa" and "sybase"



SYBASE=/opt/sybase
SERVER=PLDBSV
BACKUPSERVER=PLDBSV_BS

# Source environment variables.
. $SYBASE/SYBASE.sh


# Find the name of the script
NAME=`basename $0`


# For SELinux we need to use 'runuser' not 'su'
if [ -x /sbin/runuser ]
then
    SU=runuser
else
    SU=su
fi


# Start sybase Adaptive Server and Backup Server
start() {
    SYBASE_ASE_START=$"Starting ${NAME} Adaptive Server: "
    $SU sybase -c ". $SYBASE/SYBASE.sh; $SYBASE/$SYBASE_ASE/install/startserver \
-f $SYBASE/$SYBASE_ASE/install/RUN_${SERVER} > /dev/null"
    ret=$? 
    if [ $ret -eq 0 ]
    then    
        echo -n "$SYBASE_ASE_START                    ["
        echo -n -e "\033[32m Success \033[0m"  
        echo "]"
    else
        echo -n "$SYBASE_ASE_START           ["
        echo -n -e "\033[31m Failed \033[0m"
        echo "]"
                exit 1
    fi
    
    for ((i=1; i<31; i++))
    do
        sleep 1
        echo "waitting $i sec to prepare Backup Server!"
    done
    
    SYBASE_BS_START=$"Starting ${NAME} Backup Server: "
    $SU sybase -c ". $SYBASE/SYBASE.sh; $SYBASE/$SYBASE_ASE/install/startserver \
-f $SYBASE/$SYBASE_ASE/install/RUN_${BACKUPSERVER} > /dev/null"
    ret=$? 
    if [ $ret -eq 0 ]
    then
        echo -n "$SYBASE_BS_START                    ["
        echo -n -e "\033[32m Success \033[0m"
        echo "]"
    else
        echo -n "$SYBASE_BS_START                    ["
        echo -n -e "\033[31m Failed \033[0m"
        echo "]"
                exit 1
    fi  
}

#stop sybase adaptive server and backup server
stop() {
    SYBASE_BS_STOP=$"Stopping ${NAME} Backup Server"
    pid=$(pidof backupserver)
    if [ $pid > 0 ]
    then
    $SU root -c "kill -9 $pid > /dev/null"
        echo -n "$SYBASE_BS_STOP                     ["
        echo -n -e "\033[32m Success \033[0m"
        echo "]"
    else
        echo -n "$SYBASE_BS_STOP                     ["
        echo -n -e "\033[31m Failed \033[0m"
        echo "]"
    fi
 
    SYBASE_ASE_STOP=$"Stopping ${NAME} Adaptive Server: "
    $SU sybase -c ". $SYBASE/SYBASE.sh; isql -S $SERVER -U sa -P sybase < \
$SYBASE/$SYBASE_ASE/upgrade/shutdown.sql > /dev/null"
    ret=$?
    if [ $ret -eq 0 ]
    then
        echo -n "$SYBASE_ASE_STOP            ["
        echo -n -e "\033[32m Success \033[0m"
        echo "]"
    else
        echo -n "$SYBASE_ASE_STOP            ["
        echo -n -e "\033[31m Failed \033[0m"
        echo "]"
        exit 0
    fi
}

restart() {
    stop
    start
}

# Check Sybase Adaptive Server and Backup Server status
status() {
    dataserver=$(pidof dataserver)
    backupserver=$(pidof backupserver)
    if [ -n "$dataserver" ]; then
        echo "sybase Adaptive Server is running!"
    else
        echo "sybase Adaptive Server is stopped!" 
                
    fi

    if [ -n "$backupserver" ]; then     
        echo "sybase Backup Server is running!" && exit 0 || exit $?
    else
        echo "sybase Backup Server is stopped!"
        exit 3
    fi
}

case "$1" in
    start)
        start
        ;;
    stop)
        stop
        ;;
    restart)
        restart
        ;;
    status) 
        status
        ;;
    *)
        echo $"Usage: $0 {start|stop|restart|status}"
        exit 1
esac

您对解决这个问题有什么建议吗?

答案1

的結果pcs resource show ase157_resop start timeout="20s"

因为“/etc/init.d/that_script start”需要30秒,所以timeout=肯定不止这个时间。

答案2

您是否尝试过exit 3在脚本的状态函数中简单地添加一个,以使其符合要求?

类似这样的事情应该可以工作:

# Check Sybase Adaptive Server and Backup Server status
status() {
  dataserver=$(pidof dataserver)
  backupserver=$(pidof backupserver)
  if [ -n "$dataserver" ]; then
      echo "sybase Adaptive Server is running!" && exit 0 || exit $?
  else
      echo "sybase Adaptive Server is stopped!"
      exit 3
  fi

  if [ -n "$backupserver" ]; then     
      echo "sybase Backup Server is running!" && exit 0 || exit $?
  else
      echo "sybase Backup Server is stopped!"
      exit 1
  fi
}

編輯0:失败操作用于启动操作。当我尝试调试脚本中失败的原因时,我开始在其中添加“logger”命令,这样我就可以通过查看日志来调试失败的位置/原因。

像这样:

# Start sybase Adaptive Server and Backup Server
start() {
  logger "DEBUG: ENTERED START FUNCTION
  SYBASE_ASE_START=$"Starting ${NAME} Adaptive Server: "
  $SU sybase -c ". $SYBASE/SYBASE.sh; $SYBASE/$SYBASE_ASE/install/startserver \
-f $SYBASE/$SYBASE_ASE/install/RUN_${SERVER} > /dev/null"
  ret=$?
  logger "DEBUG: RETURN CODE: $ret"
  logger "DEBUG: CHECK THE VARS:"
  logger "DEBUG: \$SU=$SU"
  logger "DEBUG: \$SYBASE/SYBASE.sh=$SYBASE/SYBASE.sh"
  logger "DEBUG: \$SYBASE_ASE=$SYBASE_ASE"
  logger "DEBUG: \${SERVER}=${SERVER}"
  if [ $ret -eq 0 ]
  then
      echo -n "$SYBASE_ASE_START                    ["
      echo -n -e "\033[32m Success \033[0m"
      echo "]"
      logger "DEBUG: We're about to leave \$ret -eq 0"
  else
      echo -n "$SYBASE_ASE_START           ["
      echo -n -e "\033[31m Failed \033[0m"
      echo "]"
      logger "DEBUG: We're about to leave \$ret -ne 0"
                exit 1
  fi

然后查看日志(/var/log/messages 或 /var/log/syslog)并查找“DEBUG”消息以确定脚本中哪里出现故障。

相关内容