登录  
 加关注
查看详情
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

飞哥的技术博客

世上无难事,只怕有心人!

 
 
 

日志

 
 
 
 

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

2009-06-23 20:02:40|  分类: Oracle |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |

 数据库在挂载状态下可以进行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 >input datafile fno=00003 >input datafile fno=00002 >input datafile fno=00004 >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 >input datafile fno=00003 >input datafile fno=00002 >input datafile fno=00004 >input datafile fno=00005 >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.


  评论这张
 
阅读(527)| 评论(0)

历史上的今天

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2018