分类: Oracle
2008-05-12 17:19:31
一个简单的脚本介绍一下如何用六步快速安全卸载Oracle RAC。
脚本分为这么几个部分:
1. stop and delete RAC instance, drop the database
2. stop and delete ASM instance
3. stop and delete listener
4. stop crs stack and clean related resource
5. clean ocr context
6. change permission and remove related ORACLE directory and Clusterware directory
其中4,5都可以直接利用Clusterware 目录install下面的脚本进行,所以这里主要介绍1,2,3,6.
1. stop and drop database
#!/bin/ksh
db=`srvctl config database`
echo “db=$db”
nl=`srvctl config database -d $db | awk ‘{print $2}’`
echo “nl=$nl”
srvctl stop database -d $db
srvctl remove database -d $db -f
for n in $nl
do
echo “stop and remove instance on instance $n”
srvctl stop instance -d $db -i $n
srvctl remove instance -d $db -i $n -f
done
echo “stop and remove database instance done”
2. stop and drop asm instance
#!/bin/ksh
nl=`olsnodes`
for n in $nl
do
srvctl stop asm -n $n
srvctl remove asm -n $n
done
echo “stop and remove asm done”
3. stop and drop listener
lsnr=`crs_stat |grep lsnr | cut -d= -f2`
for l in $lsnr
do
crs_stop $l
crs_unregister $l
done
echo “stop and remove listener done”
4. stop crs stack and clean related resource
这里需要注意的是,这里的操作必须一个节点一个节点的执行,不能并行操作,就如同安装的时候执行root.sh一样!切记切记.
on local node:
$ORA_CRS_HOME/install/rootdelete.sh local nosharedvar nosharedhome
on remote nodes:
$ORA_CRS_HOME/install/rootdelete.sh remote nosharedvar nosharedhome
5. clean ocr
only execute this on local node:
$ORA_CRS_HOME/install/rootdeinstall.sh
6. change permission and remove directory
这里之所以要更改权限是因为安装后期运行root.sh的时候会把ORA_CRS_HOME的父目录改为root权限,下次安装的时候必须修改为oracle用户
chown -Rf ractest:oinstall $ORA_CRS_HOME/../../../
rm
-Rf $ORA_CRS_HOME;rm -Rf $ORACLE_BASE/../oraInventory; rm -Rf
$ORACLE_BASE;rm -Rf /var/opt/oracle;rm -Rf /var/tmp/.oracle/*;rm -Rf
/tmp/*;