使用NBU 對ORACLE 進行備份


概述:

   本次實驗環境采用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備份恢復實驗拓撲:

  • 備份RedHat Linux環境下的Oracle 11gR2數據庫到Master Server端;

  • 通過Master Server端恢復Oracle 11gR2數據庫

[Master/Media server][192.168.60.59][Winodws Server2008R2]

1.修改hosts文件

 

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.關閉防火牆

service iptables stop iptables: Flushing firewall rules: [ OK ] iptables: Setting chains to policy ACCEPT: filter [ OK ] iptables: Unloading modules:

 

4.修改hosts文件

vi /etc/hosts 192.168.60.100 rhel6 192.168.60.59 nbumaster

 

5.Linux NBU Client安裝

安裝介質: 

NetBackup_7.7.3_CLIENTS2.tar.gz                2.87 GB

 

解壓縮

tar xf NetBackup_7.7.3_CLIENTS2.tar.gz -C /opt

 

進入解壓完成后的目錄:

cd NetBackup_7.7.3_CLIENTS2 ./install Do you wish to continue? [y,n] (y) y Do you want to install the NetBackup client software for this client? [y,n] (y) y Enter the name of the NetBackup master server : nbumaster Would you like to use "rhel6" as the configured name of the NetBackup client? [y,n] (y) y

 

[Client][192.168.60.100][Redhat Linux 6.5][數據庫備份配置]

1.連接登陸數據庫,開啟歸檔

[oracle@rhel6 ~]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.4.0 Production on Thu Sep 14 10:32:24 2017 Copyright (c) 1982, 2013, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> shutdown immediate; //關閉數據庫; Database closed. Database dismounted. ORACLE instance shut down. SQL> startup mount; //啟動數據庫到mount狀態; ORACLE instance started. Total System Global Area 1603411968 bytes Fixed Size 2253664 bytes Variable Size 1375734944 bytes Database Buffers 218103808 bytes Redo Buffers 7319552 bytes Database mounted. SQL> alter database archivelog; //開啟數據庫歸檔; Database altered. SQL> archive log list; Database log mode Archive Mode Automatic archival Enabled Archive destination USE_DB_RECOVERY_FILE_DEST Oldest online log sequence 1 Next log sequence to archive 1 Current log sequence 1 SQL> alter database open; //打開數據庫; Database altered.
 

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 All Oracle instances should be shutdown before running this script. Please log into the Unix system as the Oracle owner for running this script Do you want to continue? (y/n) [n] y LIBOBK path: /usr/openv/netbackup/bin ORACLE_HOME: /orcl/oracle Oracle version: 11.2.0.4.0 Platform type: i686 Linking LIBOBK: ln -s /usr/openv/netbackup/bin/libobk.so /orcl/oracle/lib/libobk.so Done Please check the trace file located in /tmp/make_trace.4459 to make sure the linking process was successful.
 

 [Master/Media server][192.168.60.59][Windows 2008R2][數據庫備份]

1.登陸Netbackup客戶端軟件,新建Policy備份Oracle數據庫

2.策略配置備份時間,FULL備份一周一次,兩周一次刪除數據

3.選擇自定義RMAN腳本備份方式,添加客戶端

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@rhel6 orcl]# rm -rf * [root@rhel6 orcl]# ll 總用量 0
 

1.首先登陸數據庫,啟動數據庫到mount狀態,在Client端或Server端查詢備份數據庫的備份文件

SQL> shutdown immediate; //由於文件被刪,關閉數據庫報錯; ORA-00210: cannot open the specified control file ORA-00202: control file: '/oracle/app/oracle/oradata/orcl/control01.ctl' ORA-27041: unable to open file Linux-x86_64 Error: 2: No such file or directory Additional information: 3 SQL> shutdown abort; //強制關閉數據庫; ORACLE instance shut down. SQL> startup nomount; //啟動數據庫到nomount狀態; ORACLE instance started. Total System Global Area 1603411968 bytes Fixed Size 2253664 bytes Variable Size 1375734944 bytes Database Buffers 218103808 bytes Redo Buffers 7319552 bytes
 

這里在Server端查詢數據庫備份的文件(由於測試后面又多次進行了備份):

2.進入RMAN Target,首先恢復數據庫控制文件

[oracle@rhel6 ~]$ rman nocatalog target / Recovery Manager: Release 11.2.0.4.0 - Production on Thu Sep 14 12:23:20 2017 Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. connected to target database: ORCL (not mounted) using target database control file instead of recovery catalog RMAN> run { 2> allocate channel ch00 type sbt_tape; 3> restore controlfile from '/cntrl_26_1_954675900'; 4> release channel ch00; 5> } allocated channel: ch00 channel ch00: SID=771 device type=SBT_TAPE channel ch00: Veritas NetBackup for Oracle - Release 7.7.3 (2016051915) Starting restore at 2017-09-14 12:26:08 channel ch00: restoring control file channel ch00: restore complete, elapsed time: 00:00:28 output file name=/oracle/app/oracle/oradata/orcl/control01.ctl output file name=/oracle/app/oracle/fast_recovery_area/orcl/control02.ctl Finished restore at 2017-09-14 12:26:36 released channel: ch00

 3.控制文件恢復成功后,將數據庫啟動到mount狀態,開始恢復數據文件

