当前位置:  数据库>oracle

归档模式下,使用RMAN的同一备份两次用于不完全恢复

    来源: 互联网  发布时间:2017-05-28

    本文导语:  SCN的序列的递增性不随数据库的任何操作而改变,即使是RESETLOGS也如此。RESETLOGS清除所有联机日志文件中未应用的重做记录,RESETLOGS只重置日志文件的序列号为1,但对SCN无影响,SCN仍按原序列递增。在控制文件中保存resetlogs SCN...

SCN的序列的递增性不随数据库的任何操作而改变,即使是RESETLOGS也如此。
RESETLOGS清除所有联机日志文件中未应用的重做记录,RESETLOGS只重置日志文件的序列号为1,但对SCN无影响,SCN仍按原序列递增。

在控制文件中保存resetlogs SCN和计数器,以便唯一地标识用RESETLOGS选项执行的每一次打开数据库的操作。
这个值被写进每个数据文件头以及重做日志文件。
如果重做日志文件的日志序列号与Oracle的要求值不相符,则在恢复中不能应用重做日志文件。

RESETLOGS操作创建数据库的新形体,即一个的数据库。

根据以上理论:SCN为顺序数据流,在数据库存在期间始终递增,而,只不过,但。

前提是:

保证两股日志流(RESETLOGS之前的归档日志流和RESETLOGS之后的归档日志流)完整,并且有相应两股日志流的控制文件。

建议:在RESETLOGS前保证数据库以前备份的数据安全,。

如空间足够,建议永久保留RESETLOGS前创建的一致数据库备份。

1.关库做备份--RMAN,记下SCN与时间,记录序号及REDO。
2.打开库,记下时间/SCN,删除一个用户,做基于时间点的不完全恢复。记录不完全恢复后的SCN,归档序号
3.在恢复后的库,记下时间/SCN,再删除一个用户,使用步骤1中备份可以对RESETLOS后的库再次做不完全恢复。
##########################################################################################################

