Clusterware Console脚本分享

本文分享了一个用于简化Clusterware和RAC测试过程中节点控制的脚本。该脚本可在单一界面上实现对整个集群节点的操作,包括启动/停止堆栈、检查状态等,并支持Linux、Solaris等多个平台。


『作者:RickyZhu 转载务必注明出处和作者』

做Clusterware和RAC的测试的时候,节点多的时候,需要不停的在节点之间切换,而且容易出错,于是写了这样一个脚本,跟大家分享一下。
目前主要完成一些简单的功能,支持的平台有Linux,Solaris, AIX and HP,打算继续扩展。也欢迎使用并提出意见,

[ractest@sun880-1 ~]$ more console
#!/bin/bash

#This script is used to control the whole cluster nodes in one interface

echo "******************************************************************"
echo " Welcome to Cluster Console "
echo " "
echo "The console is used to control the whole cluster nodes in one node"
echo "now it can support start/stop stack,check stack status, process "
echo "priority, check node uptime and will support more in the future "
echo " "
echo " Any bug or comment please report to ricky.zhu@gmail.com "
echo "******************************************************************"

get_nodename () {
$CH/bin/olsnodes -n > tmp
name=`head -n $1 tmp | tail -1 | awk ‘{print $1}’`
echo "$name"
}
check_uptime() {

nl=`$CH/bin/olsnodes `
for node in $nl
do
echo "node=$node"
$RSH $node "hostname; date; /usr/bin/uptime"
done
}

UNAME=‘/bin/uname’
PLATFORM=`$UNAME`
<a id="more-444"></a>
case $PLATFORM in
SunOS)
RSH=/usr/bin/rsh
SSH=/usr/bin/ssh
GREP=/usr/xpg4/bin/grep
PSEF="/usr/bin/ps -cafe"
;;
Linux)
RSH=/usr/bin/rsh
SSH=/usr/bin/ssh
GREP=/bin/grep
PSEF="/bin/ps -cafe"
;;
HP-UX)
RSH=/usr/bin/remsh
SSH=/usr/bin/ssh
GREP=/usr/bin/grep
PSEF="/usr/bin/ps -afe"
CH=$CRS_HOME
;;
AIX)
RSH=/bin/rsh
SSH=/bin/ssh
GREP=/bin/grep
PSEF="/bin/ps -afe"
CH=$CRS_HOME
;;
esac


nodelist=`$CH/bin/olsnodes`
nl="$nodelist All"

PS3="Please select node: "
TITLE="\******************************************************************/"

select node in $nl
do
PS3="Please select command: "
# name=`get_nodename $node`
name=$node

if [[ $node == "All" ]]
then
select command in "Start the crs stack" "Stop the crs stack" "Back" "Quit"
do
case $command in
"Start the crs stack")
echo $TITLE
echo "Now to start crs on node: $name"
for name in $nodelist
do
$RSH $name "hostname; date; $CH/bin/crsctl start crs"
done
echo $TITLE
;;
"Stop the crs stack")
echo $TITLE
echo "Now to stop crs on node: $name"
for name in $nodelist
do
$RSH $name "hostname; date; $CH/bin/crsctl stop crs"
done
echo $TITLE
;;
"Back")
PS3="Please select node: "
echo "Back to cluster node list"
break
;;
Quit)
echo "Quit. Thanks for using."
exit 0
;;
esac
done
fi

$RSH $name date
if [[ $? == 0 ]]
then
RSH=$RSH
else
RSH=$SSH
fi


select command in "Start the crs stack" "Stop the crs stack" "Check stack status" "Check process priority" "Check node uptime" "
Back to nodelist" "User command" "Enable the crs next reboot" "Disable the crs next reboot" "Stop ASM instance" "Start ASM instance"
"Start nodeapps" "Stop nodeapps" "Start listener" "Stop listener" "Quit"
do
case $command in
"Start the crs stack")
echo $TITLE
echo "Now to start crs on node: $name"
$RSH $name "hostname; date; $CH/bin/crsctl start crs"
echo $TITLE
;;
"Stop the crs stack")
echo $TITLE
echo "Now to stop crs on node: $name"
$RSH $name "hostname; date; $CH/bin/crsctl stop crs"
echo $TITLE
;;
"Check stack status")
echo $TITLE
echo "Now to check crs on node: $name"
$RSH $name "hostname; date; $CH/bin/crs_stat -t -v"
echo $TITLE
;;
"Check process priority")
echo $TITLE
echo "Now check priority on node: $name"
$RSH $name "hostname;date; $PSEF | $GREP -e lmon -e dlm -e ucmm -e ocssd.bin -e oclsomon -e oprocd -e oclsvmon -e lms -e lmo
n | $GREP -v grep | $GREP -v tail"
echo $TITLE
;;
"Check node uptime")
echo $TITLE
echo "Now check all node uptime"
check_uptime;
echo $TITLE
;;
"User command")
echo $TITLE
echo "Input your command"
read cmd
source .profile; $RSH $name "hostname; date; $cmd"
echo $TITLE
;;
"Back to nodelist")
PS3="Please select node: "
echo "Back to cluster node list"
break
;;
"Enable the crs next reboot")
echo $TITLE
echo "Now enable crs on next reboot on node: $name"
$RSH $name "hostname;date; /etc/init.d/init.crs enable"
echo $TITLE
;;
"Disable the crs next reboot")
echo $TITLE
echo "Now disable crs on next reboot on node: $name"
$RSH $name "hostname;date; /etc/init.d/init.crs disable"
echo $TITLE
;;
"Stop ASM instance")
echo $TITLE
echo "Now stop ASM instance on node: $name"
$RSH $name "hostname;date; $CH/bin/srvctl stop asm -n $name"
echo $TITLE
;;
"Start ASM instance")
echo $TITLE
echo "Now start ASM instance on node: $name"
$RSH $name "hostname;date; $CH/bin/srvctl start asm -n $name"
echo $TITLE
;;
"Start nodeapps")
echo $TITLE
echo "Now start nodeapps on node: $name"
$RSH $name "hostname;date; $CH/bin/srvctl start nodeapps -n $name"
echo $TITLE
;;
"Stop nodeapps")
echo $TITLE
echo "Now stop nodeapps on node: $name"
$RSH $name "hostname;date; $CH/bin/srvctl stop nodeapps -n $name"
echo $TITLE
;;
"Stop listener")
echo $TITLE
echo "Now stop listener on node: $name"
$RSH $name "hostname;date; $CH/bin/srvctl stop listener -n $name"
echo $TITLE
;;
"Start listener")
echo $TITLE
echo "Now start listener on node: $name"
$RSH $name "hostname;date; $CH/bin/srvctl start listener -n $name"
echo $TITLE
;;
Quit)
echo "Quit. Thanks for using."
exit 0
;;
*)
echo "$REPLY is not one of your choice" 1>&2
;;
esac
done
done

