数据库在挂载状态下可以进行consistent backup

 证明的思路是:
1、使用在数据库处于NOARCHIVELOG非归档模式的mount状态下进行的数据库备份在进行还原数据库之后
   不需要恢复(recover)操作的话,即可认为数据库处于NOARCHIVELOG非归档模式的mount状态下可以进行
   consistant backup;
2、再对数据库处于ARCHIVELOG非归档模式的mount状态下进行的数据库备份,然后在mount状态下进行一
   些操作,以产生日志,然后再进行还原操作,不进行recover操作直接open数据库如何?进行recover操
   作之后进行open数据库如何?

下面的是证明的具体操作步骤:
下面在数据库处于NOARCHIVELOG非归档模式的mount状态下进行consistant backup
1、首先数据需要处于NOARCHIVELOG非归档模式下:
SQL> select name,log_mode from v$database;
NAME      LOG_MODE
--------- ------------
MYDB      NOARCHIVELOG

SQL> archive log list;
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     6
Current log sequence           8

2、挂载数据库
SQL> connect / as sysdba
Connected to an idle instance.
SQL> startup mount;
ORACLE instance started.
Total System Global Area  167772160 bytes
Fixed Size                  1218316 bytes
Variable Size              71305460 bytes
Database Buffers           92274688 bytes
Redo Buffers                2973696 bytes
Database mounted.

3、在数据库挂载状态下备份一致数据库(consistant backup)
RMAN> backup database tag 'tag_1';
Starting backup at 26-NOV-08
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/opt/oracle/oradata/mydb/system01.dbf
input datafile fno=00003 name=/opt/oracle/oradata/mydb/sysaux01.dbf
input datafile fno=00002 name=/opt/oracle/oradata/mydb/undotbs01.dbf
input datafile fno=00004 name=/opt/oracle/oradata/mydb/users01.dbf
channel ORA_DISK_1: starting piece 1 at 26-NOV-08
channel ORA_DISK_1: finished piece 1 at 26-NOV-08
piece handle=/opt/oracle/flash_recovery_area/MYDB/backupset/2008_11_26/o1_mf_nnndf_TAG_1_4lstn3pz_.bkp tag=TAG_1 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:56
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 26-NOV-08
channel ORA_DISK_1: finished piece 1 at 26-NOV-08
piece handle=/opt/oracle/flash_recovery_area/MYDB/backupset/2008_11_26/o1_mf_ncsnf_TAG_1_4lstqw5g_.bkp tag=TAG_1 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
Finished backup at 26-NOV-08

RMAN> shutdown immediate
database dismounted
Oracle instance shut down

SQL> connect / as sysdba
Connected to an idle instance.
SQL> startup mount;
ORACLE instance started.
Total System Global Area  167772160 bytes
Fixed Size                  1218316 bytes
Variable Size              71305460 bytes
Database Buffers           92274688 bytes
Redo Buffers                2973696 bytes
Database mounted.

--使用consistant backup来进行还原数据库
RMAN> restore database from tag='tag_1';
Starting restore at 26-NOV-08
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK
skipping datafile 1; already restored to file /opt/oracle/oradata/mydb/system01.dbf
skipping datafile 2; already restored to file /opt/oracle/oradata/mydb/undotbs01.dbf
skipping datafile 3; already restored to file /opt/oracle/oradata/mydb/sysaux01.dbf
skipping datafile 4; already restored to file /opt/oracle/oradata/mydb/users01.dbf
restore not done; all files readonly, offline, or already restored
Finished restore at 26-NOV-08

--此时不需要做recover操作即可进行open数据库操作
RMAN> SQL 'ALTER DATABASE OPEN';
sql statement: ALTER DATABASE OPEN

RMAN> SHUTDOWN IMMEDIATE;
database closed
database dismounted
Oracle instance shut down


下面在数据库处于归档模式的mount状态下进行consistant backup
1、首先需要数据库是处于归档模式下:
SQL> archive log list;
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     6
Current log sequence           8

