shell脚本(二)
【摘要】 #强制varyonvg aix系统vg磁盘组。#!/usr/bin/kshusage() { echo "WARNING, use this script AT YOUR OWN RISK" echo " Usage: `basename $*` " }for vgname in $*docfgmgrlsdev -Cc disk|grep Falc |awk '{print $...
#!/usr/bin/ksh usage() { echo "WARNING, use this script AT YOUR OWN RISK" echo " Usage: `basename $*` " } for vgname in $* do cfgmgr lsdev -Cc disk|grep Falc |awk '{print $1}'|sort>/tmp/lsdevname.txt lspv |grep $vgname |awk '{print $1}'|sort>/tmp/lspvname.txt for cdpdisk in `sort /tmp/lsdevname.txt /tmp/lspvname.txt|uniq -d`; do echo "=========================rmdev Defined CDP disk part==========================" rmdev -l $cdpdisk ACCOUNT_LINE01=`lsdev -l $cdpdisk |awk '{print $2}'` if [ "$ACCOUNT_LINE01" = "Defined" ] ; then echo "rmdev $cdpdisk success" else echo "rmdev $cdpdisk fail" exit 1 fi done done sleep 5 echo "============= Force varyonvg ==================================================" ACCOUNT_LINE02=`sort /tmp/lsdevname.txt /tmp/lspvname.txt|uniq -d|wc -l|awk '{print $1}'` if [ "$ACCOUNT_LINE02" -gt "0" ] ; then echo "================Force varyonvg Cdp volume group================================" for vgname in $* do varyonvg -f -O $vgname varyonvg -f $vgname done else echo "Cdp does not protect this volume group!!!!!!" fi for vgname in $* do ACCOUNT_LINE03=`lsvg $vgname |grep "VG STATE"|awk '{print $3}'` if [ "$ACCOUNT_LINE03" = "active" ] ; then echo "Force varyonvg $vgname success" else echo "Force varyonvg $vgname fail" exit 1 fi done sleep 5 echo "=============rescan cdpdisk===================================================" for fc in `lsdev -Cc adapter |grep fcs |awk '{print $1}'`; do cfgmgr -vl $fc done sleep 5 echo "=============active cdpdisk===================================================" for vgname in $* do lsdev -Cc disk|grep Falc |awk '{print $1}'|sort>/tmp/lsdevname.txt lspv |grep $vgname |awk '{print $1}'|sort>/tmp/lspvname.txt for cdpdisk in `sort /tmp/lsdevname.txt /tmp/lspvname.txt|uniq -d`; do chpv -v r $cdpdisk chpv -v a $cdpdisk ACCOUNT_LINE04=`lspv $cdpdisk |grep "PV STATE"|awk '{print $3}'` if [ "$ACCOUNT_LINE04" = "active" ] ; then echo "active $cdpdisk Success" else echo "active $cdpdisk Fail" exit 1 fi done done echo "============= varyoffvg ====================================================" ACCOUNT_LINE05=`sort /tmp/lsdevname.txt /tmp/lspvname.txt|uniq -d|wc -l|awk '{print $1}'` if [ "$ACCOUNT_LINE05" -gt "0" ] ; then echo "===========varyoffvg Cdp volume group==========================================" for vgname in $* do varyoffvg $vgname done else echo "===========Cdp does not protect this volume group================================" fi for vgname in $* do ACCOUNT_LINE06=`lsvg -o|grep $vgname |wc -l|awk '{print $1}'` if [ "$ACCOUNT_LINE06" = "0" ] ; then echo "varyoffvg $vgname Success" else echo "varyoffvg $vgname Fail" exit 1 fi done >/tmp/lsdevname.txt >/tmp/lspvname.txt echo 0
【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)