Linux操作系统中运行Oracle RAC 10.2.0.4双节点(ora1和ora2)。ora1的两块盘损坏导致系统故障,剩下一个ora2正常运行并继续对外提供服务。重做完系统后,如何保证在应用不停机的情况下快速恢复RAC 的两节点环境呢?方法如下:
1、ora1重做操作系统(版本、系统参数保持一致);
2、ora1上配置Oracle环境(ASM、裸设备等);
3、ora1上创建Oracle用户(UID以及GID与ora2保持一致)并配置互信访问机制;
4、将ora2节点的Oracle家目录进行打包并传到ora1节点,如下:
[root@ora2~]#tar-cfu01.tar/u01/app [root@ora2~]#scpu01.tarora1:/root
5、ora1上解压u01.tar并运行CRS的root.sh脚本:
运行root.sh就会重新将一些配置信息写入的/etc/init.d 等目录中。OCR 中因为已经有这个节点的资源了,所以会自动显示成功配置。
[root@ora1/]#tar-xf/root/u01.tar [root@ora1/]#cd/u01/app/crs [root@ora1crs]#./root.sh WARNING:directory'/u01/app'isnotownedbyroot WARNING:directory'/u01'isnotownedbyroot CheckingtoseeifOracleCRSStackisalreadyconfigured /etc/oracledoesnotexist.Creatingitnow. SettingthepermissionsonOCRbackupdirectory SettingupNSdirectories OracleClusterRegistryconfigurationupgradedsuccessfully WARNING:directory'/u01/app'isnotownedbyroot WARNING:directory'/u01'isnotownedbyroot clscfg:EXISTINGconfigurationversion3detected. clscfg:version3is10GRelease2. SuccessfullyaccumulatednecessaryOCRkeys. Usingports:CSS=49895CRS=49896EVMC=49898andEVMR=49897. node<nodenumber>:<nodename><privateinterconnectname><hostname> node1:ora1ora1-privora1 node2:ora2ora2-privora2 clscfg:Argumentscheckoutsuccessfully. NOKEYSWEREWRITTEN.Supply-forceparametertooverride. -forceisdestructiveandwilldestroyanyprevIoUscluster configuration. OracleClusterRegistryforclusterhasalreadybeeninitialized Startupwillbequeuedtoinitwithin30seconds. Addingdaemonstoinittab ExpectingtheCRSdaemonstobeupwithin600seconds. CSSisactiveonthesenodes. ora1 ora2 CSSisactiveonallnodes. WaitingfortheOracleCRSDandEVMDtostart OracleCRSStackinstalledandrunningunderinit(1M) Runningvipca(silent)forconfiguringnodeapps CreatingVIPapplicationresourceon(0)nodes. CreatingGSDapplicationresourceon(0)nodes. CreatingONSapplicationresourceon(0)nodes. StartingVIPapplicationresourceon(2)nodes... StartingGSDapplicationresourceon(2)nodes StartingONSapplicationresourceon(2)nodes DONE.
6、复制ora2的/etc/oratab至ora1:
[root@ora2~]#ls-l/etc/oratab -rw-rw-r--1oracleroot765Oct302009/etc/oratab [root@ora2~]#cat/etc/oratab ......... +ASM2:/u01/app/oracle/product/10.2.0/db_1:N odb:/u01/app/oracle/product/10.2.0/db_1:N [root@ora2~]#scp/etc/oratabora1:/etc/ [root@ora1~]#chownoracle:root/etc/oratab //编辑/etc/oratab文件,将里面的+ASM2修改为+ASM1. [root@ora1~]#cat/etc/oratab ......... +ASM1:/u01/app/oracle/product/10.2.0/db_1:N odb:/u01/app/oracle/product/10.2.0/db_1:N
7、运行RDBMS的root.sh脚本:
[root@ora1~]#cd/u01/app/oracle/product/10.2.0/db_1/ [root@ora1db_1]#./root.sh RunningOracle10root.shscript... Thefollowingenvironmentvariablesaresetas: ORACLE_OWNER=oracle ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1 Enterthefullpathnameofthelocalbindirectory:[/usr/local/bin]: Copyingdbhometo/usr/local/bin... Copyingoraenvto/usr/local/bin... Copyingcoraenvto/usr/local/bin... Entrieswillbeaddedtothe/etc/oratabfileasneededby DatabaseConfigurationAssistantwhenadatabaseiscreated Finishedrunninggenericpartofroot.shscript. Nowproduct-specificrootactionswillbeperformed.
8、修改$ORACLE_HOME/network/admin/listener.ora文件,将ora2的相关信息替换为ora1的。另外,监听名称不再是默认的listener了,而是listener_ora1。
9、创建$ORACLE_HOME/dbs/下的spfile以及密码文件。
[oracle@ora1~]$cd$ORACLE_HOME/dbs [oracle@ora1dbs]$cpinitodb2.orainitodb1.ora [oracle@ora1dbs]$cpinit+ASM2.orainit+ASM1.ora [oracle@ora1dbs]$cporapw+ASM2orapw+ASM1 [oracle@ora1dbs]$cporapwodb2orapwodb1
10、启动所有rac资源:
[oracle@ora1~]$crs_start-all Attemptingtostart`ora.odb.odb_taf.odb1.srv`onmember`ora1` Attemptingtostart`ora.ora1.LISTENER_ORA1.lsnr`onmember`ora1` Startof`ora.odb.odb_taf.odb1.srv`onmember`ora1`succeeded. Startof`ora.ora1.LISTENER_ORA1.lsnr`onmember`ora1`succeeded. [oracle@ora1~]$crs_stat-t-v NameTypeR/RAF/FTTargetStateHost ---------------------------------------------------------------------- ora.odb.dbapplication0/00/1ONLINEONLINEora2 ora....b1.instapplication0/50/0ONLINEONLINEora1 ora....b2.instapplication0/50/0ONLINEONLINEora2 ora...._taf.csapplication0/00/1ONLINEONLINEora1 ora....db1.srvapplication0/00/0ONLINEONLINEora1 ora....db2.srvapplication0/00/0ONLINEONLINEora2 ora....SM1.asmapplication0/50/0ONLINEONLINEora1 ora....A1.lsnrapplication0/50/0ONLINEONLINEora1 ora.ora1.gsdapplication0/50/0ONLINEONLINEora1 ora.ora1.onsapplication0/30/0ONLINEONLINEora1 ora.ora1.vipapplication0/00/0ONLINEONLINEora1 ora....SM2.asmapplication0/50/0ONLINEONLINEora2 ora....A2.lsnrapplication0/50/0ONLINEONLINEora2 ora.ora2.gsdapplication0/50/0ONLINEONLINEora2 ora.ora2.onsapplication0/30/0ONLINEONLINEora2 ora.ora2.vipapplication0/00/0ONLINEONLINEora2
到此,ora1已成功添加进RAC环境。