前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >DBA必备技能:RAC 如何安装新主机识别老存储恢复数据库

DBA必备技能:RAC 如何安装新主机识别老存储恢复数据库

作者头像
数据和云
发布2018-03-07 16:15:16
1.3K0
发布2018-03-07 16:15:16
举报
文章被收录于专栏:数据和云数据和云

编辑手记:在 DBA 的日常工作中,经常会遇到 RAC 的一个节点失效的情况,或者通过存储迁移主机,如何恢复环境,加入集群是 DBA 的必备技能。

张大朋(Lunar)Oracle 资深技术专家

Lunar 拥有超过十年的 ORACLE SUPPORT 从业经验,曾经服务于ORACLE ACS部门,现就职于 ORACLE Sales Consultant 部门,负责的产品主要是 Exadata,Golden Gate,Database 等。

在有些场景下,RAC环境中如果主机出现问题,比如硬件故障等,不能启动,我们需要尽快从存储上启动数据库,恢复业务,这样就需要迁移以前的RAC环境到新的主机环境下。在时间中,恢复过程还是很快的,基本上就是安装软件的过程,如果真实场景恢复业务,有两种方法:

1,按照我这里的方法重新安装主机,恢复RAC和数据库; 2,如果之前有可用的操作系统的备份(比如NBU备份了OS),那么直接使用NBU还原即可;

这里测试的场景是:

重新安装11204的GI(Grid Infrastructure)和ORACLE RDBMS软件,然后识别老存储;操作系统是OEL Linux 6.6, 数据库版本是11.2.0.4,单节点RAC 。

首先,因为存储使用的是11204的ASM,测试过程只安装11204的GI(Grid Infrastructure)软件,不用OUI配置GI。

/u01/app/oraInventory/orainstRoot.shChanging permissions of /u01/app/oraInventory.Adding read,write permissions for group.Removing read,write,execute permissions for world. Changing groupname of /u01/app/oraInventory to oinstall.The execution of the script is complete.

执行root.sh:

/u01/app/11.2.0.4/grid/root.shPerforming root user operation for Oracle 11g The following environment variables are set as: ORACLE_OWNER= grid ORACLE_HOME= /u01/app/11.2.0.4/grid Enter the full pathname of the local bin directory: [/usr/local/bin]: The contents of "dbhome" have not changed. No need to overwrite.The contents of "oraenv" have not changed. No need to overwrite.The contents of "coraenv" have not changed. No need to overwrite. Creating /etc/oratab file...Entries will be added to the /etc/oratab file as needed byDatabase Configuration Assistant when a database is createdFinished running generic part of root script.Now product-specific root actions will be performed. Using configuration parameter file: /u01/app/11.2.0.4/grid/crs/install/crsconfig_paramsCreating trace directoryUser ignored Prerequisites during installationInstalling Trace File AnalyzerOLR initialization - successful root wallet。。。。Adding Clusterware entries to upstartCRS-2672: Attempting to start 'ora.mdnsd' on 'lunar5'CRS-2676: Start of 'ora.mdnsd' on 'lunar5' succeededCRS-2672: Attempting to start 'ora.gpnpd' on 'lunar5'CRS-2676: Start of 'ora.gpnpd' on 'lunar5' succeededCRS-2672: Attempting to start 'ora.cssdmonitor' on 'lunar5'CRS-2672: Attempting to start 'ora.gipcd' on 'lunar5'CRS-2676: Start of 'ora.cssdmonitor' on 'lunar5' succeededCRS-2676: Start of 'ora.gipcd' on 'lunar5' succeededCRS-2672: Attempting to start 'ora.cssd' on 'lunar5'CRS-2672: Attempting to start 'ora.diskmon' on 'lunar5'CRS-2676: Start of 'ora.diskmon' on 'lunar5' succeededCRS-2676: Start of 'ora.cssd' on 'lunar5' succeeded ASM created and started successfully. Disk Group TEMPDG created successfully. clscfg: -install mode specifiedSuccessfully accumulated necessary OCR keys.Creating OCR keys for user 'root', privgrp 'root'..Operation successful.CRS-4256: Updating the profileSuccessful addition of voting disk 381226346c054f62bf5f219ee16d7e25.Successfully replaced voting disk group with +TEMPDG.CRS-4256: Updating the profileCRS-4266: Voting file(s) successfully replaced## STATE File Universal Id File Name Disk group-- ----- ----------------- --------- --------- 1. ONLINE 381226346c054f62bf5f219ee16d7e25 (/dev/asm-diski) [TEMPDG]Located 1 voting disk(s).CRS-2672: Attempting to start 'ora.asm' on 'lunar5'CRS-2676: Start of 'ora.asm' on 'lunar5' succeededCRS-2672: Attempting to start 'ora.TEMPDG.dg' on 'lunar5'CRS-2676: Start of 'ora.TEMPDG.dg' on 'lunar5' succeededConfigure Oracle Grid Infrastructure for a Cluster ... succeeded

相应的checkpoint文件内容:

这里看到“DESC=”ROOTCRS_NODECONFIG” STATE=”SUCCESS””表示GI已经配置完成。 图形界面点击ok,继续执行其余配置,配置完成后,再次检查checkpoint文件:

ll /u01/app/grid/Clusterware/ckptGridHA_lunar5.xml-rw-r--r-- 1 grid oinstall 4176 Feb 15 19:31 /u01/app/grid/Clusterware/ckptGridHA_lunar5.xml[root@lunar5 ~]# cd /u01/app/grid/Clusterware/[root@lunar5 Clusterware]# lltotal 8-rw-r--r-- 1 grid oinstall 4176 Feb 15 19:31 ckptGridHA_lunar5.xml

