注册

主备切换脚本问题

潘儿 2023/09/27 797 6

为提高效率,提问时请提供以下信息,问题描述清晰可优先响应。
【DM版本】:DM8
【操作系统】:centos7
【CPU】:2
【问题描述】*:要了个主备切换脚本,但是执行不下去,看不懂哪儿的问题

#!/bin/sh
###############################################
#程序功能:该脚本用于切换dm数据库 ##
#修改时间: 2023-8-18 ##
###############################################
set -x

##配置文件名,数据库名##
ininame=dmmonitor.ini
##实例名##
INSTANCE_NAME=DM02
##密码
SYSDBAPWD=SYSDBA

function log
{
logcontent=$*
echo "[date +'%Y-%m-%d %T']😒{logcontent}"
}

function CHECK
{
echo "0"
}

function SWITCH
{
cd /dm8/bin
./dmmonitor path=/dm8/bin/${ininame} <<EOF
login
SYSDBA
${SYSDBAPWD}
/usr/bin/expect <<AAA
set timeout -1
expect "assword:"
send \x03

expect eof
exit

AAA

switchover ${INSTANCE_NAME}

exit

EOF
}

function FORCE
{
echo "0"
}

###################################################################################################
#脚本入口
###################################################################################################
vSwitch=switch
##检查服务状态的命令

case ${vSwitch} in
check)
CHECK
;;
switch)
SWITCH
;;
force)
FORCE
;;
*)
echo "Usage: sh $0 [check/switch/force]"
;;
esac

日志为:

[dmdba@loaclhost ~]$ sh dmqiehuan.sh

  • ininame=dmmonitor.ini
  • INSTANCE_NAME=DM02
  • SYSDBAPWD=SYSDBA
  • vSwitch=switch
  • case ${vSwitch} in
  • SWITCH
  • cd /dm8/bin
  • ./dmmonitor path=/dm8/bin/dmmonitor.ini
    [monitor] 2023-09-27 16:33:24: DMMONITOR[4.0] V8
    [monitor] 2023-09-27 16:33:24: DMMONITOR[4.0] IS READY.

[monitor] 2023-09-27 16:33:24: Received message from(DM01)
WTIME WSTATUS INST_OK INAME ISTATUS IMODE RSTAT N_OPEN FLSN CLSN
2023-09-27 16:33:24 OPEN OK DM01 OPEN PRIMARY VALID 2 39925 39925

[monitor] 2023-09-27 16:33:24: Received message from(DM02)
WTIME WSTATUS INST_OK INAME ISTATUS IMODE RSTAT N_OPEN FLSN CLSN
2023-09-27 16:33:24 OPEN OK DM02 OPEN STANDBY VALID 2 39925 39925

Input command illegal, list the correct usage as follows:
(if it is not the command you need, please input help to get other commands' help information)
#----------------------------------------------------------------------------------#
login
--login dmmonitor
#----------------------------------------------------------------------------------#

Input command illegal, please input help to get the help information!

Input command illegal, please input help to get the help information!

Input command illegal, please input help to get the help information!

Input command illegal, please input help to get the help information!

Input command illegal, please input help to get the help information!

Input command illegal, please input help to get the help information!

Input command illegal, please input help to get the help information!

Input command illegal, please input help to get the help information!

Input command illegal, please input help to get the help information!

Input command illegal, list the correct usage as follows:
(if it is not the command you need, please input help to get other commands' help information)
#----------------------------------------------------------------------------------#
exit
--exit dmmonitor
#----------------------------------------------------------------------------------#

Input command illegal, please input help to get the help information!

Input command illegal, please input help to get the help information!

Input command illegal, list the correct usage as follows:
(if it is not the command you need, please input help to get other commands' help information)
#----------------------------------------------------------------------------------#
switchover [group_name[.]] [db_name]
--switchover specified database of specified group as primary database
#----------------------------------------------------------------------------------#

Input command illegal, please input help to get the help information!

Input command illegal, list the correct usage as follows:
(if it is not the command you need, please input help to get other commands' help information)
#----------------------------------------------------------------------------------#
exit
--exit dmmonitor
#----------------------------------------------------------------------------------#

回答 0
暂无回答
扫一扫
联系客服