本文是一篇迟来的博文,写这篇博文源于近日在整理技术笔记时,看到2年前写的EMC Networker 8.1异机恢复Oracle 11gR2数据库的操作笔记(测试的是假如生产数据库服务器崩溃宕机,而将备份数据恢复到备用数据库服务器)。虽然去年EMC就已推出了Networker 9,但本文可能多少还有一点参考价值,便稍加整理后发了出来。
一、测试环境
计算机名 |
IP地址 |
操作系统 |
角色 |
安装软件 |
Bakserver |
10.1.1.4 |
RedHat 6 |
备份服务器 |
EMC Networker 8.1.1 |
DB1 |
10.1.1.5 |
RedHat 6 | 生产数据库服务器(源数据库) |
Oracle 11g R2、 lgtoclnt-8.1.1.2-1.x86_64.rpm(Networker客户端) lgtonmda-1.6.0.2-1_x86_64.rpm (Networker数据库模块) |
TestDB02 |
10.1.1.6 |
RedHat 6 | 备用数据库服务器(目标数据库) |
注:备用数据库服务器的Oracle版本、实例名、Oracle相关目录及权限必须和生产数据库服务器一致。
本文原始出处:江健龙的技术博客http://jiangjianlong.blog.51cto.com/3735273/1869808
二、备用数据库服务器准备
1、安装配置Oracle数据库,其中版本、实例名、相关目录及权限均需要和生产数据库服务器一致,这部分操作不是本文重点故略过。
2、安装Networker客户端及数据库模块,版本需与生产数据库服务器一致。
(1)解压networker客户端安装包
(2)安装Networker客户端
(3)启动Networker客户端
(4)解压NMDA1.6数据库模块安装包
(5)安装NMDA1.6数据库模块
3、链接库文件,切换到oracle用户进入到/database/system/db/lib,然后执行以下命令:
ln –s/usr/lib/libnsrora.so libobk.so
4、确保归档已开启
SQL>archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /oradata/arch
Oldest online log sequence 363
Next log sequence to archive 365
Current log sequence 365
5、打开控制文件自动备份
RMAN> configure controlfile autobackup on;
RMAN> configure controlfile autobackup format fordevice type sbt to '%F';
6、做好hosts解析,确保备份服务器、目标数据库服务器之间能互相解析。
7、在Networker控制台操作,新客户端向导
(1)输入客户端名称,并按默认选择传统客户端
(2)点击选择Oracle
(3)选择目标池为Data Domain存储中的池,按默认选择IP
(4)按默认选择第一项
(5)填写相关目录路径,以及用户名、密码和实例名
(6)选择浏览策略和保留策略,以及远程访问标识*@*
(7)选择添加到的组,默认已经勾选了default组,记得要去掉勾选。此处是要备份时才需要,我们现在只是为了恢复数据库而创建客户端,并不是要添加进组中进行备份,所以后面创建完客户端后需要从组中删除此客户端
(8)完成客户端的创建
(9)由于只需要创建为networker客户端,并不需要加入组,故从组中删除(加入组是为了定时执行备份)
注:如果是要在组中参加定时备份,则需要右击修改客户端向导,做如下2处修改:
三、异机恢复过程
本文原始出处:江健龙的技术博客http://jiangjianlong.blog.51cto.com/3735273/1869808
1、通过Networker查询存储集,确认要恢复的日期,例如从DataDomain存储中恢复11月27号的备份数据
2、找到上图红框处的这个存储集,记下这个存储集的名称
3、数据库的恢复操作必须在备用数据库服务器(即目标机)上进行,需要使用RMAN命令进行恢复
(1)启动数据库到nomount模式
[oracle@TESTDB02 ~]$sqlplus /nolog
SQL*Plus: Release 11.2.0.4.0 Production on Tue Nov 2514:18:59 2014
Copyright (c) 1982, 2013, Oracle. All rights reserved.
SQL> conn / as sysdba
Connected to an idle instance.
SQL> shutdown immediate
ORA-01109: database not open
SQL>create pfile='/database/system/db/dbs/ma.ora' from spfile;
File created.
SQL>startup nomount pfile='/database/system/db/dbs/ma.ora';
ORACLE instance started.
Total System Global Area 1603411968 bytes
Fixed Size 2253664 bytes
Variable Size 1006636192 bytes
Database Buffers 587202560 bytes
Redo Buffers 7319552 bytes
(2)查出源数据库db1的DBID,然后将目标数据库的DBID设置和源数据库的DBID一样
[oracle@TESTDB02 ~]$ rman target /
Recovery Manager:Release 11.2.0.4.0 - Production on Wed Nov 19 14:49:36 2014
Copyright (c)1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected totarget database: MA (not mounted)
RMAN> set dbid=2362817816;
executing command: SET DBID
(3)使用RMAN脚本恢复spfile
RMAN>
run{
allocatechannel s1 type 'sbt_tape';
send'NSR_ENV=(NSR_SERVER=BAKServer,NSR_CLIENT=db1,NSR_DATA_VOLUME_POOL=Oracle)';
restorespfile from 'c-2362817816-20141127-01';
releasechannel s1;
}
执行RMAN脚本后输出如下,可以看到spfile文件已成功恢复:
allocated channel: s1
channel s1: SID=63 device type=SBT_TAPE
channel s1: NMDA Oracle v1.6.0
sent command to channel: s1
Starting restore at 27-NOV-14
channel s1: restoring spfile from AUTOBACKUPc-2362817816-20141127-01
channel s1: SPFILE restore from AUTOBACKUPcomplete
Finished restore at 27-NOV-14
released channel: s1
(4)使用RMAN脚本恢复controlfile
RMAN>
run{
allocatechannel s1 type 'sbt_tape';
send'NSR_ENV=(NSR_SERVER=BAKServer,NSR_CLIENT=db1,NSR_DATA_VOLUME_POOL=Oracle)';
restorecontrolfile from 'c-2362817816-20141127-01';
releasechannel s1;
}
执行RMAN脚本后输出如下,可以看到控制文件已成功恢复:
allocated channel: s1
channel s1: SID=63 device type=SBT_TAPE
channel s1: NMDA Oracle v1.6.0
sent command to channel: s1
Starting restore at 27-NOV-14
channel s1: restoring control file
channel s1: restore complete, elapsed time:00:00:07
output filename=/database/dbdata/ma/control01.ctl
output filename=/database/system/fast_recovery_area/ma/control02.ctl
Finished restore at 27-NOV-14
released channel: s1
(5)mount数据库
RMAN>sql ' alter database mount';
sql statement: alter database mount
(6)通过RMAN脚本还原数据文件,不需要指定时间点,RMAN会根据控制文件的记录去找
run {
allocatechannel s1 type 'sbt_tape';
send'NSR_ENV=(NSR_SERVER=BAKServer,NSR_CLIENT=db1,NSR_DATA_VOLUME_POOL=Oracle)';
restoredatabase;
releasechannel s1;
}
执行RMAN脚本后输出如下,可以看到数据文件已经成功restore:
(7)通过RMAN脚本Recover数据库,不需要指定时间点,RMAN会根据控制文件的记录去找
run{
allocatechannel s1 type 'sbt_tape';
send'NSR_ENV=(NSR_SERVER=BAKServer,NSR_CLIENT=db1,NSR_DATA_VOLUME_POOL=Oracle)';
recoverdatabase;
releasechannel s1;
}
执行RMAN脚本后这时会提示报错找不到一个序列号为xxxx的归档,这是因为Oracle不会自动截断日志,会不断要求找下一个归档日志,因此需要在RMAN脚本中指定截断
(8)在recover脚本中添加until sequence 4295,再次使用RMAN脚本recover数据库
run{
allocatechannel s1 type 'sbt_tape';
send'NSR_ENV=( NSR_SERVER=BAKServer,NSR_CLIENT=db1,NSR_DATA_VOLUME_POOL=Oracle)';
recoverdatabase until sequence 4295;
releasechannel s1;
}
这次就recover成功了
(9)打开数据库,并resetlogs
RMAN> exit
RecoveryManager complete.
[oracle@TESTDB02 ~]$ sqlplus /nolog
SQL*Plus:Release 11.2.0.4.0 Production on Fri Nov 28 09:52:25 2014
Copyright(c) 1982, 2013, Oracle. All rightsreserved.
SQL> conn / as sysdba
Connected.
SQL> alter database openresetlogs;
Databasealtered.
SQL> exit
Disconnectedfrom Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bitProduction
With thePartitioning, OLAP, Data Mining and Real Application Testing options
注:如果没有备份归档日志,而是只备份了数据文件,则在完成restore database后,不用执行recover操作,而做如下3步操作:
1、编辑前面创建的pfile,vi /database/system/db/dbs/ma.ora,增加一行参数:_allow_resetlogs_corruption=true
2、从该pfile创建spfile:
SQL>create spfile from pfile='/database/system/db/dbs/ma.ora';
3、执行SQL语句开库:
SQL>alterdatabase open resetlogs;
(10)启动监听
[oracle@TESTDB02 ~]$ lsnrctl
LSNRCTLfor Linux: Version 11.2.0.4.0 - Production on 28-NOV-2014 09:55:06
Copyright(c) 1991, 2013, Oracle. All rightsreserved.
Welcometo LSNRCTL, type "help" for information.
LSNRCTL> start
Starting/database/system/db/bin/tnslsnr: please wait...
TNSLSNRfor Linux: Version 11.2.0.4.0 - Production
Systemparameter file is /database/system/db/network/admin/listener.ora
Logmessages written to /database/system/diag/tnslsnr/TESTDB02/listener/alert/log.xml
Listeningon:(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=TESTDB02.it.com)(PORT=1521)))
Listeningon: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Connectingto (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=TESTDB02.it.com)(PORT=1521)))
STATUSof the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version11.2.0.4.0 - Production
StartDate 28-NOV-2014 09:55:08
Uptime 0 days 0 hr. 0 min. 0 sec
TraceLevel off
Security ON: Local OS Authentication
SNMP OFF
ListenerParameter File /database/system/db/network/admin/listener.ora
ListenerLog File /database/system/diag/tnslsnr/TESTDB02listener/alert/log.xml
ListeningEndpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=TESTDB02.it.com)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Thelistener supports no services
Thecommand completed successfully
LSNRCTL>stop
Connectingto (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=TESTDB02.it.com)(PORT=1521)))
Thecommand completed successfully
(11)至此,数据库已完成异机恢复,剩余的工作便是测试数据是否完整、正常,更改应用系统的数据库连接地址进行验证等。