使用Rman結合netbackup重定向恢復ORACLE數據庫

使用Rman結合netbackup重定向恢復ORACLE數據庫

網上使用netbackup異機恢復oracle數據庫完整的例子不多,由於公司的環境所致,花了些時間做了個恢復測試,以下是恢復測試,共享大家,歡迎拍磚。

*****實施環境*****

數據庫服務器:eagle (原主機)

NBUserver:sol1(NBU備份服務器)

異機數據庫:sol2(目標主機)


*****恢復的前提條件*****

1、日常數據庫備份成功。至少有一次全備份和Archivelog.

2、原主機的OS及ORACLE版本與目標主機的OS及ORACLE版本保持一致.

3、需要原數據庫、NBUserver的下列信息:

3.1、IP Address, Hostname, Nbu media server name(NBU備份服務器) /client name(原主機) 

3.2、Oracle DB version,SID,DBID,Datafile Path,Controlfile Path,Archivelog Path

3.3、在目標主機上安裝與原數據庫版本相同的oracle軟件,不創建數據庫。

3.4、在目標主機上安裝NbuClient軟件、DBagent服務,安裝類型與原主機一致。


*********************************各主機軟件安裝情況*********************************

1、數據庫服務器:eagle (原主機)

oracle9.2.0.6 Server/oracleAgent/NBUClient6.5

2、NBUserver:sol1(NBU備份服務器)

NBUServer6.5

3、異機數據庫:sol2(目標主機)

oracle9.2.0.6 Server/oracleAgent/NBUClient6.5


*********************************恢復步驟*********************************


目標主機sol2配置


1、安裝NBUClient6.5

1.1、拷貝帶有NBUClient的65_DVD1_20070723.iso 

# ls
65_DVD1_20070723.iso 65_DVD2_20070723.iso 

1.2、掛載iso文件

# lofiadm
Block Device File
# pwd
/opt/nbufile
# lofiadm -a /solairs 10 iso
lofiadm: open: /solairs: No such file or directory
# lofiadm -a /opt/nbufile/65_DVD1_20070723.iso
/dev/lofi/1

# mkdir /mnt/iso
# mount -F hsfs /dev/lofi/1 /mnt/iso/
# cd /mnt/iso
# ls
IA64 NB_65_ICS_1.4.37.3_WIN32 X86 x64
Launch.bat NB_65_ICS_1.4.37.3_WINIA64 autorun.inf
NBClients NB_65_ICS_1.4.37.3_WINX64 install


1.3、開始安裝NBUClient

# ./install

Symantec Installation Script
Copyright 1993 - 2007 Symantec Corporation, All Rights Reserved.

Installing NetBackup Client Software

NOTE: To install NetBackup Server software, insert the appropriate
NetBackup Server cdrom.

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

This package will install Solaris/Solaris10 client.

This package will install NetBackup client 6.5.

--指定NBUServer端得名稱:

Enter the name of the NetBackup server : sol1

--指定NBUClient端得名稱:

Would you like to use "sol2" as the configured
name of the NetBackup client? [y,n] (y) y
x openv, 0 bytes, 0 tape blocks
x openv/lib, 0 bytes, 0 tape blocks

..........................

LiveUpdate is not installed, skipping registration step...


File /usr/openv/tmp/install_trace.9361 contains a trace of this install.
That file can be deleted after you are sure the install was successful.




2、安裝NBUClient6.5

2.1、掛載iso

# ls
65_DVD1_20070723.iso 65_DVD2_20070723.iso 65_DVD4_20070723.iso


# lofiadm -a /dev/lofi/2
lofiadm: cannot use lofi on itself
# mount -F hsfs /dev/lofi/2 /mnt/iso/
# df -h
Filesystem size used avail capacity Mounted on
/dev/md/dsk/d10 111G 46G 64G 42% /
/devices 0K 0K 0K 0% /devices
ctfs 0K 0K 0K 0% /system/contract
proc 0K 0K 0K 0% /proc
mnttab 0K 0K 0K 0% /etc/mnttab
swap 34G 1.7M 34G 1% /etc/svc/volatile
objfs 0K 0K 0K 0% /system/object
sharefs 0K 0K 0K 0% /etc/dfs/sharetab
/platform/sun4u-us3/lib/libc_psr/libc_psr_hwcap2.so.1
111G 46G 64G 42% /platform/sun4u-us3/lib/libc_psr.so.1
/platform/sun4u-us3/lib/sparcv9/libc_psr/libc_psr_hwcap2.so.1
111G 46G 64G 42% /platform/sun4u-us3/lib/sparcv9/libc_psr.so.1
fd 0K 0K 0K 0% /dev/fd
swap 34G 1.1M 34G 1% /tmp
swap 34G 64K 34G 1% /var/run
/dev/lofi/2 1.4G 1.4G 0K 100% /mnt/iso
# cd /mnt/iso
# ls
Doc NB_OM NB_SM install vADD vDBA