SQL> select name,log_mode from v$database;
NAME      LOG_MODE
--------- ------------
MYDB      NOARCHIVELOG

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup mount;
ORACLE instance started.
Total System Global Area  167772160 bytes
Fixed Size                  1218316 bytes
Variable Size              71305460 bytes
Database Buffers           92274688 bytes
Redo Buffers                2973696 bytes
Database mounted.

修改数据库为归档模式:
SQL>  alter database archivelog;
Database altered.

SQL> select name,log_mode from v$database;
NAME      LOG_MODE
--------- ------------
MYDB      ARCHIVELOG   --修改为归档模式

SQL> select name,log_mode from v$database;
NAME      LOG_MODE
--------- ------------
MYDB      ARCHIVELOG   --修改为归档模式

2、在数据库mount状态下进行备份
RMAN> backup database tag 'tag_2';
Starting backup at 28-NOV-08
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=/opt/oracle/oradata/mydb/system01.dbf
input datafile fno=00003 name=/opt/oracle/oradata/mydb/sysaux01.dbf
input datafile fno=00002 name=/opt/oracle/oradata/mydb/undotbs01.dbf
input datafile fno=00004 name=/opt/oracle/oradata/mydb/users01.dbf
input datafile fno=00005 name=/opt/oracle/oradata/mydb/users02.dbf
channel ORA_DISK_1: starting piece 1 at 28-NOV-08
channel ORA_DISK_1: finished piece 1 at 28-NOV-08
piece handle=/opt/oracle/flash_recovery_area/MYDB/backupset/2008_11_28/o1_mf_nnndf_TAG_2_4lym5r1k_.bkp tag=TAG_2 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:36
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 28-NOV-08
channel ORA_DISK_1: finished piece 1 at 28-NOV-08
piece handle=/opt/oracle/flash_recovery_area/MYDB/backupset/2008_11_28/o1_mf_ncsnf_TAG_2_4lym8vhc_.bkp tag=TAG_2 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
Finished backup at 28-NOV-08


3、以sys用户登陆mount状态下的数据库,只做一些查询操作,
   观察SCN是否改变(不允许做其他的维护操作,mount状态下只能做fixed tables/views做查询操作如果做其他操作,会报如下错误:
   ORA-01219: database not open: queries allowed on fixed tables/views only),
   做了查询发现SCN并没有发生改变
--查看还原之后数据库的SCN
SQL> select current_scn from v$database;
CURRENT_SCN
-----------
          0
SQL> select dbms_flashback.get_system_change_number from dual;
select dbms_flashback.get_system_change_number from dual
       *
ERROR at line 1:
ORA-00904: "DBMS_FLASHBACK"."GET_SYSTEM_CHANGE_NUMBER": invalid identifier
分析:mount状态下不能获取到当前数据库的SCN


4、使用在mount下进行的备份进行还原
SQL> shutdown immediate;
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.

SQL> startup mount;
ORACLE instance started.
Total System Global Area  167772160 bytes
Fixed Size                  1218316 bytes
Variable Size              71305460 bytes
Database Buffers           92274688 bytes
Redo Buffers                2973696 bytes
Database mounted.

[oracle@localhost ~]$ rman target sys/test@MYDB

Recovery Manager: Release 10.2.0.1.0 - Production on Thu Nov 27 13:19:14 2008

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

connected to target database: MYDB (DBID=2586727849, not open)

RMAN> restore database from tag='tag_2';
Starting restore at 27-NOV-08
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK
skipping datafile 1; already restored to file /opt/oracle/oradata/mydb/system01.dbf
skipping datafile 2; already restored to file /opt/oracle/oradata/mydb/undotbs01.dbf
skipping datafile 3; already restored to file /opt/oracle/oradata/mydb/sysaux01.dbf
skipping datafile 4; already restored to file /opt/oracle/oradata/mydb/users01.dbf
restore not done; all files readonly, offline, or already restored
Finished restore at 27-NOV-08

--不进行recover操作,直接open数据库
RMAN> SQL 'alter database open';
sql statement: alter database open

结论:数据库处于mount状态下,不管数据库是归档模式还是非归档模式,所做的备份都是consistent backup.


 

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值