概述:
本次实验环境采用Veritas Netbackup 7.7.3软件版本,对Redhat Linux Oracle数据库的备份和恢复。
操作系统 | 主机名 | IP地址 |
Windows Server 2008R2 | nbumaster | 192.168.60.59 |
Redhat Linux 6.5 x86_64 | rhel6 | 192.168.60.100 |
Oracle备份恢复实验拓扑:
[Master/Media server][192.168.60.59][Winodws Server2008R2]
2.上传Netbackup 7.7.3软件解压并安装
3.输入License授权安装Master Server
4.等待安装完成
[Client][192.168.60.100][Redhat Linux 6.5]
1.修改HOSTNAME
vi/etc/sysconfig/network NETWORKING=yes HOSTNAME=rhel6
2.修改selinux设置
vi/etc/selinux/config SELINUXTYPE=disabled
3.关闭防火墙
serviceiptablesstop iptables:Flushingfirewallrules:[OK] iptables:SettingchainstopolicyACCEPT:filter[OK] iptables:Unloadingmodules:
vi/etc/hosts 192.168.60.100rhel6 192.168.60.59nbumaster
5.Linux NBU Client安装
安装介质:
NetBackup_7.7.3_CLIENTS2.tar.gz2.87GB
解压缩
tarxfNetBackup_7.7.3_CLIENTS2.tar.gz-C/opt
进入解压完成后的目录:
cdNetBackup_7.7.3_CLIENTS2 ./install Doyouwishtocontinue?[y,n](y)y DoyouwanttoinstalltheNetBackupclientsoftwareforthisclient?[y,n](y)y EnterthenameoftheNetBackupmasterserver:nbumaster Wouldyouliketouse"rhel6"astheconfigured nameoftheNetBackupclient?[y,n](y)y
[Client][192.168.60.100][Redhat Linux 6.5][数据库备份配置]
1.连接登陆数据库,开启归档
[oracle@rhel6~]$sqlplus/assysdba sql*Plus:Release11.2.0.4.0ProductiononThuSep1410:32:242017 Copyright(c)1982,2013,Oracle.Allrightsreserved. Connectedto: OracleDatabase11gEnterpriseEditionRelease11.2.0.4.0-64bitProduction WiththePartitioning,OLAP,DataMiningandRealApplicationTestingoptions sql>shutdownimmediate;//关闭数据库; Databaseclosed. Databasedismounted. ORACLEinstanceshutdown. sql>startupmount;//启动数据库到mount状态; ORACLEinstancestarted. TotalSystemGlobalArea1603411968bytes FixedSize 2253664bytes VariableSize 1375734944bytes DatabaseBuffers 218103808bytes RedoBuffers 7319552bytes Databasemounted. sql>alterdatabasearchivelog;//开启数据库归档; Databasealtered. sql>archiveloglist; Databaselogmode ArchiveMode Automaticarchival Enabled Archivedestination USE_DB_RECOVERY_FILE_DEST Oldestonlinelogsequence1 Nextlogsequencetoarchive1 Currentlogsequence 1 sql>alterdatabaSEOpen;//打开数据库; Databasealtered.
2.修改RMAN脚本
[oracle@rhel6~]$su- Password: [oracle@rhel6~]#cp-rfp/usr/openv/netbackup/ext/db_ext/oracle/samples/rman/hot_database_backup.sh/opt/scripts [oracle@rhel6~]#vi/opt/scripts/hot_database_backup.sh ORACLE_HOME=/oracle/app/oracle/product/11.2.0 ORACLE_SID=orcl ORACLE_USER=oracle ORACLE_TARGET_CONNECT_STR=sys/manager
3.建立Oracle Link
su-oracle cd/usr/openv/netbackup/bin/ ./oracle_link AllOracleinstancesshouldbeshutdownbeforerunningthisscript. PleaselogintotheUnixsystemastheOracleownerforrunningthisscript Doyouwanttocontinue?(y/n)[n]y LIBOBKpath:/usr/openv/netbackup/bin ORACLE_HOME:/orcl/oracle Oracleversion:11.2.0.4.0 Platformtype:i686 LinkingLIBOBK: ln-s/usr/openv/netbackup/bin/libobk.so/orcl/oracle/lib/libobk.so Done Pleasecheckthetracefilelocatedin/tmp/make_trace.4459 tomakesurethelinkingprocesswassuccessful.
[Master/Media server][192.168.60.59][Windows 2008R2][数据库备份]
1.登陆Netbackup客户端软件,新建Policy备份Oracle数据库
2.策略配置备份时间,FULL备份一周一次,两周一次删除数据
4.选择相应的RMAN脚本进行备份
5.选择手动执行备份测试
6.至此Oracle数据库的备份完成
[Client][192.168.60.100][Redhat Linux 6.5][数据库恢复]
在这模拟一下数据库故障问题,删除dbf数据文件、ctl控制文件、log日志文件
[oracle@rhel6~]#cd/oracle/app/oracle/oradata/orcl [root@rhel6orcl]#rm-rf* [root@rhel6orcl]#ll 总用量0
1.首先登陆数据库,启动数据库到mount状态,在Client端或Server端查询备份数据库的备份文件
sql>shutdownimmediate;//由于文件被删,关闭数据库报错; ORA-00210:cannotopenthespecifiedcontrolfile ORA-00202:controlfile:'/oracle/app/oracle/oradata/orcl/control01.ctl' ORA-27041:unabletoopenfile Linux-x86_64Error:2:Nosuchfileordirectory Additionalinformation:3 sql>shutdownabort;//强制关闭数据库; ORACLEinstanceshutdown. sql>startupnomount;//启动数据库到nomount状态; ORACLEinstancestarted. TotalSystemGlobalArea1603411968bytes FixedSize 2253664bytes VariableSize 1375734944bytes DatabaseBuffers 218103808bytes RedoBuffers 7319552bytes
这里在Server端查询数据库备份的文件(由于测试后面又多次进行了备份):
[oracle@rhel6~]$rmannocatalogtarget/ RecoveryManager:Release11.2.0.4.0-ProductiononThuSep1412:23:202017 Copyright(c)1982,2011,Oracleand/oritsaffiliates.Allrightsreserved. connectedtotargetdatabase:ORCL(notmounted) usingtargetdatabasecontrolfileinsteadofrecoverycatalog RMAN>run{ 2>allocatechannelch00typesbt_tape; 3>restorecontrolfilefrom'/cntrl_26_1_954675900'; 4>releasechannelch00; 5>} allocatedchannel:ch00 channelch00:SID=771devicetype=SBT_TAPE channelch00:VeritasNetBackupforOracle-Release7.7.3(2016051915) Startingrestoreat2017-09-1412:26:08 channelch00:restoringcontrolfile channelch00:restorecomplete,elapsedtime:00:00:28 outputfilename=/oracle/app/oracle/oradata/orcl/control01.ctl outputfilename=/oracle/app/oracle/fast_recovery_area/orcl/control02.ctl Finishedrestoreat2017-09-1412:26:36 releasedchannel:ch00
3.控制文件恢复成功后,将数据库启动到mount状态,开始恢复数据文件
RMAN>alterdatabasemount; databasemounted RMAN>run{ 2>allocatechannelch00typesbt_tape; 3>allocatechannelch01typesbt_tape; 4>restoredatabase; 5>releasechannelch00; 6>releasechannelch01; 7>} allocatedchannel:ch00 channelch00:SID=771devicetype=SBT_TAPE channelch00:VeritasNetBackupforOracle-Release7.7.3(2016051915) allocatedchannel:ch01 channelch01:SID=10devicetype=SBT_TAPE channelch01:VeritasNetBackupforOracle-Release7.7.3(2016051915) Startingrestoreat2017-09-1412:29:42 Startingimplicitcrosscheckbackupat2017-09-1412:29:42 Finishedimplicitcrosscheckbackupat2017-09-1412:29:43 Startingimplicitcrosscheckcopyat2017-09-1412:29:43 Finishedimplicitcrosscheckcopyat2017-09-1412:29:43 searchingforallfilesintherecoveryarea catalogingfiles... nofilescataloged channelch00:startingdatafilebackupsetrestore channelch00:specifyingdatafile(s)torestorefrombackupset channelch00:restoringdatafile00001to/oracle/app/oracle/oradata/orcl/system01.dbf channelch00:restoringdatafile00004to/oracle/app/oracle/oradata/orcl/users01.dbf channelch00:readingfrombackuppiecebk_21_1_954675802 channelch01:startingdatafilebackupsetrestore channelch01:specifyingdatafile(s)torestorefrombackupset channelch01:restoringdatafile00002to/oracle/app/oracle/oradata/orcl/sysaux01.dbf channelch01:restoringdatafile00003to/oracle/app/oracle/oradata/orcl/undotbs01.dbf channelch01:readingfrombackuppiecebk_20_1_954675802 channelch00:piecehandle=bk_21_1_954675802tag=HOT_DB_BK_INC_LVL0 channelch00:restoredbackuppiece1 channelch00:restorecomplete,elapsedtime:00:01:05 channelch01:piecehandle=bk_20_1_954675802tag=HOT_DB_BK_INC_LVL0 channelch01:restoredbackuppiece1 channelch01:restorecomplete,elapsedtime:00:01:05 Finishedrestoreat2017-09-1412:30:55 releasedchannel:ch00 releasedchannel:ch01
4.恢复数据库
RMAN>run{ 2>allocatechannelch00typesbt_tape; 3>allocatechannelch01typesbt_tape; 4>recoverdatabase; 5>releasechannelch00; 6>releasechannelch01; 7>} allocatedchannel:ch00 channelch00:SID=771devicetype=SBT_TAPE channelch00:VeritasNetBackupforOracle-Release7.7.3(2016051915) allocatedchannel:ch01 channelch01:SID=10devicetype=SBT_TAPE channelch01:VeritasNetBackupforOracle-Release7.7.3(2016051915) Startingrecoverat2017-09-1412:33:19 startingmediarecovery channelch00:startingarchivedlogrestoretodefaultdestination channelch00:restoringarchivedlog archivedlogthread=1sequence=3 channelch00:readingfrombackuppieceal_24_1_954675865 channelch01:startingarchivedlogrestoretodefaultdestination channelch01:restoringarchivedlog archivedlogthread=1sequence=4 channelch01:readingfrombackuppieceal_25_1_954675865 channelch00:piecehandle=al_24_1_954675865tag=TAG20170914T114424 channelch00:restoredbackuppiece1 channelch00:restorecomplete,elapsedtime:00:00:25 archivedlogfilename=/oracle/app/oracle/fast_recovery_area/ORCL/archivelog/2017_09_14/o1_mf_1_3_dvn1o8l5_.arcthread=1sequence=3 channeldefault:deletingarchivedlog(s) archivedlogfilename=/oracle/app/oracle/fast_recovery_area/ORCL/archivelog/2017_09_14/o1_mf_1_3_dvn1o8l5_.arcRECID=9STAMP=954678824 channelch01:piecehandle=al_25_1_954675865tag=TAG20170914T114424 channelch01:restoredbackuppiece1 channelch01:restorecomplete,elapsedtime:00:00:25 archivedlogfilename=/oracle/app/oracle/fast_recovery_area/ORCL/archivelog/2017_09_14/o1_mf_1_4_dvn1o8wd_.arcthread=1sequence=4 channeldefault:deletingarchivedlog(s) archivedlogfilename=/oracle/app/oracle/fast_recovery_area/ORCL/archivelog/2017_09_14/o1_mf_1_4_dvn1o8wd_.arcRECID=10STAMP=954678824 unabletofindarchivedlog archivedlogthread=1sequence=5 releasedchannel:ch00 releasedchannel:ch01 RMAN-00571:=========================================================== RMAN-00569:===============ERRORMESSAGESTACKFOLLOWS=============== RMAN-00571:=========================================================== RMAN-03002:failureofrecovercommandat09/14/201712:33:53 RMAN-06054:mediarecoveryrequestingunknownarchivedlogforthread1withsequence5andstartingSCNof1938164
5.从SCN记录从新记录新的日志文件
RMAN>recoverdatabaseuntilscn1938164; Startingrecoverat2017-09-1412:35:08 allocatedchannel:ORA_DISK_1 channelORA_DISK_1:SID=771devicetype=DISK startingmediarecovery mediarecoverycomplete,elapsedtime:00:00:00 Finishedrecoverat2017-09-1412:35:08
6.打开数据库,生成新的redolog以及undolog文件
RMAN>alterdatabaSEOpen 2>; RMAN-00571:=========================================================== RMAN-00569:===============ERRORMESSAGESTACKFOLLOWS=============== RMAN-00571:=========================================================== RMAN-03002:failureofalterdbcommandat09/14/201712:37:54 ORA-01589:mustuseRESETLOGSorNORESETLOGSoptionfordatabaSEOpen RMAN>alterdatabaSEOpenRESETLOGS; databaSEOpened
至此,Oracle数据库的本机通过Netbackup备份恢复实验成功实现。需要注意的是在Netbackup备份数据库的时候,要在数据库端配置script,然后在master端发起备份;而数据库恢复只需在client端发起恢复即可。
原文链接:https://www.f2er.com/oracle/207737.html