2.2、安裝NetBackup Database Agent Software 
# ./install


Symantec Installation Script
Copyright 1993 - 2007 Symantec Corporation, All Rights Reserved.

Installation Options

1 NetBackup Add-On Product Software 
2 NetBackup Database Agent Software 

q To quit from this script
Choose an option [default: q]: 2

**********

There are two ways to install database agent software.

1. Remote Installation: Loads the software on a server with
the intent of pushing database software out to affected clients.

2. Local Installation: Loads and installs the software only to this
local machine.

**********

Do you want to do a local installation? [y,n] (n) /mnt/iso

You have entered an invalid option.

Do you want to do a local installation? [y,n] (n) y

**********

NetBackup Database Agent Installation

Choose the Database Agents you wish to install
one at a time or select Install All Database Agents.

1) NetBackup for DB2
2) NetBackup for Informix
3) NetBackup for Lotus Notes
4) NetBackup for Oracle
5) NetBackup for SAP
6) NetBackup for Sybase

7) Install All Database Agents

q) Done Selecting Agents
x) Exit from this Script

Choose an option: 4

Choose an option: q


You have chosen to install these Database Agents:

NetBackup for Oracle

Is this list correct? [y,n] (y) y

**********


Of the agents selected, the following are supported
on this platform and will be installed:

Oracle

Loading the Database Agent packages into the
/usr/openv/netbackup/dbext directory and installing.


**********

Installing NetBackup for Oracle


Installing NetBackup for Oracle...

NetBackup for Oracle installation completed.

**********

Execution of ./install_dbext is complete.


Execution of ./install is complete.

File /usr/openv/tmp/install_options_trace.10400 contains a trace of this install.


Symantec Installation Script
Copyright 1993 - 2007 Symantec Corporation, All Rights Reserved.

Installation Options

1 NetBackup Add-On Product Software 
2 NetBackup Database Agent Software 

q To quit from this script
Choose an option [default: q]: q

#


3、安裝Oracle 9.2.0.1 升級至 9.2.0.6(此步驟略過)

3.1、將$ORACLE_HOME/dbs/pfile、spfile、pwdfile拷貝至目標數據庫相同目錄

3.2、根據參數文件中參數指向的目錄創建,bdump、cump、udump及歸檔路徑

-bash-3.00$mkdir /oracle/app/admin/china111/bdump
-bash-3.00$mkdir /oracle/app/admin/china111/cdump
-bash-3.00$mkdir /oracle/app/admin/china111/udump
-bash-3.00$mkdir /oracle/archive


4、目標主機sol2的nbuClient、hosts文件配置

4.1、創建$ORACLE_HOME/bp.conf file 

#cd $ORACLE_HOME 
#vi bp.conf

SERVER = sol1   /*master server name*/               
CLIENT_NAME = eagle          /*source host name*/               
CLINET_READ_TIMEOUT = 1800                

4.2、編輯/usr/openv/netbackup/bp.conf

#vi bp.conf                  

SERVER = sol1              /*master server name*/ 
CLIENT_NAME = eagle        /*source host name*/        
CLIENT_NAME = sol2         /*target host name */ 
VERBOSE = 5                  
CLIENT_READ_TIMEOUT = 1800
CLIENT_CONNECT_TIMEOUT = 1800 

4.3 編輯/etc/hosts文件

#vi /etc/hosts    
          
#
# Internet host table
#
::1     localhost
127.0.0.1       localhost
192.168.45.12   sol2    loghost         sol2.company.igocctv.com.
192.168.45.11   sol1
192.168.43.180  autosvr

#AD Use
192.168.45.10   company.igocctv.com


5、NBUserver主機的nbu、hosts文件配置

5.1、創建文件允許進行重定向恢復主機  
     
#cd /usr/openv/netbackup/db/altnames               
#touch sol2      /*target host name */ 
#cd /usr/openv/netbackup/db/altnames
#touch No.Restrictions

5.2、編輯/etc/hosts文件

#vi /etc/hosts 

# vi /etc/hosts
#
# Internet host table
#
::1     localhost
127.0.0.1       localhost
192.168.45.11   sol1    loghost         sol1.company.igocctv.com.
192.168.45.12   sol2
192.168.43.101  swallow1
192.168.43.102  swallow2
192.168.43.151  swallow3
192.168.43.152  swallow4
192.168.43.180  autosvr
192.168.43.2    eagle

6、開始恢復數據庫

6.1、使用pfile或spfile在目標主機(sol2)上啓動數據庫到nomount 狀態

# su - oracle
Sun Microsystems Inc.   SunOS 5.10      Generic January 2005
-bash-3.00$ ORACLE_SID=china111
-bash-3.00$ sqlplus " / as sysdba "

SQL*Plus: Release 9.2.0.6.0 - Production on Tue Jun 14 11:30:36 2011

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

Connected to an idle instance.

SQL> startup nomount
ORACLE instance started.

Total System Global Area 1.7836E+10 bytes
Fixed Size                   756856 bytes
Variable Size            7348420608 bytes
Database Buffers         1.0486E+10 bytes
Redo Buffers                 811008 bytes
SQL> 

6.2、rman恢復數據庫

首先在NBUserver端找到有效的備份文件,其中/cntrl_2602_1_753766268爲最新的控制文件

# bplist -C eagle -S sol1 -l -t 4 -s 6/13/2011 -e 6/14/2011 -R /
-rw-rw---- oracle    dba           2097152 Jun 14 03:31 /cntrl_2602_1_753766268
-rw-rw---- oracle    dba        1048576000 Jun 14 03:25 /al_2600_1_753765924
-rw-rw---- oracle    dba         367263744 Jun 14 03:25 /al_2601_1_753765924
-rw-rw---- oracle    dba         10281216K Jun 14 03:07 /bk_2599_1_753764858
-rw-rw---- oracle    dba          1051648K Jun 14 03:00 /bk_2597_1_753764402
-rw-rw---- oracle    dba          2602752K Jun 14 03:00 /bk_2598_1_753764402
-rw-rw---- oracle    dba           2097152 Jun 13 03:30 /cntrl_2596_1_753679828
-rw-rw---- oracle    dba        1048576000 Jun 13 03:24 /al_2594_1_753679494
-rw-rw---- oracle    dba         327155712 Jun 13 03:24 /al_2595_1_753679494
-rw-rw---- oracle    dba         10246400K Jun 13 03:06 /bk_2593_1_753678418
-rw-rw---- oracle    dba        1069285376 Jun 13 03:00 /bk_2591_1_753678002
-rw-rw---- oracle    dba          2564352K Jun 13 03:00 /bk_2592_1_753678002

開始進行恢復
-bash-3.00$ rman target /

Recovery Manager: Release 9.2.0.6.0 - 64bit Production

Copyright (c) 1995, 2002, Oracle Corporation.  All rights reserved.

connected to target database: china111 (not mounted)

RMAN> run{
2> ALLOCATE CHANNEL CH00 TYPE 'SBT_TAPE';
3> SEND 'NB_ORA_SERV=sol1,NB_ORA_CLIENT=eagle';
4> restore controlfile from '/cntrl_2602_1_753766268';
5> }

using target database controlfile instead of recovery catalog
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of allocate command on CH00 channel at 06/14/2011 11:45:03
ORA-19554: error allocating device, device type: SBT_TAPE, device name: 
ORA-27211: Failed to load Media Management Library

google下,結合trace文件發現沒有libobk.so所致

trace文件:

-bash-3.00$ cat ch*
/oracle/app/admin/china111/udump/china111_ora_12041.trc
Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.6.0 - Production
ORACLE_HOME = /oracle/app/product/9.2.0
System name:    SunOS
Node name:      sol2
Release:        5.10
Version:        Generic_139555-08
Machine:        sun4u
Instance name: china111
Redo thread mounted by this instance: 0 <none>
Oracle process number: 16
Unix process pid: 12041, image: oracle@sol2 (TNS V1-V3)

*** SESSION ID13.1) 2011-06-14 11:45:03.268
SKGFQ OSD: Error in function sbtinit on line 2384
SKGFQ OSD: Look for SBT Trace messages in file /oracle/app/admin/china111/udump/sbtio.log
SBT Initialize failed for oracle.static
-bash-3.00$ more ch*
/oracle/app/admin/china111/udump/china111_ora_12041.trc
Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.6.0 - Production
ORACLE_HOME = /oracle/app/product/9.2.0
System name:    SunOS
Node name:      sol2
Release:        5.10
Version:        Generic_139555-08
Machine:        sun4u
Instance name: china111
Redo thread mounted by this instance: 0 <none>
Oracle process number: 16
Unix process pid: 12041, image: oracle@sol2 (TNS V1-V3)

*** SESSION ID13.1) 2011-06-14 11:45:03.268
SKGFQ OSD: Error in function sbtinit on line 2384
SKGFQ OSD: Look for SBT Trace messages in file /oracle/app/admin/china111/udump/sbtio.log
SBT Initialize failed for oracle.static

-bash-3.00$ sbttest /etc/hosts
The sbt function pointers are loaded from oracle.static library.
libobk.so could not be loaded.  Check that it is installed

libobk.so沒有找到,所有報錯了。

拷貝libobk.so至/opt/oracle/product/9.2/lib/下面

oracle@dbsvr$ ls /usr/openv/netbackup/bin/libobk.so*
/usr/openv/netbackup/bin/libobk.so.1 /usr/openv/netbackup/bin/libobk.so64.1
oracle@dbsvr$cp /usr/openv/netbackup/bin/libobk.so64.1 /opt/oracle/product/9.2/lib/libobk.so

重新進行rman恢復

RMAN> run{
2>  ALLOCATE CHANNEL CH00 TYPE 'SBT_TAPE';
3> SEND 'NB_ORA_SERV=sol1,NB_ORA_CLIENT=eagle';
4> restore controlfile from '/cntrl_2602_1_753766268';
5> }

allocated channel: CH00
channel CH00: sid=11 devtype=SBT_TAPE
channel CH00: Veritas NetBackup for Oracle - Release 6.5 (2007072323)

sent command to channel: CH00

Starting restore at 14-JUN-11

channel CH00: restoring controlfile
channel CH00: restore complete
replicating controlfile
input filename=/oracle/app/oradata/china111/control01.ctl
output filename=/oracle/app/oradata/china111/control02.ctl
output filename=/oracle/app/oradata/china111/control03.ctl
Finished restore at 14-JUN-11
released channel: CH00

RMAN> exit


Recovery Manager complete.

完成恢復數據庫控制文件,重啓數據庫,加載mount狀態

-bash-3.00$ sqlplus " / as sysdba "

SQL*Plus: Release 9.2.0.6.0 - Production on Tue Jun 14 16:26:23 2011

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.


Connected to:
Oracle9i Enterprise Edition Release 9.2.0.6.0 - 64bit Production
With the Partitioning, OLAP and Oracle Data Mining options
JServer Release 9.2.0.6.0 - Production

SQL> shutdown immediate;
ORA-01507: database not mounted


ORACLE instance shut down.
SQL> 
SQL> startup mount
ORACLE instance started.

Total System Global Area 1.7836E+10 bytes
Fixed Size                   756856 bytes
Variable Size            7348420608 bytes
Database Buffers         1.0486E+10 bytes
Redo Buffers                 811008 bytes
Database mounted.
SQL> exit

繼續進行rman數據庫恢復

-bash-3.00$ rman target /

Recovery Manager: Release 9.2.0.6.0 - 64bit Production

Copyright (c) 1995, 2002, Oracle Corporation.  All rights reserved.

connected to target database: CHINA111 (DBID=2087198266)

RMAN> run{
2> ALLOCATE CHANNEL CH00 TYPE 'SBT_TAPE';
3> SEND 'NB_ORA_SERV=sol1,NB_ORA_CLIENT=eagle';
4> restore database;
5> }

using target database controlfile instead of recovery catalog
allocated channel: CH00
channel CH00: sid=13 devtype=SBT_TAPE
channel CH00: Veritas NetBackup for Oracle - Release 6.5 (2007072323)

sent command to channel: CH00

Starting restore at 14-JUN-11