RMAN> alter database mount; database mounted RMAN> run { 2> allocate channel ch00 type sbt_tape; 3> allocate channel ch01 type sbt_tape; 4> restore database; 5> release channel ch00; 6> release channel ch01; 7> } allocated channel: ch00 channel ch00: SID=771 device type=SBT_TAPE channel ch00: Veritas NetBackup for Oracle - Release 7.7.3 (2016051915) allocated channel: ch01 channel ch01: SID=10 device type=SBT_TAPE channel ch01: Veritas NetBackup for Oracle - Release 7.7.3 (2016051915) Starting restore at 2017-09-14 12:29:42 Starting implicit crosscheck backup at 2017-09-14 12:29:42 Finished implicit crosscheck backup at 2017-09-14 12:29:43 Starting implicit crosscheck copy at 2017-09-14 12:29:43 Finished implicit crosscheck copy at 2017-09-14 12:29:43 searching for all files in the recovery area cataloging files... no files cataloged channel ch00: starting datafile backup set restore channel ch00: specifying datafile(s) to restore from backup set channel ch00: restoring datafile 00001 to /oracle/app/oracle/oradata/orcl/system01.dbf channel ch00: restoring datafile 00004 to /oracle/app/oracle/oradata/orcl/users01.dbf channel ch00: reading from backup piece bk_21_1_954675802 channel ch01: starting datafile backup set restore channel ch01: specifying datafile(s) to restore from backup set channel ch01: restoring datafile 00002 to /oracle/app/oracle/oradata/orcl/sysaux01.dbf channel ch01: restoring datafile 00003 to /oracle/app/oracle/oradata/orcl/undotbs01.dbf channel ch01: reading from backup piece bk_20_1_954675802 channel ch00: piece handle=bk_21_1_954675802 tag=HOT_DB_BK_INC_LVL0 channel ch00: restored backup piece 1 channel ch00: restore complete, elapsed time: 00:01:05 channel ch01: piece handle=bk_20_1_954675802 tag=HOT_DB_BK_INC_LVL0 channel ch01: restored backup piece 1 channel ch01: restore complete, elapsed time: 00:01:05 Finished restore at 2017-09-14 12:30:55 released channel: ch00 released channel: ch01
 

4.恢復數據庫

RMAN> run { 2> allocate channel ch00 type sbt_tape; 3> allocate channel ch01 type sbt_tape; 4> recover database; 5> release channel ch00; 6> release channel ch01; 7> } allocated channel: ch00 channel ch00: SID=771 device type=SBT_TAPE channel ch00: Veritas NetBackup for Oracle - Release 7.7.3 (2016051915) allocated channel: ch01 channel ch01: SID=10 device type=SBT_TAPE channel ch01: Veritas NetBackup for Oracle - Release 7.7.3 (2016051915) Starting recover at 2017-09-14 12:33:19 starting media recovery channel ch00: starting archived log restore to default destination channel ch00: restoring archived log archived log thread=1 sequence=3 channel ch00: reading from backup piece al_24_1_954675865 channel ch01: starting archived log restore to default destination channel ch01: restoring archived log archived log thread=1 sequence=4 channel ch01: reading from backup piece al_25_1_954675865 channel ch00: piece handle=al_24_1_954675865 tag=TAG20170914T114424 channel ch00: restored backup piece 1 channel ch00: restore complete, elapsed time: 00:00:25 archived log file name=/oracle/app/oracle/fast_recovery_area/ORCL/archivelog/2017_09_14/o1_mf_1_3_dvn1o8l5_.arc thread=1 sequence=3 channel default: deleting archived log(s) archived log file name=/oracle/app/oracle/fast_recovery_area/ORCL/archivelog/2017_09_14/o1_mf_1_3_dvn1o8l5_.arc RECID=9 STAMP=954678824 channel ch01: piece handle=al_25_1_954675865 tag=TAG20170914T114424 channel ch01: restored backup piece 1 channel ch01: restore complete, elapsed time: 00:00:25 archived log file name=/oracle/app/oracle/fast_recovery_area/ORCL/archivelog/2017_09_14/o1_mf_1_4_dvn1o8wd_.arc thread=1 sequence=4 channel default: deleting archived log(s) archived log file name=/oracle/app/oracle/fast_recovery_area/ORCL/archivelog/2017_09_14/o1_mf_1_4_dvn1o8wd_.arc RECID=10 STAMP=954678824 unable to find archived log archived log thread=1 sequence=5 released channel: ch00 released channel: ch01 RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of recover command at 09/14/2017 12:33:53 RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 5 and starting SCN of 1938164

 

5.從SCN記錄從新記錄新的日志文件

RMAN> recover database until scn 1938164; Starting recover at 2017-09-14 12:35:08 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=771 device type=DISK starting media recovery media recovery complete, elapsed time: 00:00:00 Finished recover at 2017-09-14 12:35:08
 

6.打開數據庫,生成新的redolog以及undolog文件

RMAN> alter database open 2> ; RMAN-00571: =========================================================== RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS =============== RMAN-00571: =========================================================== RMAN-03002: failure of alter db command at 09/14/2017 12:37:54 ORA-01589: must use RESETLOGS or NORESETLOGS option for database open RMAN> alter database open RESETLOGS; database opened
 

 至此,Oracle數據庫的本機通過Netbackup備份恢復實驗成功實現。需要注意的是在Netbackup備份數據庫的時候,要在數據庫端配置script,然后在master端發起備份;而數據庫恢復只需在client端發起恢復即可。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM