ORACLE-基础五(online redo log)

来源:互联网 发布:单片机四路抢答器程序 编辑:程序博客网 时间:2024/05/02 12:11

Online Redo Log Files

Online Redo log files have the following characteristics:

Record all changes made to data

Provide a recovery mechanism

Can be organized into groups

At least two groups required



Online Redo Log File Groups

A set of identical copies of online redo log files is called an online redo log file group

The LGWR backgroundprocess concurrently writes the same information to call online redo log files in a group

The Oracle server needs a minimum of two online redo log file groups for the nomal operation of a database


Online Redo Log File Members

Each online redo log file in a group is called a member

Each member in a group has identical log sequence numbers and are of the same size.

The LSN(log sequence number ) is assigned each time that the Oracle server writes to a log group to uniquely identify each online redo log file




How Redo Files Work

Online Redo log files are used in a cyclic fashion

When a online redo log file is full , LGWR will move to the next log group

    Called a log swith

    Checkpoint operation also occurs

    Information wirtten to the control file

The act of switching from one log file group to the other is called a log swith . A checkpoint is the writing of dirty(modified ) blocks from the buffer cache to disk


When will LGWR write redo?

When a transaction commits

Every three seconds

When the Redo Log Buffer becomes one-third full

When there is more than a megabyte of changed records in the Redo Log Buffer.

Before the DBWn writes modified blocks in the Database Buffer Cache to the data files




Force Log Switches $CK

Forcing a log switch

ALTER SYSTEM SWITCH LOGFILE

Checkpoints can be forced by :

   FAST_START_MTTR_TARGET=600

   ALTER SYSTEM CHECKPOINT

(select group#, thread#,sequence#,status from v$log)







Dropping  Redo File Members

An instance always requires at least two vlid groups of redo log files, regardless of the number of members in the groups.(A group comprises one or more members ) If the member you eant to drop os the last valid member of the group ,you cann't drop the  member until the other members become valid. To see a redo log file status, use the v$LOGFILE view, A redo log file becomes INVALID if the database cannot access it .Itbecomes STALE if the databse suspects that it is not complete or correct. A tale log file becomes valid again the next time its group is made the active group.

you cn drop a redo log member only if it is not part of an active or current group. If you want to drop a member of an active group, first force a log switch to accur.

Make sure the group to which a redo log member belongs is archived (if archiving is enabled) before dropping the member. To see whether this has happed,use the V$LOG view


When a redo log member is dropped from the database, the operating system file is not deleted from disk.Rather, the control files of the associated database are updated to dorp the member from database structure.After dropping a redo log file, make sure that the dorp completed successfully, and then use the appropriate operating system command to delete the dropped redo log file.




Dropping Redo Files Groups

An active or current group cannot be dropped .

When an online redo log file group is dropped, the operating system files are not deleted

Alter DATABASE  DROP LOGFILEGROUP 3



Clear Redo Files

ALTER DATABASE CLEAR LOGFILE command can be used to reinitialize an onlie redo log file

ALTER DATABASE CLEAR LOGFILE GROUP 2

Use the UNARCHIVED keyword to avoid archiving the corrupted online redo log file

ALTER DATABASE CLEAR UNARCHIVED LOGFILE GROUP 2


if only one members in a Redo groups available , Oracle can continue Work.  

V$LOG                      Displays the redo log file information from the control file

V$LOGFILE               Identifies redo log groups and memebers and members status

V$LOG_HISTORY    Cantains log history information


Archived Redo Log files

Filled online redo log files can ben archived

there are two advantages in running the database in ARCHIVELOG mode and archiving online redo lgo files:

   Recovery: A database backup together with online and archived redo log files can guarantee recovery of all committed transactions

  Backup: This can the performed  while the database is open

By defualt, the database  is created in NOARCHIVELOG mod


can view through v$instance or v$database


Archived Redo Log Files

Accomplished automatically by ARCn

Accomplished manually through SQL statements

When successfully archived:

   An entry in the control file is made

   Records:archive log name, log sequence number, and high and low system change number (SCN)

Filedd online redo log files cannot be reused until:

  Acheckpoint has taken place

  File has been archived by ARCn

Can be multiplexed

Maintained by the DBA

ALTER DATABASE ADD LOGFILE GROUP 3 ('$HOME/ORDATA/u01/log3a.rdo','$HOME/ORDATA/u01/log3b.rdo') SIZE 1M;ALTER DATABASE ADD LOGFILE MEMBER '$HOME/ORDATA/u01/log1.rdo' TO GROUP 1, '$HOME/ORDATA/u01/log2.rdo' TO GROUP 2;ALTER DATABASE DROP LOGFILE MEMBER '$HOME/ORDATA/u01/log1.rdo';ALTER DATABASE DROP LOGFILEGROUP 3ALTER DATABASE RENAME FILE '$HOME/ORDATA/u01/log1.rdo' TO '$HOME/ORDATA/u01/log2.rdo'ALTER DATABASE CLEAR LOGFILE GROUP 2ALTER DATABASE CLEAR UNARCHIVED LOGFILE GROUP 2




0 0
原创粉丝点击