Oracle Archivelog、视图及日志分析

来源:互联网 发布:php 邀请码注册数据库 编辑:程序博客网 时间:2024/06/05 10:01

编写时间:2015416日星期四

编写人:蜗牛

QQ  295013648


  1. 说明

Archivelog,也就是我们通常所说的归档,那什么是归档,归档是怎么产生的,其作用又是什么,归档文件中到底存在什么样的内容,这些都是作为数据库管理员的我们应该知道,并且能够应用到工作中的。在参加工作的两年多里,本人一直都在从事着oraclesybase相关的工作,期间也整理过很多的资料,但都很乱。下面就来整理一下关于归档原理与相关只是吧。

 

 

  1. 为什么需要归档

在我们讲什么是归档之前,就需要说一下为什么需要归档。为什么需要归档哪?那么如果真的没有归档会发生什么事情?

  1. rman online备份不存在
  2. 闪回功能不存在
  3. Dataguard不存在
  1. Goldengate不存在
  1. 流功能不存在
  2. ……

那么现在应该知道归档为什么这么重要了吧,当然起初归档的产生原因可能很简单,可能是客户需要更安全的数据库,也可能是其他原因,但正是因为归档的存在,才有了oracle一系列基于归档的新功能或者新应用。

 

  1. 归档总结

下面我们就基于归档的生命周期,来对归档进行进一步的总结。

 

  1. 归档从哪来

要说归档从哪来,那就要先提一下redo日志了(我有一篇专门关于redo日志的文档叫Oracle Redo,在我的百度中应该有,下面也不会说太多),redo中存放的是数据库中数据的变更,每对数据或者数据库表做插入、删除、修改操作,在redo中都会进行记录,这样做是为了数据安全。归档就是由oracle数据库后台进程ARCn进程redo日志文件中的内容复制到归档文件中。

 

  1. 归档的作用

归档日志在oracle数据库中是非常重要,它能够使数据库更加的安全可靠,甲骨文公司基于归档为oracle数据库增加了很多新的功能,例如闪回、数据流等,更为online备份打下了基础,还开发了新的应用,例如DGOGG等。

  1. 怎么查看归档

查看归档分为两个部分,一是逻辑层面查看归档日志,二是物理层面查看归档日志,只有这样才能更好的理解归档,分析归档,以及利用归档。

 

3.1从逻辑层面查询归档

相关视图V$ARCHIVEV$ARCHIVED_LOGV$ARCHIVE_DESTV$ARCHIVE_DEST_STATUSV$ARCHIVE_GAPV$ARCHIVE_PROCESSES等。

 

Dynamic Performance View

Description

V$DATABASE

Shows if the database is in ARCHIVELOG or NOARCHIVELOG

mode and if MANUAL (archiving mode) has been specified.

V$ARCHIVED_LOG

V$ARCHIVED_LOG displays archived log information from the control file, including

archive log names. An archive log record is inserted after the online redo log is

successfully archived or cleared (name column is NULL if the log was cleared). If the log

is archived twice, there will be two archived log records with the same THREAD#,

SEQUENCE#, and FIRST_CHANGE#, but with a different name. An archive log record is

also inserted when an archive log is restored from a backup set or a c

 

V$ARCHIVE_DEST

Describes the current instance, all archive destinations, and

the current value, mode, and status of these destinations

V$ARCHIVE_PROCESSES

Displays information about the state of the various archive

processes for an instance.

V$ARCHIVE_DEST_STATUS

V$ARCHIVE_DEST_STATUS displays runtime and configuration information for the

archived redo log destinations. The information in this view does not persist across an

instance shutdown.

V$ARCHIVE_GAP

V$ARCHIVE_GAP displays information about archive gaps on a standby database. This

view can be used to find out the current archive gap that is blocking recovery for the

current recovery incarnation.

V$ARCHIVE

V$ARCHIVE displays information about redo log files in need of archiving. Each row

displays information for one thread. This information is also available in V$LOG. Oracle

recommends that you use V$LOG.

 

 

3.2从物理层面查看归档

要从逻辑层面查看归档就牵扯到了日志分析了,通过日志分析,我们可以去查看数据库中到底执行了什么样的命令,更新了那些对象,谁在更新等信息。下面我们就针对归档日志做一些日志分析。

命令如下

SQL>execdbms_logmnr.add_logfile(logfilename=>'/flash/ORCL/archivelog/2015_04_16/o1_mf_1_80_blyjdrvq_.arc',options=>dbms_logmnr.new);

 

PL/SQLprocedure successfully completed.

 

SQL>

SQL>EXECDBMS_LOGMNR.START_LOGMNR(OPTIONS=>DBMS_LOGMNR.DICT_FROM_ONLINE_CATALOG);

 

PL/SQLprocedure successfully completed.

 

selectSCN,TABLE_NAME,USERNAME from v$logmnr_contents;

可以从表中查看到所做的操作。

 

四、待补充

0 0
原创粉丝点击