更改重做日志(redolog)文件的大小-凯发app官方网站

凯发app官方网站-凯发k8官网下载客户端中心 | | 凯发app官方网站-凯发k8官网下载客户端中心
  • 博客访问: 2090701
  • 博文数量: 195
  • 博客积分: 4378
  • 博客等级: 上校
  • 技术积分: 4046
  • 用 户 组: 普通用户
  • 注册时间: 2007-09-09 11:37
个人简介

白天和黑夜只交替没交换无法想像对方的世界

文章分类

全部博文(195)

文章存档

2014年(3)

2013年(20)

2012年(18)

2011年(107)

2010年(17)

2009年(5)

2008年(20)

2007年(5)

相关博文
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·
  • ·

分类: oracle

2010-07-01 14:37:09

更改重做日志(redolog)文件的大小
 

从原来每个100m更改成1m

sql> show user;
user is "sys"
sql> select group#,status from v$log;

    group# status
---------- ----------------
         1 current
         2 inactive
         3 inactive

sql> alter database add logfile group 4 ('d:\oracle\oradata\practice\redo04.log'
) size 100m;

database altered.

sql> alter database add logfile group 5 ('d:\oracle\oradata\practice\redo05.log'
) size 100m;

database altered.

sql> alter system switch logfile;

system altered.

sql> alter system switch logfile;

system altered.

sql> select group#,status from v$log;

    group# status
---------- ----------------
         1 inactive
         2 inactive
         3 inactive
         4 inactive
         5 current

sql> alter database drop logfile group 1;

database altered.

sql> alter database drop logfile group 2;

database altered.

sql> alter database drop logfile group 3;

database altered.

sql> alter database add logfile group 1 ('d:\oracle\oradata\practice\redo01.log'
) size 1m;
alter database add logfile group 1 ('d:\oracle\oradata\practice\redo01.log') siz
e 1m
*
error at line 1:
ora-00301: error in adding log file 'd:\oracle\oradata\practice\redo01.log' -
file cannot be created
ora-27038: skgfrcre: file exists
osd-04010: option specified, file already exists

注意:每一步删除drop操作,都需要手工删除os中的实体文件。如上错误是因为忘了手工删除原来的redo01.log


sql> select group#,status from v$log;

    group# status
---------- ----------------
         4 inactive
         5 current

sql> alter database add logfile group 1 ('d:\oracle\oradata\practice\redo01.log'
) size 1m;

database altered.

sql> alter database add logfile group 2 ('d:\oracle\oradata\practice\redo02.log'
) size 1m;

database altered.

sql> alter database add logfile group 3 ('d:\oracle\oradata\practice\redo03.log'
) size 1m;

database altered.

sql> select group#,status from v$log;

    group# status
---------- ----------------
         1 unused
         2 unused
         3 unused
         4 inactive
         5 current

sql> alter system switch logfile;

system altered.

sql> alter system switch logfile;

system altered.

sql> select group#,status from v$log;

    group# status
---------- ----------------
         1 inactive
         2 current
         3 unused
         4 inactive
         5 inactive

sql> alter system switch logfile;

system altered.

sql> select group#,status from v$log;

    group# status
---------- ----------------
         1 inactive
         2 inactive
         3 current
         4 inactive
         5 inactive

sql> alter database drop logfile group 4;

database altered.

sql> alter database drop logfile group 5;

database altered.

sql> select group#,status,bytes from v$log;

    group# status                bytes
---------- ---------------- ----------
         1 inactive            1048576
         2 inactive            1048576
         3 current            1048576

===========================参考================================

假设现有三个日志组,每个组内有一个成员,每个成员的大小为1mb,现在想把此三个日志组的成员大小都改为10mb

1、创建2个新的日志组
alter database add logfile group 4 ('d:\oracle\oradata\oradb\redo04_1.log') size 1024k;
alter database add logfile group 5 ('d:\oracle\oradata\oradb\redo05_1.log') size 1024k;

2、切换当前日志到新的日志组
alter system switch logfile;
alter system switch logfile;

3、删除旧的日志组
alter database drop logfile group 1;
alter database drop logfile group 2;
alter database drop logfile group 3;

4、操作系统下删除原日志组1、2、3中的文件

5、重建日志组1、2、3
alter database add logfile group 1 ('d:\oracle\oradata\oradb\redo01_1.log') size 10m;
alter database add logfile group 2 ('d:\oracle\oradata\oradb\redo02_1.log') size 10m;
alter database add logfile group 3 ('d:\oracle\oradata\oradb\redo03_1.log') size 10m;

6、切换日志组
alter system switch logfile;
alter system switch logfile;
alter system switch logfile;

7、删除中间过渡用的日志组4、5
alter database drop logfile group 4;
alter database drop logfile group 5;

8、到操作系统下删除原日志组4、5中的文件

9、备份当前的最新的控制文件
sql>; connect internal
sql>; alter database backup controlfile to trace resetlogs

(注意:如果为安全考虑每个group可以多加几个文件)

==============================

跟redo logfile有关的其它数据库参数    
    
    1、log_buffer
    
       log_buffer是oracle sga的一部分, 所有dml命令修改的数据块先放在log_buffer里, 如果满了或者到了check_point时候通过lgwr后台进程写到redo logfile里去。它不能设得太大,这样在意外发生时会丢失很多改变过的数据。它最好不要大于512k或者128k*cpu个数。
       
       我们可以用下面的sql语句检测log_buffer使用情况:
       
