nbu恢復oracle資料庫案例
1、安裝作業系統
2、安裝資料庫系統
3、安裝nbu軟體及配置
--安裝客戶端
上傳SYMCnbclient_Linux-RedHat2.6.18_7.5.0.2.tar
編輯本機hosts
vi /etc/hosts
新增:192.168.99.252 hdnbu1
解壓:
[root@scmtest u01]# tar -xvf SYMCnbclient_Linux-RedHat2.6.18_7.5.0.2.tar
[root@scmtest u01]# cd SYMCnbclient_Linux-RedHat2.6.18_7.5.0.2
[root@scmtest SYMCnbclient_Linux-RedHat2.6.18_7.5.0.2]# ./install
過程當中要輸入備份服務端:hdnbu1
然後再用oracle使用者執行:
[root@scmtest bin]# su - oracle
[oracle@scmtest ~]$ cd /usr/openv/netbackup/bin
[oracle@scmtest bin]$ ./oracle_link
Thu Feb 21 14:03:02 CST 2013
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: /software/oracle/product/10.2.0/db1
Oracle version: 10.2.0.5.0
Platform type: x86_64
Linking LIBOBK:
ln -s /usr/openv/netbackup/bin/libobk.so64 /software/oracle/product/10.2.0/db1/lib/libobk.so
Done
Please check the trace file located in /tmp/make_trace.23602
to make sure the linking process was successful.
4、編輯初始引數檔案
這時候,需要進行修改,比如原來用的什麼盤,現在用什麼盤等
編輯後如下:
*._addm_auto_enable=FALSE
*._b_tree_bitmap_plans=FALSE
*._db_block_numa=1
*._enable_NUMA_optimization=FALSE
*._optimizer_cartesian_enabled=FALSE
*._optimizer_skip_scan_enabled=FALSE
*.archive_lag_target=1800
*.audit_file_dest='/software/oracle/admin/ncerp/adump'
*.background_dump_dest='/software/oracle/admin/ncerp/bdump'
*.compatible='10.2.0.5.0'
*.control_files='/u01/ncerp/control/control01.ctl','/u01/ncerp/control/control02.ctl'
*.core_dump_dest='/software/oracle/admin/ncerp/cdump'
*.db_block_size=8192
*.db_cache_size=4294967296
*.db_create_file_dest='/u01/ncerp/flash_recover'
*.db_domain=''
*.db_file_multiblock_read_count=16
*.db_name='ncerp'
*.java_pool_size=33554432
*.job_queue_processes=10
*.large_pool_size=33554432
*.log_archive_dest_1='location=/u01/ncerp/arch'
*.log_archive_format='%s_%t_%r.log'
*.max_dump_file_size='1024'
*.open_cursors=1000
*.optimizer_dynamic_sampling=4
*.optimizer_index_cost_adj=40
*.parallel_max_servers=5
*.pga_aggregate_target=2147483648
*.processes=800
*.recyclebin='OFF'
*.shared_pool_size=838860800
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
5、根據引數檔案,建相應的目錄
[oracle@scmtest ~]$ mkdir -p /u01/ncerp/control/
[oracle@scmtest u01]$ mkdir -p /app/oracle/admin/ncerp/cdump
[oracle@scmtest u01]$ mkdir -p /app/oracle/admin/ncerp/bdump
[oracle@scmtest u01]$ mkdir -p /app/oracle/admin/ncerp/adump
[oracle@scmtest u01]$ mkdir -p /app/oracle/admin/ncerp/pfile
[oracle@scmtest u01]$ mkdir -p /u01/ncerp/flash_recover
[oracle@scmtest u01]$ mkdir -p /u01/ncerp/arch
[oracle@scmtest ncerp]$ mkdir oradata
注意:這些要與引數檔案對應,要不然無法啟動!
6、恢復控制檔案
export ORACLE_SID=ncerp
[oracle@scmtest u01]$ rman target /
Recovery Manager: Release 10.2.0.5.0 - Production on Thu Feb 21 14:17:10 2013
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database (not started)
RMAN> startup nomount pfile='/u01/ncpfile.ora';
Oracle instance started
Total System Global Area 5217714176 bytes
Fixed Size 2103536 bytes
Variable Size 905971472 bytes
Database Buffers 4294967296 bytes
Redo Buffers 14671872 bytes
從nbu的伺服器上查詢要恢復的控制檔案
hdnbu1:/tmp # bplist -C RD162 -t 4 -R -b -l / | more
-rw-rw---- oracle dba 10747904 Mar 28 11:26 /c-3383507379-20130328-0b
-rw-rw---- oracle dba 11010048 Mar 28 11:25 /c-2177845250-20130328-0d
-rw-rw---- oracle dba 10747904 Mar 28 11:25 /cntrl_9202_1_811250475
-rw-rw---- oracle dba 10747904 Mar 28 11:25 /cntrl_7788_1_811250456
-rw-rw---- oracle dba 10747904 Mar 28 11:25 /c-3383507379-20130328-0a
-rw-rw---- oracle dba 11010048 Mar 28 11:24 /c-2177845250-20130328-0c
-rw-rw---- oracle dba 114032640 Mar 28 11:17 /al_7786_1_811249961
-rw-rw---- oracle dba 123207680 Mar 28 11:17 /al_7785_1_811249961
-rw-rw---- oracle dba 3670016 Mar 28 11:17 /al_9200_1_811249960
-rw-rw---- oracle dba 3932160 Mar 28 11:17 /al_9199_1_811249959
-rw-rw---- oracle dba 11010048 Mar 28 09:25 /c-2177845250-20130328-0b
-rw-rw---- oracle dba 10747904 Mar 28 09:25 /c-3383507379-20130328-09
-rw-rw---- oracle dba 10747904 Mar 28 09:25 /cntrl_9197_1_811243259
-rw-rw---- oracle dba 10747904 Mar 28 09:25 /cntrl_7783_1_811243253
RMAN> run
2> {
3> allocate channel c1 type 'sbt_tape';
4> send 'NB_ORA_CLIENT=RD162';
5> restore controlfile from '/cntrl_24145_1_828414748';
6> release channel c1;
7> }
using target database control file instead of recovery catalog
allocated channel: c1
channel c1: sid=874 devtype=SBT_TAPE
channel c1: Veritas NetBackup for Oracle - Release 7.5 (2012050902)
sent command to channel: c1
Starting restore at 2013-03-28 12:41:30
channel c1: restoring control file
channel c1: restore complete, elapsed time: 00:05:16
output filename=/u02/ncerp/control/control01.ctl
output filename=/u02/ncerp/control/control02.ctl
Finished restore at 2013-03-28 12:46:47
released channel: c1
7、還原資料庫檔案
在這裡要查一下資料庫是否已經mount
SQL> select status from v$instance;
STATUS
------------
MOUNTED
RMAN> run {
ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE';
send 'NB_ORA_CLIENT=RD162';
set newname for datafile '/backup/ncerp/oradata/system01.dbf' to '/u02/ncerp/oradata/system01.dbf' ;
set newname for datafile '/backup/ncerp/oradata/system02.dbf' to '/u02/ncerp/oradata/system02.dbf' ;
set newname for datafile '/backup/ncerp/oradata/nnc_index03_1.dbf' to '/u02/ncerp/oradata/nnc_index03_1.dbf';
set newname for datafile '/backup/ncerp/oradata/undotbs1.dbf' to '/u02/ncerp/oradata/undotbs1.dbf' ;
set newname for datafile '/backup/ncerp/oradata/sysaux01.dbf' to '/u02/ncerp/oradata/sysaux01.dbf' ;
set newname for datafile '/backup/ncerp/oradata/users01.dbf' to '/u02/ncerp/oradata/users01.dbf' ;
set newname for datafile '/backup/ncerp/oradata/nnc_data01_1.dbf' to '/u02/ncerp/oradata/nnc_data01_1.dbf' ;
set newname for datafile '/backup/ncerp/oradata/nnc_data01_2.dbf' to '/u02/ncerp/oradata/nnc_data01_2.dbf' ;
set newname for datafile '/backup/ncerp/oradata/nnc_data01_3.dbf' to '/u02/ncerp/oradata/nnc_data01_3.dbf' ;
set newname for datafile '/backup/ncerp/oradata/nnc_data01_4.dbf' to '/u02/ncerp/oradata/nnc_data01_4.dbf' ;
set newname for datafile '/backup/ncerp/oradata/nnc_data02_1.dbf' to '/u02/ncerp/oradata/nnc_data02_1.dbf' ;
set newname for datafile '/backup/ncerp/oradata/nnc_data02_2.dbf' to '/u02/ncerp/oradata/nnc_data02_2.dbf' ;
set newname for datafile '/backup/ncerp/oradata/nnc_data03_1.dbf' to '/u02/ncerp/oradata/nnc_data03_1.dbf' ;
set newname for datafile '/backup/ncerp/oradata/nnc_data03_2.dbf' to '/u02/ncerp/oradata/nnc_data03_2.dbf' ;
set newname for datafile '/backup/ncerp/oradata/nnc_data03_3.dbf' to '/u02/ncerp/oradata/nnc_data03_3.dbf' ;
set newname for datafile '/backup/ncerp/oradata/nnc_data03_4.dbf' to '/u02/ncerp/oradata/nnc_data03_4.dbf' ;
set newname for datafile '/backup/ncerp/oradata/nnc_index02_1.dbf' to '/u02/ncerp/oradata/nnc_index02_1.dbf';
set newname for datafile '/backup/ncerp/oradata/nnc_index01_1.dbf' to '/u02/ncerp/oradata/nnc_index01_1.dbf';
set newname for datafile '/backup/ncerp/oradata/nnc_index01_2.dbf' to '/u02/ncerp/oradata/nnc_index01_2.dbf';
set newname for datafile '/backup/ncerp/oradata/nnc_index01_3.dbf' to '/u02/ncerp/oradata/nnc_index01_3.dbf';
set newname for datafile '/backup/ncerp/oradata/nnc_index01_4.dbf' to '/u02/ncerp/oradata/nnc_index01_4.dbf';
set newname for datafile '/backup/ncerp/oradata/iufo01.dbf' to '/u02/ncerp/oradata/iufo01.dbf' ;
set newname for datafile '/backup/ncerp/oradata/iufo02.dbf' to '/u02/ncerp/oradata/iufo02.dbf' ;
set newname for datafile '/backup/ncerp/oradata/nnc_data03_5.dbf' to '/u02/ncerp/oradata/nnc_data03_5.dbf' ;
Restore database;
Switch datafile all;
}
vi res_test.sh 內容如下:
export ORACLE_SID=ncerp
rman target / <
ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE';
send 'NB_ORA_CLIENT=RD162';
set newname for datafile '/backup/ncerp/oradata/system01.dbf' to '/u01/ncerp/oradata/system01.dbf';
set newname for datafile '/backup/ncerp/oradata/system02.dbf' to '/u01/ncerp/oradata/system02.dbf';
set newname for datafile '/backup/ncerp/oradata/nnc_index03_1.dbf' to '/u01/ncerp/oradata/nnc_index03_1.dbf';
set newname for datafile '/backup/ncerp/oradata/undotbs1.dbf' to '/u01/ncerp/oradata/undotbs1.dbf';
set newname for datafile '/backup/ncerp/oradata/sysaux01.dbf' to '/u01/ncerp/oradata/sysaux01.dbf';
set newname for datafile '/backup/ncerp/oradata/users01.dbf' to '/u01/ncerp/oradata/users01.dbf';
set newname for datafile '/backup/ncerp/oradata/nnc_data01_1.dbf' to '/u01/ncerp/oradata/nnc_data01_1.dbf';
set newname for datafile '/backup/ncerp/oradata/nnc_data01_2.dbf' to '/u01/ncerp/oradata/nnc_data01_2.dbf';
set newname for datafile '/backup/ncerp/oradata/nnc_data01_3.dbf' to '/u01/ncerp/oradata/nnc_data01_3.dbf';
set newname for datafile '/backup/ncerp/oradata/nnc_data01_4.dbf' to '/u01/ncerp/oradata/nnc_data01_4.dbf';
set newname for datafile '/backup/ncerp/oradata/nnc_data02_1.dbf' to '/u01/ncerp/oradata/nnc_data02_1.dbf';
set newname for datafile '/backup/ncerp/oradata/nnc_data02_2.dbf' to '/u01/ncerp/oradata/nnc_data02_2.dbf';
set newname for datafile '/backup/ncerp/oradata/nnc_data03_1.dbf' to '/u01/ncerp/oradata/nnc_data03_1.dbf';
set newname for datafile '/backup/ncerp/oradata/nnc_data03_2.dbf' to '/u01/ncerp/oradata/nnc_data03_2.dbf';
set newname for datafile '/backup/ncerp/oradata/nnc_data03_3.dbf' to '/u01/ncerp/oradata/nnc_data03_3.dbf';
set newname for datafile '/backup/ncerp/oradata/nnc_data03_4.dbf' to '/u01/ncerp/oradata/nnc_data03_4.dbf';
set newname for datafile '/backup/ncerp/oradata/nnc_index02_1.dbf' to '/u01/ncerp/oradata/nnc_index02_1.dbf';
set newname for datafile '/backup/ncerp/oradata/nnc_index01_1.dbf' to '/u01/ncerp/oradata/nnc_index01_1.dbf';
set newname for datafile '/backup/ncerp/oradata/nnc_index01_2.dbf' to '/u01/ncerp/oradata/nnc_index01_2.dbf';
set newname for datafile '/backup/ncerp/oradata/nnc_index01_3.dbf' to '/u01/ncerp/oradata/nnc_index01_3.dbf';
set newname for datafile '/backup/ncerp/oradata/nnc_index01_4.dbf' to '/u01/ncerp/oradata/nnc_index01_4.dbf';
set newname for datafile '/backup/ncerp/oradata/iufo01.dbf' to '/u01/ncerp/oradata/iufo01.dbf';
set newname for datafile '/backup/ncerp/oradata/iufo02.dbf' to '/u01/ncerp/oradata/iufo02.dbf';
set newname for datafile '/backup/ncerp/oradata/nnc_data03_5.dbf' to '/u01/ncerp/oradata/nnc_data03_5.dbf';
Restore database;
Switch datafile all;
RELEASE CHANNEL ch00;
}
exit
EOF
date
[oracle@scmtest u01]$ nohup ./res_test.sh > testlog.log &
8、恢復歸檔日誌
SQL> select max(SEQUENCE#) from v$archived_log;
MAX(SEQUENCE#)
--------------
3651
SQL> select * from (select status,SEQUENCE#,COMPLETION_TIME from v$archived_log where SEQUENCE# >= 5485 order by SEQUENCE# desc) where rownum <=30;
S SEQUENCE# COMPLETION_TIME
- ---------- -------------------
D 5485 2013-03-28 11:12:40
run
{
set archivelog destination to '/u02/ncerp/arch';
ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE';
send 'NB_ORA_CLIENT=RD162';
restore archivelog sequence between 5463 and 5486 thread 1;
RELEASE CHANNEL ch00;
}
做一次恢復測試看看
SQL> recover database using backup controlfile until cancel;
ORA-00279: change 86837184 generated at 03/28/2013 01:55:53 needed for thread 1
ORA-00289: suggestion : /u02/ncerp/arch/5464_1_800011778.log
ORA-00280: change 86837184 for thread 1 is in sequence #5464
Specify log: {
auto
ORA-00308: cannot open archived log '/u02/ncerp/arch/5464_1_800011778.log'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
ORA-00308: cannot open archived log '/u02/ncerp/arch/5464_1_800011778.log'
ORA-27037: unable to obtain file status
Linux-x86_64 Error: 2: No such file or directory
Additional information: 3
ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
ORA-01152: file 1 was not restored from a sufficiently old backup
ORA-01110: data file 1: '/u02/ncerp/oradata/system01.dbf'
說明需要3556這個歸檔日誌
所以恢復時,從這個日誌進行恢復!
也可以採用後臺執行方式
export ORACLE_SID=ncerp
rman target /
run
{
set archivelog destination to '/u01/ncerp/arch';
ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE';
send 'NB_ORA_CLIENT=RD162';
restore archivelog sequence between 3556 and 3562 thread 1;
RELEASE CHANNEL ch00;
}
9、資料庫恢復
SQL> ALTER DATABASE RENAME FILE '/backup/ncerp/redo/redo01.log' TO '/u02/ncerp/redo/redo01.log';
SQL> ALTER DATABASE RENAME FILE '/backup/ncerp/redo/redo02.log' TO '/u02/ncerp/redo/redo02.log';
SQL> ALTER DATABASE RENAME FILE '/backup/ncerp/redo/redo03.log' TO '/u02/ncerp/redo/redo03.log';
SQL> ALTER DATABASE RENAME FILE '/backup/ncerp/redo/redo04.log' TO '/u02/ncerp/redo/redo04.log';
SQL> ALTER DATABASE RENAME FILE '/backup/ncerp/redo/redo05.log' TO '/u02/ncerp/redo/redo05.log';
SQL> ALTER DATABASE RENAME FILE '/backup/ncerp/redo/redo06.log' TO '/u02/ncerp/redo/redo06.log';
SQL> recover database using backup controlfile until cancel;
ORA-00279: change 2418426514 generated at 01/10/2013 21:58:37 needed for thread
1
ORA-00289: suggestion : /u03/app/oracle/oradata/arch/1052_1_800727819.log
ORA-00280: change 2418426514 for thread 1 is in sequence #1052
Specify log: {
auto
SQL> recover database using backup controlfile until cancel;
ORA-00279: change 2418716975 generated at 01/11/2013 09:50:06 needed for thread
1
ORA-00289: suggestion : /u03/app/oracle/oradata/arch/1070_1_800727819.log
ORA-00280: change 2418716975 for thread 1 is in sequence #1070
Specify log: {
cancel
說明,如果上面日誌可能有點大的時候,我們需要調整,比如說刪除日誌組等,然後還重新新增日誌到新位置
10、開啟資料庫
SQL> alter database open resetlogs;
Database altered.
11、建立臨時表空間
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/29371470/viewspace-1062685/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle案例12——NBU Oracle恢復Oracle
- NBU恢復oracleOracle
- 【資料庫資料恢復】Oracle資料庫誤truncate table的資料恢復案例資料庫資料恢復Oracle
- 【資料庫資料恢復】SAP資料庫資料恢復案例資料庫資料恢復
- 【資料庫資料恢復】ASM磁碟組掉線的Oracle資料庫資料恢復案例資料庫資料恢復ASMOracle
- 【資料庫資料恢復】Sql Server資料庫資料恢復案例資料庫資料恢復SQLServer
- 【資料庫資料恢復】ASM例項不能掛載的Oracle資料庫資料恢復案例資料庫資料恢復ASMOracle
- 資料庫恢復案例大全資料庫
- 虎年初十ORACLE資料庫恢復案例Oracle資料庫
- 【資料庫資料恢復】斷電導致Oracle資料庫資料丟失的資料恢復案例資料庫資料恢復Oracle
- 【資料庫資料恢復】Oracle ASM例項無法掛載的資料恢復案例資料庫資料恢復OracleASM
- 【資料庫資料恢復】Oracle資料庫檔案出現壞塊報錯的資料恢復案例資料庫資料恢復Oracle
- 【oracle資料庫資料恢復】誤操作導致的資料庫誤刪除的資料恢復案例Oracle資料庫資料恢復
- 練習:資料庫恢復案例資料庫
- 資料庫常規恢復案例資料庫
- MySQL 資料庫增量資料恢復案例MySql資料庫資料恢復
- 【資料庫資料恢復】SqlServer資料庫無法讀取的資料恢復案例資料庫資料恢復SQLServer
- 【資料庫資料恢復】sql server資料庫連線失效的資料恢復案例資料庫資料恢復SQLServer
- 【資料庫資料恢復】linux系統下MYSQL資料庫資料恢復案例資料庫資料恢復LinuxMySql
- 【資料庫資料恢復】MongoDB資料庫檔案損壞的資料恢復案例資料庫資料恢復MongoDB
- 非常實用的Oracle資料庫資料恢復方法案例Oracle資料庫資料恢復
- 伺服器資料恢復—透過拼接資料庫碎片恢復SqlServer資料庫資料的資料恢復案例伺服器資料恢復資料庫SQLServer
- NBU之oracle的備份恢復Oracle
- 【資料庫資料恢復】SQL Server資料庫磁碟空間不足的資料恢復案例資料庫資料恢復SQLServer
- 【資料庫資料恢復】如何恢復Oracle資料庫truncate表的資料資料庫資料恢復Oracle
- 伺服器資料恢復-ext3檔案系統下oracle資料庫資料恢復案例伺服器資料恢復Oracle資料庫
- 【資料庫資料恢復】MongoDB資料庫服務啟動失敗的資料恢復案例資料庫資料恢復MongoDB
- 資料庫資料恢復—附加資料庫錯誤823的SQL Server資料恢復案例資料庫資料恢復SQLServer
- 【北亞資料恢復】sqlserver資料庫被加密的資料恢復案例分享資料恢復SQLServer資料庫加密
- 【資料庫資料恢復】oracle資料庫誤truncate table怎麼恢復資料?資料庫資料恢復Oracle
- 【資料庫資料恢復】誤truncate table的Oracle資料庫資料恢復方案資料庫資料恢復Oracle
- 【資料庫資料恢復】EXT3檔案系統下MYSQL資料庫恢復案例資料庫資料恢復MySql
- 【北亞資料恢復】伺服器斷電導致Oracle資料庫報錯的資料恢復案例資料恢復伺服器Oracle資料庫
- 【資料庫資料恢復】華為雲ECS網站伺服器mysql資料庫資料恢復案例資料庫資料恢復網站伺服器MySql
- 【資料庫資料恢復】Oracle資料庫ASM磁碟組掉線如何恢復資料?資料庫資料恢復OracleASM
- 【資料庫資料恢復】無法啟動MongoDB服務的資料恢復案例資料庫資料恢復MongoDB
- Oracle異地資料庫恢復Oracle資料庫
- Oracle資料庫終極恢復Oracle資料庫