Explain the purpose of online redo log files
Record all changes made to data
Provide a recovery mechanism
at least two groups required
online redo log file group :   identical copies of online redo log files
LGWR will the same information in one online redo log files group.
each online redo log files in a group is called a memeber
each member in a group has identical log sequence number(LSN) and  are of the same size
LSN 是按组递增的,比如第一组是1,第二组是2,再写第一组的时候就成了3.....

Outline the structure of online redo log files


control log switches and checkpoints
The act of switching from one log file group to the other is called a log switch(LS).
A checkpoint is the writing of dirty blocks from the buffer cache to disk.(DBWn)
Log switch 就会引发checkpoint, 同时也会通知CKPT 进程将信息写到control file中

When will LGWR write redo?
- when a transaction commits (当commit的时候,并非将数据写到数据文件中去,而是将数据字入redo log file)
- Every three seconds
- When the redo log buffer becomes on-third full
- when there is more than a megabyte of changed records in the redo log buffer
- befor the DBWn wirtes modified blocks in the db buffer cache to the data file (means: checkpoint 发生时写redo log file)

---------------------------------------
#swich log files manually
desc v$log;
select group#, thread#, sequence#, status from v$log;
-current: 当前正在写的组
-inactive: 当前组可以被复盖状态,也就是说已经发生了checkpoint.
-active: 还未发生checkpoint.
alter system switch logfile;
---------------------------------------

---------------------------------------
# checkpoints can be forced
- when log switch
-FAST_START_MTTR_FARGET = 600 (10分钟发生一次checkpoint, 这一个参数重要影响性能)
-Alter system checkpoint;
---------------------------------------


multiplex and maintain online redo log files
---------------------------------------
#adding redo files groups
desc v$logfile;
select * from v$logfile;
alter database add logfile group 3
('$home/oradata/u01/redo3a.rdo' , '$home/oradata/u01/redo3b.rdo' ) size 100M;
---------------------------------------

---------------------------------------
#adding  redo file members
alter database add logfile member
'$home/oradata/u01/redo1c.rdo' to group 1,
'$home/oradata/u01/redo2c.rdo' to group 2,
'$home/oradata/u01/redo3c.rdo' to group 3;
#一个组内的多个member大小相同。
---------------------------------------

---------------------------------------
# dropping redo file members
desc v$logfile;
select * from v$logfile;
#如果一个组里只有一个status 为valid 的成员,那我们是不能将其删除的。
#删除后只是在control file 里标识已经删除,物理文件没有被删除,我们可以用操作系统命令将其删除。
alter database drop logfile member '$home/oradata/u01/redo2c.rdo'
---------------------------------------

---------------------------------------
# dropping redo file group
# active 状态group 不能被删除
# 同样并非在物理上实际删除那个文件,需用rm 命令删除。
alter database drop logfile group 2;
---------------------------------------


---------------------------------------
# relocate and rename redo log file
# 在改之前记得对数据库进行全备
select * from v$logfile;
shutdown  immediate
cd /u01/oradata/wilson/
ls al
cp redo04.log ..
cd ..
mv redo04.log redo04.rdo
startup mount;
alter database rename file '/u01/oradata/wilson/redo04.log' to '/u01/oradata/redo04.rdo
alter database open;
select * from v$logfile;
# 方法二中,新增一个,再把老的那个删除。
---------------------------------------

---------------------------------------
#clear redo files
#如果redo file中的数据坏掉了,它就写不进去了,我们得手动进行清空。这个步骤会使数据丢失。
alter database clear logfile group 2;
or alter database clear unarchived logfile group 2;
---------------------------------------

---------------------------------------
# redo file configuration
# 在OLTP系统中,如果系统负荷大,group 比较就多些。在OLAP 中,因为只有select 很少有delete update,所以不会写redo log file,我们可以只设置两个。
# 每个组中尽量至少有两个member , 比如只有两个member 的情况下,把这两个成员放在不同的disk 上,减少io 和disk falsure 危险。
# 我们也应该把redo log file 和 archive file 放在别外的磁盘上,也减少io .
# 数据文件也应该跟redo log file 放在不同的地方。

---------------------------------------

manage online redo log files with OMF
....

obtain online redo log files information
v$log
v$logfile
v$log_history
#表中有一个字段THREAD表示在实例操作log file 的线程,如果是两个instance 的rac 环境下,则应该有两个thread.

#查看数据库是否处于archive 归档模式
---------------------------------------
method 1.
desc v$instance;
select archiver form v$instance

method 2.
desc v$database;
select log_mode from v$database;
---------------------------------------

# 如果在archive 模式下,只有当checkpoint 条件发生和被archive 了才能使得log file 被复写。

#Online redo log files and datafile 千万不能丢

posted on 2008-07-03 13:36  Alex.Zhang  阅读(318)  评论(0编辑  收藏  举报