Hot backup and Rman backup

Some friends asked if the hot backup and rman backup can  exist at the same system at same time .

I did some a test cases below :

1.Checking the files belongs to the database :

[oracle@test1 ~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Fri Jan 20 05:28:16 2012
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
/home/oracle/app/oracle/oradata/orcl/system01.dbf
/home/oracle/app/oracle/oradata/orcl/undotbs01.dbf
/home/oracle/app/oracle/oradata/orcl/sysaux01.dbf
/home/oracle/app/oracle/oradata/orcl/users01.dbf
/home/oracle/app/oracle/oradata/orcl/test2.dbf

SQL> select name from v$tablespace;

NAME
------------------------------
SYSTEM
UNDOTBS1
SYSAUX
TEMP
USERS
TEST2

6 rows selected.

SQL> create table hot_writting_t (col1 number(10)) tablespace test2;

Table created.

2.Starting  hot backup for the tablespace test2 :
 

SQL> alter tablespace test2 begin backup ;

Tablespace altered.

SQL> insert into hot_writting_t values (1);

1 row created.

SQL> commit;

Commit complete.


SQL> insert into hot_writting_t  select * from hot_writting_t;

1 row created.

SQL> / 

2 rows created.

SQL> /

4 rows created.

SQL> /

8 rows created.

SQL> commit;

Commit complete.

3.Checking  current log sequences

SQL> alter system switch logfile; ------------Here is the first logs generated for hot backup number should sequence number is  140

System altered.

SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /home/oracle/arch1/chicago/
Oldest online log sequence     139
Next log sequence to archive   141
Current log sequence           141
SQL> alter system switch logfile;

System altered.

SQL> alter system switch logfile;

System altered.

SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /home/oracle/arch1/chicago/
Oldest online log sequence     141
Next log sequence to archive   143
Current log sequence           143

4.SQL> ---Ok now switch to rman to backup the database full;
                And remember the log sequence are from 143
 
[oracle@test1 ~]$ rman target /

Recovery Manager: Release 10.2.0.1.0 - Production on Fri Jan 20 05:39:30 2012

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

connected to target database: ORCL (DBID=1236993297)

RMAN> backup database;

Starting backup at 20-JAN-12
using channel ORA_DISK_1
RMAN-06554: WARNING: file 5 is in backup mode
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/home/oracle/app/oracle/oradata/orcl/system01.dbf
input datafile fno=00003 name=/home/oracle/app/oracle/oradata/orcl/sysaux01.dbf
input datafile fno=00005 name=/home/oracle/app/oracle/oradata/orcl/test2.dbf
input datafile fno=00002 name=/home/oracle/app/oracle/oradata/orcl/undotbs01.dbf
input datafile fno=00004 name=/home/oracle/app/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: starting piece 1 at 20-JAN-12
channel ORA_DISK_1: finished piece 1 at 20-JAN-12
piece handle=/home/oracle/app/oracle/flash_recovery_area/CHICAGO/backupset/2012_01_20/o1_mf_nnndf_TAG20120120T054026_7kk3gclh_.bkp tag=TAG20120120T054026 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:05:16
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 20-JAN-12
channel ORA_DISK_1: finished piece 1 at 20-JAN-12
piece handle=/home/oracle/app/oracle/flash_recovery_area/CHICAGO/backupset/2012_01_20/o1_mf_ncsnf_TAG20120120T054026_7kk3r9cn_.bkp tag=TAG20120120T054026 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 20-JAN-12

5.Switch some logfiles :

SQL> alter system switch logfile;

System altered.

SQL> /

System altered.

SQL> /

System altered.

SQL> /

System altered.

SQL> /

System altered.

SQL> /

System altered.

SQL> /

System altered.

SQL> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            /home/oracle/arch1/chicago/
Oldest online log sequence     148
Next log sequence to archive   150
Current log sequence           150




6.End backup and shutdown the database 

SQL> alter tablespace test2 end backup ;

Tablespace altered.

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> quit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

7.Destroy the datafiles belong to the database ;

[oracle@test1 ~]$ mv /home/oracle/app/oracle/oradata/orcl/test2.dbf /home/oracle/app/oracle/oradata/orcl/test2.dbf.bak

8.DB can not startup now :

[oracle@test1 orcl]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Fri Jan 20 05:58:57 2012

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area  184549376 bytes
Fixed Size                  1218412 bytes
Variable Size              79693972 bytes
Database Buffers          100663296 bytes
Redo Buffers                2973696 bytes
Database mounted.
ORA-01110: data file 5: '/home/oracle/app/oracle/oradata/orcl/test2.dbf'
ORA-01115: IO error reading block from file 5 (block # 1)
ORA-27069: attempt to do I/O beyond the range of the file
Additional information: 1
Additional information: 1


SQL> shutdown abort;
ORACLE instance shut down.
SQL>
SQL>
SQL> quit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

9.As rman expect ,we need the "full backup sets" and archived logs from 143 then we can perform. a complete recover for the database .

10.Ok ,prepare these for rman to recover the database:
we keep the full backup and archived logs since 143 :

[oracle@test1 orcl]$ cd /home/oracle/arch1/chicago/
[oracle@test1 chicago]$ ls
1_137_709212561.arc  1_140_709212561.arc  1_143_709212561.arc  1_146_709212561.arc  1_149_709212561.arc
1_138_709212561.arc  1_141_709212561.arc  1_144_709212561.arc  1_147_709212561.arc
1_139_709212561.arc  1_142_709212561.arc  1_145_709212561.arc  1_148_709212561.arc

[oracle@test1 chicago]$ mkdir bffullbkp
[oracle@test1 chicago]$ mv 1_13* bffullbkp/
[oracle@test1 chicago]$ ls
1_140_709212561.arc  1_142_709212561.arc  1_144_709212561.arc  1_146_709212561.arc  1_148_709212561.arc  bffullbkp
1_141_709212561.arc  1_143_709212561.arc  1_145_709212561.arc  1_147_709212561.arc  1_149_709212561.arc
[oracle@test1 chicago]$ mv 1_140_709212561.arc  bffullbkp/
[oracle@test1 chicago]$ mv 1_141_709212561.arc  bffullbkp/
[oracle@test1 chicago]$ mv 1_142_709212561.arc  bffullbkp/
[oracle@test1 chicago]$ mv 1_143_709212561.arc  bffullbkp/

11.As expect we are able to recover the database ,but the testing result was :

RMAN> restore database -force ;

Starting restore at 20-JAN-12
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK

channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /home/oracle/app/oracle/oradata/orcl/system01.dbf
restoring datafile 00002 to /home/oracle/app/oracle/oradata/orcl/undotbs01.dbf
restoring datafile 00003 to /home/oracle/app/oracle/oradata/orcl/sysaux01.dbf
restoring datafile 00004 to /home/oracle/app/oracle/oradata/orcl/users01.dbf
restoring datafile 00005 to /home/oracle/app/oracle/oradata/orcl/test2.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/app/oracle/flash_recovery_area/CHICAGO/backupset/2012_01_20
/o1_mf_nnndf_TAG20120120T054026_7kk3gclh_.bkp
channel ORA_DISK_1: restored backup piece 1
piece handle=/home/oracle/app/oracle/flash_recovery_area/CHICAGO/backupset/2012_01_20/o1_mf_nnndf_TAG20120120T054026_7kk3gclh_.bkp tag=TAG20120120T054026
channel ORA_DISK_1: restore complete, elapsed time: 00:02:25
Finished restore at 20-JAN-12

12.Now recover the database with the archived logs ;


RMAN> recover database;

Starting recover at 20-JAN-12
using channel ORA_DISK_1

starting media recovery

archive log thread 1 sequence 144 is already on disk as file /home/oracle/arch1/chicago/1_144_709212561.arc
archive log thread 1 sequence 145 is already on disk as file /home/oracle/arch1/chicago/1_145_709212561.arc
archive log thread 1 sequence 146 is already on disk as file /home/oracle/arch1/chicago/1_146_709212561.arc
archive log thread 1 sequence 147 is already on disk as file /home/oracle/arch1/chicago/1_147_709212561.arc
archive log thread 1 sequence 148 is already on disk as file /home/oracle/arch1/chicago/1_148_709212561.arc
archive log thread 1 sequence 149 is already on disk as file /home/oracle/arch1/chicago/1_149_709212561.arc
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 01/20/2012 06:47:49
RMAN-06053: unable to perform. media recovery because of missing log
RMAN-06025: no backup of log thread 1 seq 143 lowscn 4630655 found to restore
RMAN-06025: no backup of log thread 1 seq 142 lowscn 4630615 found to restore
RMAN-06025: no backup of log thread 1 seq 141 lowscn 4630605 found to restore
RMAN-06025: no backup of log thread 1 seq 140 lowscn 4629109 found to restore

*******************************************************************************************
Ok from here we could see the 140 ---143 are all needed to restore the database;
*******************************************************************************************
The is the key point to answer our questions

[oracle@test1 chicago]$ cd bffullbkp/
[oracle@test1 bffullbkp]$ mv *.arc ./..
RMAN> recover database;

Starting recover at 20-JAN-12
using channel ORA_DISK_1

starting media recovery

archive log thread 1 sequence 140 is already on disk as file /home/oracle/arch1/chicago/1_140_709212561.arc
archive log thread 1 sequence 141 is already on disk as file /home/oracle/arch1/chicago/1_141_709212561.arc
archive log thread 1 sequence 142 is already on disk as file /home/oracle/arch1/chicago/1_142_709212561.arc
archive log thread 1 sequence 143 is already on disk as file /home/oracle/arch1/chicago/1_143_709212561.arc
archive log thread 1 sequence 144 is already on disk as file /home/oracle/arch1/chicago/1_144_709212561.arc
archive log thread 1 sequence 145 is already on disk as file /home/oracle/arch1/chicago/1_145_709212561.arc
archive log thread 1 sequence 146 is already on disk as file /home/oracle/arch1/chicago/1_146_709212561.arc
archive log thread 1 sequence 147 is already on disk as file /home/oracle/arch1/chicago/1_147_709212561.arc
archive log thread 1 sequence 148 is already on disk as file /home/oracle/arch1/chicago/1_148_709212561.arc
archive log thread 1 sequence 149 is already on disk as file /home/oracle/arch1/chicago/1_149_709212561.arc
archive log filename=/home/oracle/arch1/chicago/1_140_709212561.arc thread=1 sequence=140
archive log filename=/home/oracle/arch1/chicago/1_141_709212561.arc thread=1 sequence=141
archive log filename=/home/oracle/arch1/chicago/1_142_709212561.arc thread=1 sequence=142
archive log filename=/home/oracle/arch1/chicago/1_143_709212561.arc thread=1 sequence=143
archive log filename=/home/oracle/arch1/chicago/1_144_709212561.arc thread=1 sequence=144
archive log filename=/home/oracle/arch1/chicago/1_145_709212561.arc thread=1 sequence=145
archive log filename=/home/oracle/arch1/chicago/1_146_709212561.arc thread=1 sequence=146
archive log filename=/home/oracle/arch1/chicago/1_147_709212561.arc thread=1 sequence=147
media recovery complete, elapsed time: 00:00:03
Finished recover at 20-JAN-12

RMAN> alter database open;

database opened

RMAN>

Summary :
------------------------------------------------------------------------------------------------------------------
Based on the test cases ,we could see ,when rman full backup occurred between "begin backup " and "end backup " the archived logs during these period will be needed to perform. the complete recover .

For some guys has the habit  to "DELTE" the "archived logs all " before any RMAN full backup , So we don't suggest to use hot backup and rman backup at the same time on the same SYSTEM.

It's a risk for rman to lose the ability to recover the database for missing the archived logs generated before the full backup;
------------------------------------------------------------------------------------------------------------------

About what will happen after hot backup ,pls refer to Oracle Support Note :
What Happens During a Hot Backup[Document 22956.1]



来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/598601/viewspace-714885/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/598601/viewspace-714885/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值