资源简介
测试过的应用环境:
主库:oracle11gr2 RAC
备库:oracle11gr2 单节点HAS
配置文件(config.ini)说明:
代码片段和文件信息
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
# script: adg_job_confirmdbstatus.sh
#
# Description: The shell script could help oracle dataguard on its auto switchover.
#
#
# Author: haizdl
# Date: 10/26/2016
#
#
import pexpect
import ConfigParser
import getpass
config = ConfigParser.ConfigParser()
config.read(“config.ini“)
#######################################################################################################
## Initialization. #
#######################################################################################################
_pdb = config.get(“pri““pdb“)
_pdm = config.get(“pri““pdm“)
_sdb = config.get(“sty““sdb“)
_sdm = config.get(“sty““sdm“)
_paddr = config.get(“pri““paddr“)
_saddr = config.get(“sty““saddr“)
_paddr_s = config.get(“pri““paddr_s“)
_saddr_s = config.get(“sty““saddr_s“)
_user = config.get(“usr““user“)
_pswd = config.get(“usr““psswd“)
_urpf = config.get(“cof““userpf“)
_dir = config.get(“cof““jhome“)
_cmd_dir = “cd “ + _dir
_cmd_usr = “source “ + _urpf
_cmd_p2s = “sh ADG_P2S.sh “ + _pdb + “ “ + _pdm
_cmd_s2p = “sh ADG_S2P.sh “ + _sdb + “ “ + _sdm
_cmd_res = “sh ADG_RES.sh “ + _pdb
_cmd_opp = “sh dg_open_db.sh “ + _pdb
_cmd_ops = “sh dg_open_db.sh “ + _sdb
#######################################################################################################
## Function: ssh_cmd(IPUSERPASSWDCMD). #
## IP: IP address for command executation. #
## USER: Username of the executation. #
## PASSWORD: User Password. #
## CMD: Comands. #
#######################################################################################################
# funcation ssh_cmd()
def ssh_cmd(ip user passwd cmd):
ret = -1
ssh = pexpect.spawn(‘ssh %s@%s “%s“‘ % (userip cmd)timeout=120)
try:
i = ssh.expect([‘password:‘ ‘continue connecting (yes/no)?‘] timeout=5)
if i == 0 :
ssh.sendline(passwd)
elif i == 1:
ssh.sendline(‘yes\n‘)
ssh.expect(‘password: ‘)
ssh.sendline(passwd)
ssh.sendline(cmd)
r = ssh.read()
print (r)
ret = r
except pexpect.EOF:
print (“EOF“)
ssh.close()
ret = -1
except pexpect.TIMEOUT:
print (“TIMEOUT“)
ssh.close()
ret = -2
return ret
# main().
print (“---------------------------------------------------------------------------------“)
print (“- JOB NAME : ORACLE ACTIVE DATAGARD SWITCH OVER. “)
print (“- AUTHOR : ZHAO HAI(haizdl@126.com).
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 885 2018-03-03 23:26 oradgtool\readme.txt
目录 0 2017-03-28 22:40 oradgtool\
文件 2983 2017-03-28 22:41 oradgtool\ADG_P2S.sh
文件 2542 2017-03-28 22:41 oradgtool\ADG_RES.sh
文件 2991 2017-03-28 22:41 oradgtool\ADG_S2P.sh
文件 221 2017-03-28 22:39 oradgtool\config.ini
文件 2895 2016-12-13 10:16 oradgtool\dg_confirm_db.sh
文件 2014 2016-12-13 10:16 oradgtool\dg_open_db.sh
文件 2095 2016-12-13 10:16 oradgtool\dg_recoverlog_db.sh
文件 3061 2016-12-13 10:16 oradgtool\dg_start2m_db.sh
文件 2626 2016-12-13 10:16 oradgtool\dg_switch2p_db.sh
文件 2635 2016-12-13 10:16 oradgtool\dg_switch2s_db.sh
文件 2720 2016-12-13 09:12 oradgtool\initialization.sh
文件 5584 2017-03-28 22:40 oradgtool\switchadg.py
评论
共有 条评论