Oracle 9i DBA Fundamentals I 学习笔记(七)

Chapter 07— maintaining online redo log files


1
、联机重做日志文件
 •
记录对数据数据所做的所有改变(写入的信息包括尚未提交的事务处理、还原段信息以及方案和对象管理语句)
 •
提供一种恢复的机制
 •
被组织成组
 •
至少有两组(同一个组内的联机重做日志成员是相同的)


2
、下面的参数限制了联机重做日志文件的数量:
 • CREATE DATABASE
命令中的MAXLOGFILES 参数指定联机重做日志文件组的绝对最大数量(MAXLOGFILES 的最大值和缺省值取决于操作系统)
 • CREATE DATABASE
命令所使用的MAXLOGMEMBERS 参数决定每个组的成员的最大数量(MAXLOGMEMBERS 的最大值和缺省值取决于操作系统)


3
、检查点可发生在下面情况中:
 •
每次日志切换时
 •
当已通过正常、事务处理或者立即选项关闭例程时
 •
通过设置初始化参数FAST_START_MTTR_TARGET 强制执行时
 •
数据库管理员通过手动方式请求时
 • ALTER TABLESPACE [OFFLINE NORMAL|READ ONLY|BEGIN BACKUP]
命令导致对特定数据文件执行检查点操作时
 
如果初始化参数LOG_CHECKPOINTS_TO_ALERT 设置为TRUE,则有关每个检查点的信息都记录在alert_SID.log 文件内。该参数缺省值为FALSE,表示不记录检查点。


4
、强制日志切换:
 SQL> desc v$log;
  Name                                      Null?    Type
  ----------------------------------------- -------- ----------------------------
  GROUP#                                             NUMBER
  THREAD#                                            NUMBER
  SEQUENCE#                                          NUMBER
  BYTES                                              NUMBER
  MEMBERS                                            NUMBER
  ARCHIVED                                           VARCHAR2(3)
  STATUS                                             VARCHAR2(16)
  FIRST_CHANGE#                                      NUMBER
  FIRST_TIME                                         DATE

 SQL>

 SQL> select group#,thread#,sequence#,status from v$log;

  GROUP#    THREAD#  SEQUENCE# STATUS
 ---------- ---------- ---------- ----------------
          1          1          2 INACTIVE
          2          1          3 INACTIVE
          3          1          4 CURRENT

 SQL>

 SQL> alter system switch logfile;

 System altered.

 SQL>

 切换后:
 SQL> select group#,thread#,sequence#, status from v$log;

     GROUP#    THREAD#  SEQUENCE# STATUS
 ---------- ---------- ---------- ----------------
          1          1          5 CURRENT
          2          1          3 INACTIVE
          3          1          4 ACTIVE

 SQL>


 
强制检查点发生:
 SQL> alter system checkpoint;

 System altered.

 SQL>
 

5、增加联机重做日志组:
 
先查看组的情况:
 SQL> desc v$logfile;
  Name                                      Null?    Type
  ----------------------------------------- -------- ----------------------------
  GROUP#                                             NUMBER
  STATUS                                             VARCHAR2(7)
  TYPE                                               VARCHAR2(7)
  MEMBER                                             VARCHAR2(513)

 SQL>

 SQL> select * from v$logfile;

    GROUP# STATUS  TYPE    MEMBER
 ---------- ------- ------- ------------------------------
          3         ONLINE  /u01/oradata/denver/redo03.log
          2 STALE   ONLINE  /u01/oradata/denver/redo02.log
          1         ONLINE  /u01/oradata/denver/redo01.log

 SQL>
 
 
创建:
 SQL> alter database add logfile group 4
 2  ('/u01/oradata/denver/redo04.log') size 50M;

 Database altered.

 SQL>

 创建后:
 SQL> select * from v$logfile;

   GROUP# STATUS  TYPE    MEMBER
 ---------- ------- ------- ------------------------------
          3         ONLINE  /u01/oradata/denver/redo03.log
          2 STALE   ONLINE  /u01/oradata/denver/redo02.log
          1         ONLINE  /u01/oradata/denver/redo01.log
          4         ONLINE  /u01/oradata/denver/redo04.log

 SQL>
6
、增加联机重做日志组成员:

 SQL> alter database add logfile member
  2  '/u01/oradata/denver/redo04a.log' to group 4;

 Database altered.

 SQL>

 增加后:
 SQL> select * from v$logfile;

GROUP# STATUS  TYPE    MEMBER
 ---------- ------- ------- -----------------------------------
          3         ONLINE  /u01/oradata/denver/redo03.log
          2 STALE   ONLINE  /u01/oradata/denver/redo02.log
          1         ONLINE  /u01/oradata/denver/redo01.log
          4         ONLINE  /u01/oradata/denver/redo04.log
          4 INVALID ONLINE  /u01/oradata/denver/redo04a.log

 SQL>

7、删除日志成员:
 
删除前:
 SQL> select * from v$logfile;

 GROUP# STATUS  TYPE    MEMBER
 ---------- ------- ------- ------------------------------
   3         ONLINE  /u01/oradata/denver/redo03.log
   2 STALE   ONLINE  /u01/oradata/denver/redo02.log
   1 STALE   ONLINE  /u01/oradata/denver/redo01.log
   4         ONLINE  /u01/oradata/denver/redo04.log
   4         ONLINE  /u01/oradata/denver/redo04a.lo
                           g
 
 SQL>
 
 
删除:
 SQL> alter database drop logfile member '/u01/oradata/denver/redo04a.log';

 Database altered.
 
 SQL>
 
 
删除后:
 SQL> select * from v$logfile;
 
    GROUP# STATUS  TYPE    MEMBER
 ---------- ------- ------- ------------------------------
          3         ONLINE  /u01/oradata/denver/redo03.log
          2         ONLINE  /u01/oradata/denver/redo02.log
          1 STALE   ONLINE  /u01/oradata/denver/redo01.log
          4         ONLINE  /u01/oradata/denver/redo04.log

 SQL>

8、删除组
 
删除前:
 
 SQL> select group#,members,archived,status from v$log;
 
     GROUP#    MEMBERS ARC STATUS
 ---------- ---------- --- ----------------
          1          1 YES INACTIVE
          2          1 NO  CURRENT
          3          1 YES INACTIVE
          4          1 YES ACTIVE
 
 SQL>
 
 
删除
 alter database drop logfile group 4;
 
 
9
、清空redo:
 SQL> alter database clear logfile group 3;
 
10
、重命名、重分配日志文件(两种方法)
 
(1)、添加新成员,删除旧成员
 
(2)、ALTER  DATABASE  RENAME  FILE  command
          •shutdown the database
          •copy the database redo log files to the new location
          •place the database in MOUNT mode
          •execute the command
            Eg:
          
ALTER DATABASE RENAME FILE
               ‘$HOME/ORACLE/u01/log2a.rdo’
                 TO ‘$HOME/ORACLE/u02/log1c.rdo’;)
          •open database for operation

 

posted on 2011-03-09 11:44  草原和大树  阅读(360)  评论(0编辑  收藏  举报