共计 12234 个字符,预计需要花费 31 分钟才能阅读完成。
今天就跟大家聊聊有关 nbu 恢复 oracle 数据库的案例分析,可能很多人都不太了解,为了让大家更加了解,丸趣 TV 小编给大家总结了以下内容,希望大家根据这篇文章可以有所收获。
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 / EOF
run {
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
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: {RET =suggested | filename | AUTO | CANCEL}
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: {RET =suggested | filename | AUTO | CANCEL}
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: {RET =suggested | filename | AUTO | CANCEL}
cancel
说明,如果上面日志可能有点大的时候,我们需要调整,比如说删除日志组等,然后还重新添加日志到新位置
10、打开数据库
SQL alter database open resetlogs;
Database altered.
11、创建临时表空间
看完上述内容,你们对 nbu 恢复 oracle 数据库的案例分析有进一步的了解吗?如果还想了解更多知识或者相关内容,请关注丸趣 TV 行业资讯频道,感谢大家的支持。