But execution of script had a little bug, when one of the RAC nodes is down-script hang! This is why I have added ssh ConnectTimeout parameter which solve this problem fully.
Here is the whole source of changed script:
#!/bin/sh # # # Requirements: # - Make sure the ORA_CRS_HOME / ORACLE_HOME is set to the CRS environment. # - Make sure all the nodes in the cluster can be accessed trough ssh. # Version: # - version 1.0 # - Bernhard de Cock Buning # -> master.sh # -> 1.0 Initial creation of masternode information script. # - www.rachelp.nl / GRID-IT # # -> 1.1 added "-o ConnectTimeout=5" when node is down -script hang otherwise! # - Damir Vadas # - http://damir-vadas.blogspot.com/ #set -x -v #exec >> /tmp/master_node.log 2>&1 ORA_CRS_HOME=$ORACLE_HOME SSH=/usr/bin/ssh NODES=`$ORA_CRS_HOME/bin/olsnodes` HIGHEST_HOSTNAME="" HIGHEST_VALUE=0 for I in $NODES do CURRENT_HOSTNAME=$I CURRENT_VALUE=`$SSH -o ConnectTimeout=5 $I grep clssgmEstablishMasterNode $ORA_CRS_HOME/log/$I/cssd/ocssd.l* | tail -1 | tr -d CSSD] | awk '{print $2 $3}' | tr -d ':.-'` if [[ $(( $(echo $CURRENT_VALUE ) - $(echo $HIGHEST_VALUE ) )) > 0 ]] ; then HIGHEST_VALUE=$CURRENT_VALUE HIGHEST_HOSTNAME=$CURRENT_HOSTNAME fi done MASTERNODE=`$SSH $HIGHEST_HOSTNAME grep clssgmEstablishMasterNode $ORA_CRS_HOME/log/$HIGHEST_HOSTNAME/cssd/ocssd.l* | tail -1 | awk '{print $11}' | tr -d 'node()'` echo "Masternode is node with number: $MASTERNODE" $ORA_CRS_HOME/bin/olsnodes -n
Modified script output in a case when iis2 node is down looks like:
[oracle CRS@iis4 ~]$ master ssh: connect to host iis2 port 22: No route to host Masternode is node with number: 1 iis1 1 iis2 2 iis3 3 iis4 4 [oracle CRS@iis4 ~]$
Hope this helps someone. Cheers!
No comments :
Post a Comment