本文来源于天行健,君子以自强不息 http://www.rickyzhu.com , 原文地址: http://www.rickyzhu.com/444_cluster-console-script.html

./runInstaller -silent -responseFile /opt/src/database/response/db_install.rsp -ignorePrereqFailure Starting Oracle Universal Installer... Checking Temp space: must be greater than 120 MB. Actual 82926 MB Passed Checking swap space: must be greater than 150 MB. Actual 1906 MB Passed Preparing to launch Oracle Universal Installer from /tmp/OraInstall2025-10-15_10-26-01AM. Please wait ...[oracle@localhost database]$ The command line arguments '-ignorePrereqFailure' are not valid options. Type 'oui -help' at the command line for instructions on appropriate command line usage. Usage: runInstaller [-options] [(<CommandLineVariable=Value>)*] Where options include: -clusterware oracle.crs,<crs version> Version of Cluster ready services installed. -crsLocation <Path> Used only for cluster installs, specifies the path to the crs home location. Specifying this overrides CRS information obtained from central inventory. -invPtrLoc <full path of oraInst.loc> Unix only. To point to a different inventory location. The orainst.loc file contains: inventory_loc=<location of central inventory> inst_group=<> -jreLoc <location> Path where Java Runtime Environment is installed. OUI cannot be run without it. -logLevel <level> To filter log messages that have a lesser priority level than <level>. Valid options are: severe, warning, info, config, fine, finer, finest, basic, general, detailed, trace. The use of basic, general, detailed, trace is deprecated. -paramFile <location of file> Specify location of oraparam.ini file to be used by OUI. -responseFile <Path> Specifies the response file and path to use. -attachHome For attaching homes to the OUI inventory. -cfs Indicates that the Oracle home specified is on cluster file system (shared). This is mandatory when '-local' is specified so that Oracle Universal Installer can register the home appropriately into the inventory. -clone For making an Oracle Home copy match its current environment. -debug For getting the debug information from OUI. -detachHome For detaching homes from the OUI inventory without deleting inventory directory inside Oracle home. -enableRollingUpgrade Used in cluster environment, to enable upgrade of a product on a subset of nodes (on which the product was installed). -executeSysPrereqs Execute system pre-requisite checks and exit. -force Allowing silent mode installation into a non-empty directory. -help Displays above usage. -ignoreSysPrereqs For ignoring the results of the system pre-requisite checks. -local Performs the operation on the local node irrespective of the cluster nodes specified. -printdiskusage Log debug information for disk usage. -printmemory Log debug information for memory usage. -printtime Log debug information for time usage. -relink For performing relink actions on the oracle home Usage: -relink -maketargetsxml <location of maketargetsxml> [-makedepsxml <location of makedepsxml>] [name=value] -silent For silent mode operations, the inputs can be a response file or a list of command line variable value pairs. -waitforcompletion Installer will wait for completion instead of spawning the java engine and exiting. -suppressPreCopyScript Suppress the execution of precopy script. -acceptUntrustedCertificates Accept untrusted certificates from a secure site. -suppressPostCopyScript Suppress the execution of postcopy script. -noconfig Do not execute config tools. -noconsole For suppressing display of messages to console. Console is not allocated. -formCluster To install the Oracle clusterware in order to form the cluster. -remotecp <Path> Unix specific option. Used only for cluster installs, specifies the path to the remote copy program on the local cluster node. -remoteshell <Path> Unix specific option. Used only for cluster installs, specifies the path to the remote shell program on the local cluster node. -executePrereqs To execute only the prerequisite checks. -ignorePrereq To ignore running the prerequisite checks. -ignoreInternalDriverError To ignore any internal driver errors. -downloadUpdates To download updates only. -showProgress To show the installation progress on the console. This option is supported only in case of silent installation. Command Line Variables Usage Command line variables are specified using <name=value>; for example: [ session: | compName: | compName:version: ]variableName=" valueOfVariable"] Session/Installer variables are specified using: [session:]varName=value Ex 1: session:ORACLE_HOME_NAME="OraHome" Ex 2: ORACLE_HOME_NAME="OraHome" The lookup order is session:varName then just varName. The session prefix is used to avoid ambiguity. Component variables are specified using: [compInternalName:[Version:]]varName Ex 1: oracle.comp1:1.0.1:varName="VarValue" Ex 2: oracle.comp1:varName="VarValue" The lookup order is compInternalName:Version:varName, then compInternalName:varName, then just varName.
最新发布
10-16
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值