svrmgrl>; select rbar.name,rbar.value,re.name,re.value,(rbar.value*100)/re.value||'%' "radio"
from v$sysstat rbar,v$sysstat re
where rbar.name='redo buffer allocation retries'
and re.name='redo entries';

       这个比率小于1%才好,否则增加log_buffer的大小
       
    2、log_checkpoint_interval

       oracle8.1 版本后log_checkpoint_interval指的是两次checkpoint之间操作系统数据块的个数。
       
       checkpoint时oracle把内存里修改过的数据块用dbwr写到物理文件,用lgwr写到日志和控制文件。
              
       一般unix操作系统的数据块为 512 bytes。
       
       从性能优化来说 log_checkpoint_interval = redo logfile size bytes / 512 bytes
        
       
    3、log_checkpoint_timeout
    
     oracle8.1 版本后log_checkpoint_timeout指的是两次checkpoint之间时间秒数。
     oracle建议不用这个参数来控制,因为事务(transaction)大小不是按时间等量分布的。
log_checkpoint_timeout = 0
log_checkpoint_timeout = 900

========================================

how redo log files work
the oracle server sequentially records all changes made to the database in the redo log buffer. the redo entries are written from the redo log buffer to one of the online redo log file groups called the current online redo log file group by the lgwr process. lgwr writes under the following situations:
    when a transaction commits
    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 datafiles
redo log files are used in a cyclic fashion. each redo log file group is identified by a log sequence number that is overwritten each time the log is reused.
log switches:
lgwr writes to the online redo log files sequentially. when the current online redo log file group is filled, lgwr begins writing to the next group. this is called a log switch.
when the last available online redo log file is filled, lgwr returns to the first online redo log file group and starts writing again.

checkpoints:
during a checkpoint:
dbwn writes a number of dirty database buffers, that are covered by the log that is being checkpointed, to the datafiles. the number of buffers that dbwn writes is determined by the fast_start_mttr_target parameter, if specified. the default is zero.
note: the fast_start_mttr_target parameter is covered in detail in the oracle9i database administration fundamentals ii course.
the checkpoint background process ckpt updates the control file to reflect that it has completed a checkpoint successfully. if the checkpoint is caused by a log switch, ckpt also updates the headers of the datafiles.
checkpoints can occur for all datafiles in the database or only for specific datafiles.
a checkpoint occurs, for example, in the following situations:
    at every log switch
    when an instance has been shut down with the normal, transactional, or immediate option
    when forced by setting the initialization parameter fast_start_mttr_target
    when manually requested by the database administrator
    when the alter tablespace [offline normal|read only|begin backup]command causes checkpointing on specific datafiles
information about each checkpoint is recorded in the alert_sid.log file if the log_checkpoints_to_alert initialization parameter is set to true. the default value of false for this parameter does not log checkpoints.


redo log buffer
redo log buffer 可以循环使用,存放数据库改变牵涉的信息,其内部放的是redo entry。
redo entry存放的是insert, update, delete, create, alter, drop 等操作对数据库的改变信息,这些信息在recovery的时候是很重要。这些redo entry 由oracle server进程从用户内存放到redo buffer。


lgwr(log writer)
lgwr(log writer)是oracle启动时候必须启动的进程,它负责把redo log buffer中的redo entry写到redo log文件中。
在如下情况下写文件:
- redo log buffer 三分之一满了
- 达到某时间点
- 在 dbwr w把修改的数据块写到数据文件之前写redo log file
- 事务 commit的时候
- 在数据库做归档redo log 文件的时候

redo log file
redo log就是存放redo log 信息的文件了,至少有两个redo log 组,oracle循环使用之。当然推荐又更多的redo log 组。既然是循环使用redo log,必然会有一个log switch的过程。

log switch发生在:
- log file 已经写满了
- 使用了alter system switch logfile 命令

在log switch 的时候自动会做checkpoint。

只要redo log组里面有一个redo log file可以用,就能进行log switch。当然如果redo log file坏了,lgwr肯定会记录到 trace和alert文件.

关于redo log的设置
一般至少两组redo log 文件,
每组中的redo log文件最好在不同的磁盘上,防止一起损坏。
每组中的redo log文件必须大小一致,它们是同时修改的。
不同组的redo log文件大小不一定一致。
每组的redo log文件数目必须一致。


修改redo log的位置
- 看看当前的redo log文件是不是正在使用,如果在使用如下命令
alter system switch log file;
- 把该文件copy到你想要放到位置
- alter database rename file ’filename’ to filename’

增加redo log 文件
alter database [database]
add logfile member
[ ’filename’ [reuse]
[, ’filename’ [reuse]]...
to {group integer
|(’filename’[, ’filename’]...)
}

删除redo log 文件
如果redo log 文件是invalid状态,可以删除之
alter database [database] drop logfile member ’filename’[, ’filename’]...

相关数据字典
察看
v$log
v$logfile
v$log_history

阅读(5671) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~
")); function link(t){ var href= $(t).attr('href'); href ="?url=" encodeuricomponent(location.href); $(t).attr('href',href); //setcookie("returnouturl", location.href, 60, "/"); }
网站地图