channel CH00: starting datafile backupset restore
channel CH00: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /oracle/app/oradata/china111/system01.dbf
restoring datafile 00005 to /oracle/app/oradata/china111/example01.dbf
restoring datafile 00012 to /oracle/app/oradata/china111/TBS_MIG_DATA02.dbf
channel CH00: restored backup piece 1
piece handle=bk_2597_1_753764402 tag=HOT_DB_BK_LEVEL0 params=NULL
channel CH00: restore complete
channel CH00: starting datafile backupset restore
channel CH00: specifying datafile(s) to restore from backup set
restoring datafile 00002 to /oracle/app/oradata/china111/undotbs01.dbf
restoring datafile 00003 to /oracle/app/oradata/china111/cwmlite01.dbf
restoring datafile 00006 to /oracle/app/oradata/china111/indx01.dbf
restoring datafile 00010 to /oracle/app/oradata/china111/xdb01.dbf
restoring datafile 00013 to /oracle/app/oradata/china111/perfstat.dbf
channel CH00: restored backup piece 1
piece handle=bk_2598_1_753764402 tag=HOT_DB_BK_LEVEL0 params=NULL
channel CH00: restore complete
channel CH00: starting datafile backupset restore
channel CH00: specifying datafile(s) to restore from backup set
restoring datafile 00004 to /oracle/app/oradata/china111/drsys01.dbf
restoring datafile 00007 to /oracle/app/oradata/china111/odm01.dbf
restoring datafile 00008 to /oracle/app/oradata/china111/tools01.dbf
restoring datafile 00009 to /oracle/app/oradata/china111/users01.dbf
restoring datafile 00011 to /oracle/app/oradata/china111/TBS_MIG_DATA01.dbf
channel CH00: restored backup piece 1
piece handle=bk_2599_1_753764858 tag=HOT_DB_BK_LEVEL0 params=NULL
channel CH00: restore complete
Finished restore at 14-JUN-11

完成restore數據庫恢復。

由於使用了最新的controlfile備份,還需要利用之前的歸檔日誌做數據庫恢復。

執行recover並結合備份信息得到完成恢復需要的歸檔。

SQL> recover database until cancel using backup controlfile;
ORA-00279: change 80864517522 generated at 06/14/2011 03:00:02 needed for
thread 1
ORA-00289: suggestion : /oracle/archive/china111_t1_arc_s1709.arc
ORA-00280: change 80864517522 for thread 1 is in sequence #1709


Specify log: {<RET>=suggested | filename | AUTO | CANCEL}

需要1709、1710的歸檔

使用rman恢復歸檔日誌:

-bash-3.00$ rman target /

Recovery Manager: Release 9.2.0.6.0 - 64bit Production

Copyright (c) 1995, 2002, Oracle Corporation.  All rights reserved.

connected to target database: CHINA111 (DBID=2087198266)

RMAN> run{
2> ALLOCATE CHANNEL CH00 TYPE 'SBT_TAPE';
3> SEND 'NB_ORA_SERV=sol1,NB_ORA_CLIENT=eagle';
4> restore archivelog from logseq 1709 until logseq 1710;
5> }

using target database controlfile instead of recovery catalog
allocated channel: CH00
channel CH00: sid=11 devtype=SBT_TAPE
channel CH00: Veritas NetBackup for Oracle - Release 6.5 (2007072323)

sent command to channel: CH00

Starting restore at 14-JUN-11

channel CH00: starting archive log restore to default destination
channel CH00: restoring archive log
archive log thread=1 sequence=1709
channel CH00: restoring archive log
archive log thread=1 sequence=1710
channel CH00: restored backup piece 1
piece handle=al_2601_1_753765924 tag=TAG20110614T032524 params=NULL
channel CH00: restore complete
Finished restore at 14-JUN-11
released channel: CH00

RMAN> 

有了需要的歸檔可以完成數據庫恢復了

-bash-3.00$ ls -l
total 717372
-rw-r-----   1 oracle   dba      367072256 Jun 14 18:25 china111_t1_arc_s1709.arc
-rw-r-----   1 oracle   dba        30208 Jun 14 18:24 china111_t1_arc_s1710.arc

SQL> recover database until cancel using backup controlfile;
ORA-00279: change 80864517522 generated at 06/14/2011 03:00:02 needed for
thread 1
ORA-00289: suggestion : /oracle/archive/china111_t1_arc_s1709.arc
ORA-00280: change 80864517522 for thread 1 is in sequence #1709


Specify log: {<RET>=suggested | filename | AUTO | CANCEL}

ORA-00279: change 80864574826 generated at 06/14/2011 03:25:19 needed for
thread 1
ORA-00289: suggestion : /oracle/archive/china111_t1_arc_s1710.arc
ORA-00280: change 80864574826 for thread 1 is in sequence #1710
ORA-00278: log file '/oracle/archive/china111_t1_arc_s1709.arc' no longer
needed for this recovery

Specify log: {<RET>=suggested | filename | AUTO | CANCEL}
cancel
Media recovery cancelled.

SQL> alter database open resetlogs;

Database altered.

SQL> select instance_name,status from v$instance;

INSTANCE_NAME    STATUS
---------------- ------------
china111         OPEN

完成Rman結合netbackup重定向異機恢復ORACLE數據庫


鏈接:http://www.itpub.net/thread-1446965-1-1.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章