$ cd /usr/openv/netbackup/bin
$ ./oracle_link
Tue Jun 26 15:53:04 CST 2012
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: /oracle/product/11.2.0
Oracle version: 11.2.0.3.0
Platform type: sparc
Linking LIBOBK:
ln -s /usr/openv/netbackup/bin/libobk.so64.1 /oracle/product/11.2.0/lib/libobk.so
Done
Please check the trace file located in /tmp/make_trace.6091
to make sure the linking process was successful.
注意这个提醒关机的警告可以忽略,9I中才需要关闭oracle实例。
三、创建备份脚本
将模板脚本编辑如下
ORACLE_HOME=/oracle/product/11.2.0
export ORACLE_HOME
ORACLE_SID=kbankdb
export ORACLE_SID
TARGET_CONNECT_STR=/
$RMAN target $TARGET_CONNECT_STR nocatalog msglog $RMAN_LOG_FILE append << EOF
RUN {
ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE';
ALLOCATE CHANNEL ch01 TYPE 'SBT_TAPE';
BACKUP
$BACKUP_TYPE
SKIP INACCESSIBLE
TAG hot_db_bk_level0
FILESPERSET 5
# recommended format
FORMAT 'bk_%s_%p_%t'
DATABASE;
sql 'alter system archive log current';
RELEASE CHANNEL ch00;
RELEASE CHANNEL ch01;
# backup all archive logs
ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE';
ALLOCATE CHANNEL ch01 TYPE 'SBT_TAPE';
BACKUP
BACKUP
filesperset 20
FORMAT 'al_%s_%p_%t'
ARCHIVELOG ALL;
RELEASE CHANNEL ch00;
RELEASE CHANNEL ch01;
#
# Note: During the process of backing up the database, RMAN also backs up the
# control file. This version of the control file does not contain the
# information about the current backup because "nocatalog" has been specified.
# To include the information about the current backup, the control file should
# be backed up as the last step of the RMAN section. This step would not be
# necessary if we were using a recovery catalog or auto control file backups.
#
ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE';
BACKUP
# recommended format
FORMAT 'cntrl_%s_%p_%t'
CURRENT CONTROLFILE;
RELEASE CHANNEL ch00;
}
SQL> create table mytable(id number(4),name varchar2(14)) tablespace users;
Table created.
SQL> insert into mytable values(01,'kbank');
1 row created.
SQL> commit;
Commit complete.
SQL> select * from mytable;
ID NAME
---------- --------------
1 kbank
SQL>
记录当前时间
SQL> alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';
Session altered.
SQL> select sysdate from dual;
SYSDATE
-------------------
2012-06-26 17:02:02
SQL>
再插入记录,并记录时间
SQL> insert into mytable values(02,'china');
1 row created.
SQL> commit;
Commit complete.
SQL> select sysdate from dual;
SYSDATE
-------------------
2012-06-26 17:03:33
SQL>
五、发起备份
确保备份成功。
六、执行不完全恢复
1.先关闭实例
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL>
2.加载到mount状态
SQL> startup mount;
ORACLE instance started.
Total System Global Area 2004860928 bytes
Fixed Size 2160696 bytes
Variable Size 587204552 bytes
Database Buffers 1409286144 bytes
Redo Buffers 6209536 bytes
Database mounted.
SQL>
3.执行恢复脚本,将数据库恢复到'2012/06/26 17:02:02'时刻
$ rman target /
Recovery Manager: Release 11.2.0.3.0 - Production on Tue Jun 26 17:19:37 2012
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
connected to target database: KBANKDB (DBID=4053543997, not open)
RMAN> run {
2> allocate channel ch1 type 'sbt_tape';
3> allocate channel ch2 type 'sbt_tape';
4> set until time "to_date('2012/06/26 17:02:02','yyyy/mm/dd hh24:mi:ss')";
5> restore database;
6> recover database;
7> release channel ch1;
8> release channel ch2;
9> }
using target database control file instead of recovery catalog
allocated channel: ch1
channel ch1: SID=96 device type=SBT_TAPE
channel ch1: Veritas NetBackup for Oracle - Release 7.1 (2012031623)
allocated channel: ch2
channel ch2: SID=127 device type=SBT_TAPE
channel ch2: Veritas NetBackup for Oracle - Release 7.1 (2012031623)
executing command: SET until clause
Starting restore at 26-JUN-12
channel ch1: starting datafile backup set restore
channel ch1: specifying datafile(s) to restore from backup set
channel ch1: restoring datafile 00001 to /oracle/TPGISOFTDB/sys/system01.dbf
channel ch1: restoring datafile 00003 to /oracle/TPGISOFTDB/undo/undotbs01.dbf
channel ch1: reading from backup piece bk_3_1_786988494
channel ch2: starting datafile backup set restore
channel ch2: specifying datafile(s) to restore from backup set
channel ch2: restoring datafile 00002 to /oracle/TPGISOFTDB/sys/sysaux01.dbf
channel ch2: restoring datafile 00004 to /oracle/TPGISOFTDB/data/users01.dbf
channel ch2: reading from backup piece bk_4_1_786988494
channel ch1: piece handle=bk_3_1_786988494 tag=HOT_DB_BK_LEVEL0
channel ch1: restored backup piece 1
channel ch1: restore complete, elapsed time: 00:04:25
channel ch2: piece handle=bk_4_1_786988494 tag=HOT_DB_BK_LEVEL0
channel ch2: restored backup piece 1
channel ch2: restore complete, elapsed time: 00:05:15
Finished restore at 26-JUN-12
Starting recover at 26-JUN-12
starting media recovery
archived log for thread 1 with sequence 2 is already on disk as file /oracle/product/11.2.0/dbs/arch1_2_786977585.dbf
archived log for thread 1 with sequence 3 is already on disk as file /oracle/product/11.2.0/dbs/arch1_3_786977585.dbf
archived log for thread 1 with sequence 4 is already on disk as file /oracle/product/11.2.0/dbs/arch1_4_786977585.dbf
archived log file name=/oracle/product/11.2.0/dbs/arch1_2_786977585.dbf thread=1 sequence=2
archived log file name=/oracle/product/11.2.0/dbs/arch1_3_786977585.dbf thread=1 sequence=3
media recovery complete, elapsed time: 00:00:15
Finished recover at 26-JUN-12
released channel: ch1
released channel: ch2
RMAN>
4.以resetlogs打开实例
RMAN> alter database open resetlogs;
database opened
RMAN>
RMAN> exit
5.检查表记录是否已经恢复到到'2012/06/26 17:02:02'时刻
$ sqlplus "/as sysdba"
SQL*Plus: Release 11.2.0.3.0 Production on Tue Jun 26 17:35:01 2012
Copyright (c) 1982, 2011, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, Oracle Label Security, OLAP, Data Mining,
Oracle Database Vault and Real Application Testing options
SQL> select * from mytable;
ID NAME
---------- --------------
1 kbank
SQL>
如果觉得我的文章对您有用,请点赞。您的支持将鼓励我继续创作!
赞1
添加新评论1 条评论
2015-11-05 16:20