SYS@bys1>col name for a50
SYS@bys1>select * from (select name,recid,sequence#,status,applied from v$archived_log order by recid desc) where rownumselect incarnation#,resetlogs_change#,resetlogs_time,prior_resetlogs_time,status,resetlogs_id from v$database_incarnation;可以从此视图查出历次RESETLOGS情况
INCARNATION# RESETLOGS_CHANGE# RESETLOGS_TIME PRIOR_RESETLOGS_TIM STATUS RESETLOGS_ID
------------ ----------------- ------------------- ------------------- ------- ------------
1 1 2009/08/13 23:00:48 PARENT 694825248
2 754488 2013/08/01 08:58:04 2009/08/13 23:00:48 PARENT 822301084
3 2541692 2013/10/27 19:18:12 2013/08/01 08:58:04 PARENT 829941492
4 3228984 2013/11/06 00:14:08 2013/10/27 19:18:12 PARENT 830736848
5 3229505 2013/11/06 00:27:42 2013/11/06 00:14:08 CURRENT 830737662

SYS@bys1>startup mount;
ORACLE instance started.
Total System Global Area 631914496 bytes
Fixed Size 1338364 bytes
Variable Size 385876996 bytes
Database Buffers 239075328 bytes
Redo Buffers 5623808 bytes
SYS@bys1>exit

[oracle@bys001 ~]$ cat fullback.sh
rman log /home/oracle/backfull-`date +%Y%m%d-%H%M`.log 2> 3> 4> 5> 6> 7> RMAN>
[oracle@bys001 ~]$ sqlplus / as sysdba
SYS@bys1>alter database open;
Database altered.
###############
4.记录当前系统的SCN,并删除一个用户
SYS@bys1>select open_mode from v$database;
OPEN_MODE
--------------------

SYS@bys1>select dbid,checkpoint_change# from v$database;
DBID CHECKPOINT_CHANGE#
---------- ------------------
3957527513 3228508
SYS@bys1>col name for a40
SYS@bys1>select file#,name,checkpoint_change#,to_char(checkpoint_time,'yyyy-mm-dd hh24:mi:ss') cptime from v$datafile;
FILE# NAME CHECKPOINT_CHANGE# CPTIME
---------- ---------------------------------------- ------------------ -------------------
1 /u01/oradata/bys1/system01.dbf 3228508 2013-11-05 23:51:15
2 /u01/oradata/bys1/sysaux01.dbf 3228508 2013-11-05 23:51:15
3 /u01/oradata/bys1/undotbs01.dbf 3228508 2013-11-05 23:51:15
4 /u01/oradata/bys1/users01.dbf 3228508 2013-11-05 23:51:15
5 /u01/oradata/bys1/example01.dbf 3228508 2013-11-05 23:51:15
6 /u01/oradata/bys1/test1.dbf 3228508 2013-11-05 23:51:15
SYS@bys1> select GROUP#,sequence#,STATUS,FIRST_CHANGE#,to_char(FIRST_TIME,'yyyy/mm/dd:hh24:mi:ss') time from V$log;
GROUP# SEQUENCE# STATUS FIRST_CHANGE# TIME
---------- ---------- ---------------- ------------- -------------------
1 31 INACTIVE 3222825 2013/11/05:22:08:56
3228378 2013/11/05:23:38:08
3 30 INACTIVE 3218774 2013/11/05:22:00:30
SYS@bys1>set time on
23:55:34 SYS@bys1> select dbms_flashback.get_system_change_number from dual;
GET_SYSTEM_CHANGE_NUMBER
------------------------

23:55:35 SYS@bys1>conn test/test
Connected.
23:55:53 TEST@bys1>select * from cat;
TABLE_NAME TABLE_TYPE
------------------------------ -----------
TEST1 SYNONYM
23:56:06 TEST@bys1>conn / as sysdba
Connected.
23:56:18 SYS@bys1>drop user test cascade;
User dropped.
删除用户完成
######################################################################

23:57:19 @bys1>conn / as sysdba
Connected.
23:57:25 SYS@bys1>shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
23:57:42 SYS@bys1>
ORACLE instance started.

Total System Global Area 631914496 bytes
Fixed Size 1338364 bytes
Variable Size 385876996 bytes
Database Buffers 239075328 bytes
Redo Buffers 5623808 bytes
Database mounted.

##############################

restore database;
recover database until scn 3228983;
alter database open resetlogs;
################
RMAN>

Starting restore at 2013/11/06 00:08:56
using channel ORA_DISK_1

skipping datafile 3; already restored to file /u01/oradata/bys1/undotbs01.dbf
skipping datafile 4; already restored to file /u01/oradata/bys1/users01.dbf
skipping datafile 5; already restored to file /u01/oradata/bys1/example01.dbf
skipping datafile 6; already restored to file /u01/oradata/bys1/test1.dbf
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00001 to /u01/oradata/bys1/system01.dbf
channel ORA_DISK_1: restoring datafile 00002 to /u01/oradata/bys1/sysaux01.dbf
channel ORA_DISK_1: reading from backup piece /home/oracle/bys001full_BYS1_830735101_8
channel ORA_DISK_1: piece handle=/home/oracle/bys001full_BYS1_830735101_8 tag=BYS001-FULL
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:04:13
Finished restore at 2013/11/06 00:13:09

RMAN>

Starting recover at 2013/11/06 00:13:48
using channel ORA_DISK_1

starting media recovery
lapsed time: 00:00:03

Finished recover at 2013/11/06 00:13:51

RMAN>

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================


RMAN> alter database open resetlogs;
database opened
RMAN>
##########################################################

[oracle@bys001 ~]$ sqlplus / as sysdba
SYS@bys1>select open_mode from v$database;
OPEN_MODE
--------------------

SYS@bys1>col name for a40

BYS@bys1>show parameter archive_form
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_format string

 

初始化参数LOG_ARCHIVE_FORMAT用于指定归档日志的文件名格式,设置该初始化参数时,可以指定以下匹配符:
%S: 日志序列号(带有前导0) %t: 重做线程编号.%T: 重做线程编号(带有前导0) %a: 活动ID %d: 数据库ID号

SYS@bys1>select * from (select name,recid,sequence#,status,applied from v$archived_log order by recid desc) where rownumselect dbid,checkpoint_change# from v$database;
DBID CHECKPOINT_CHANGE#
---------- ------------------
3957527513
SYS@bys1>select file#,name,checkpoint_change#,to_char(checkpoint_time,'yyyy-mm-dd hh24:mi:ss') cptime from v$datafile;
FILE# NAME CHECKPOINT_CHANGE# CPTIME
---------- ---------------------------------------- ------------------ -------------------
1 /u01/oradata/bys1/system01.dbf 2013-11-06 00:14:27
2 /u01/oradata/bys1/sysaux01.dbf 3228987 2013-11-06 00:14:27
3 /u01/oradata/bys1/undotbs01.dbf 3228987 2013-11-06 00:14:27
4 /u01/oradata/bys1/users01.dbf 3228987 2013-11-06 00:14:27
5 /u01/oradata/bys1/example01.dbf 3228987 2013-11-06 00:14:27
6 /u01/oradata/bys1/test1.dbf 3228987 2013-11-06 00:14:27
SYS@bys1>select GROUP#,sequence#,STATUS,FIRST_CHANGE#,to_char(FIRST_TIME,'yyyy/mm/dd:hh24:mi:ss') time from V$log;
GROUP# SEQUENCE# STATUS FIRST_CHANGE# TIME
---------- ---------- ---------------- ------------- -------------------
1 CURRENT 2013/11/06:00:14:08 2 0 UNUSED 0
3 0 UNUSED 0
SYS@bys1>conn test/test
Connected.
TEST@bys1>set time on
00:16:34 TEST@bys1>select * from cat;
TABLE_NAME TABLE_TYPE
------------------------------ -----------
TEST1 SYNONYM
00:16:39 TEST@bys1>conn / as sysdba
Connected.
00:16:45 SYS@bys1>
GET_SYSTEM_CHANGE_NUMBER
------------------------

00:16:57 SYS@bys1>
User dropped.
00:17:12 SYS@bys1>conn test/test
ERROR:
ORA-01017: invalid username/password; logon denied

Warning: You are no longer connected to ORACLE.
00:17:17 @bys1>conn / as sysdba
Connected.
00:17:21 SYS@bys1>shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
00:17:40 SYS@bys1>startup mount;
ORACLE instance started.

Total System Global Area 631914496 bytes
Fixed Size 1338364 bytes
Variable Size 385876996 bytes
Database Buffers 239075328 bytes
Redo Buffers 5623808 bytes
Database mounted.
############################################################

更多详情见请继续阅读下一页的精彩内容:

推荐阅读:

Oracle基础教程之通过RMAN复制数据库

RMAN备份策略制定参考内容

RMAN备份学习笔记

Oracle数据库备份加密 RMAN加密


    
 
 
 
本站(WWW.)旨在分享和传播互联网科技相关的资讯和技术,将尽最大努力为读者提供更好的信息聚合和浏览方式。
本站(WWW.)站内文章除注明原创外,均为转载、整理或搜集自网络。欢迎任何形式的转载,转载请注明出处。












  • 相关文章推荐
  • Hp Unix 或Linux下用tar归档,Aix Unix无法解归档,急!
  • 切换Oracle的归档模式以及非归档模式
  • oracle的归档模式 ORACLE数据库归档日志常用命令
  • 邮件归档软件 MailArchiva
  • 远程归档工具 Cyphertite
  • 怎么归档自己的包!
  • 如何归档一个目录下的部分文件?
  • oracle 如何关闭打开归档日志
  • 查看修改Oracle10G归档日志空间的限制
  • Oralce 归档日志开启与关闭示例
  • oracle日志操作模式(归档模式和非归档模式的利与弊)
  • SQLite 归档工具 SQLAR
  • 兼容 tar 的归档工具 btar
  • 归档文件是什么玩意啊?
  • 文档归档引擎 Archive4J
  • 更改Oracle数据库的归档模式
  • Oracle 删除归档日志实例
  • 关于Oracle将目标数据库设为归档模式应该注意的问题
  • Oracle数据库归档模式的切换
  • Oracle中归档模式的定义简述


  • 站内导航:


    特别声明:169IT网站部分信息来自互联网,如果侵犯您的权利,请及时告知,本站将立即删除!

    ©2012-2021,