这里看到,checkpoint文件的日期没有变化,说明checkpoint文件是执行root.sh的时候才有用的,也就是这个过程是11.2中为了方便客户,增加了root.sh的失败后继续配置二设计的,非常体贴的功能。在12.2中,该功能更加方便,他将会只管的告诉你当前配置的检查点情况,如果有些步骤失败后,oracle会自动清除老的配置,以便可以失败安装后不用重装,而是纠正错误后继续配置,类似“断点续传”那种意思。

继续检查老的asm磁盘组:

将上述磁盘组添加到ASM启动磁盘组的列表中:

对新添加的磁盘组执行mount和dismount后,这些磁盘组就会自动添加到ocr中:

检查ASM磁盘组中的内容(比如包含哪些数据库),因为ASM是采用OMF的,因此大部分情况下,通过磁盘组的目录结构就可以看出来这个存储中以前包含哪些数据库和其他相关信息:

这里看到,该存储中,包含了一个数据库,crsdg中的信息已经被我删除了,因此,没有老的ocr和voting disk文件了

现在,已经确定只有datadg2上面有数据,因此可以重组磁盘组,以便合理利用空间(后续我要用这个vm做很多其他测试):

使用kfod查看:

确认当前的crs状态都是正常的:

[root@lunar5 ~]# crsctl status res -t ——————————————————————————– NAME TARGET STATE SERVER STATE_DETAILS ——————————————————————————– Local Resources ——————————————————————————– ora.DATADG1.dg ONLINE ONLINE lunar5 ora.DATADG2.dg ONLINE ONLINE lunar5 ora.DATADG3.dg ONLINE ONLINE lunar5 ora.LISTENER.lsnr ONLINE ONLINE lunar5 ora.TEMPDG.dg ONLINE ONLINE lunar5 ora.asm ONLINE ONLINE lunar5 Started ora.gsd OFFLINE OFFLINE lunar5 ora.net1.network ONLINE ONLINE lunar5 ora.ons ONLINE ONLINE lunar5 ——————————————————————————– Cluster Resources ——————————————————————————– ora.LISTENER_SCAN1.lsnr 1 ONLINE ONLINE lunar5 ora.cvu 1 ONLINE ONLINE lunar5 ora.lunar5.vip 1 ONLINE ONLINE lunar5 ora.oc4j 1 ONLINE ONLINE lunar5 ora.scan1.vip 1 ONLINE ONLINE lunar5

至此老存储的ASM磁盘组已经在新的主机上可以识别了。

假设原来的主机已经完全不能启动了(比如硬件故障等),只能在存储上的ASM中查找数据库使用的参数文件:

这里看到,数据库使用的参数文件是spfilelunar.ora,它是spfile.272.892409049的别名文件。 我们在ASM中查看一下:

检查数据库的spfile的内容:

这里确定的,该文件+datadg2/lunar/spfilelunar.ora(也就是+DATADG2/LUNAR/PARAMETERFILE/spfile.272.892409049)就是我们需要使用的数据库参数文件。

安装Oracle 11.2.0.4数据库软件,然后执行root.sh,这个没有特别的东西,略。 之后,我们需要修改ORACLE RDBMS的oracle二进制文件的权限,让oracle 数据库进程可以获取ASM磁盘组。

su - grid$ORACLE_HOME/bin/setasmgidwrap o=/u01/app/oracle/product/11.2.0.4/dbhome_1/bin/oraclell /u01/app/oracle/product/11.2.0.4/dbhome_1/bin/oracle-rwsr-s--x 1 oracle asmadmin 239626689 Feb 15 22:09 /u01/app/oracle/product/11.2.0.4/dbhome_1/bin/oracle

注意,这里的/u01/app/oracle/product/11.2.0.4/dbhome_1/bin/oracle就是安装ORACLE RDBMS的ORACLE_HOME。 然后,将数据库添加到CRS中,启动数据库:

srvctl add database -d lunar -n lunar5 -o $ORACLE_HOME -p +DATADG2/LUNAR/PARAMETERFILE/spfile.272.892409049 -s OPEN -y AUTOMATIC -a "TEMPDG,DATADG1,DATADG2,DATADG3" -t IMMEDIATE

检查数据库在ocr中的配置:

srvctl config database -d lunarDatabase unique name: lunarDatabase name: lunar5Oracle home: /u01/app/oracle/product/11.2.0.4/dbhome_1Oracle user: oracleSpfile: +DATADG2/LUNAR/PARAMETERFILE/spfile.272.892409049Domain: Start options: openStop options: immediateDatabase role: PRIMARYManagement policy: AUTOMATICServer pools: lunarDatabase instances: Disk Groups: TEMPDG,DATADG1,DATADG2,DATADG3Mount point paths: Services: Type: RACDatabase is administrator managed

启动数据库:

[oracle@lunar5 ~]$ srvctl start database -d lunar

检查crs的状态:

至此,整个使用新主机识别老存储的RAC(主要是识别ASM)就完成了。如果是文件系统的环境,比这个简单很多,ASM的全部可以省略了。


本文参与 腾讯云自媒体分享计划,分享自微信公众号。
原始发表:2017-06-23,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 数据和云 微信公众号,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
对象存储
对象存储(Cloud Object Storage,COS)是由腾讯云推出的无目录层次结构、无数据格式限制,可容纳海量数据且支持 HTTP/HTTPS 协议访问的分布式存储服务。腾讯云 COS 的存储桶空间无容量上限,无需分区管理,适用于 CDN 数据分发、数据万象处理或大数据计算与分析的数据湖等多种场景。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档