1、Oracle 日志原理
史记讲解法
日志记录方式
2、实际日志产生过程
3、归档模式
alter database archivelog
ARCHIVE LOG LIST
SELECT log_mode FROM v$database
alter database noarchivelog
ALTER SYSTEM ARCHIVE LOG CURRENT
ALTER SYSTEM ARCHIVE LOG ALL
ALTER SYSTEM SET LOG_ARCHIVE_MAX_PROCESSES=3;
alter system set log_archive_dest = '/u01/app/oracle/archivelog1' scope =
spfile;
alter system set log_archive_duplex_dest = '/u01/app/oracle/archivelog2'
scope = spfile;
alter system set log_archive_dest_1 =
'LOCATION=/u01/app/oracle/archivelog3';
alter system set log_archive_dest_2 = 'SERVICE=standby1';
alter system set log_archive_format = 'arch_%t_%s_%r.arc';
col dest_name format a20;
col destination format a30;
select
dest_name,status,archiver,destination,log_sequence,reopen_secs,transmit_mode,pro
cess
from v$archive_dest;
select name,sequence#,registrar,standby_dest,archived,status from
v$archived_log;
v$archived_log -->从控制文件中获得归档的相关信息
v$archive_dest -->归档路径及状态
v$log_history -->控制文件中日志的历史信息
v$database -->查看数据库是否处于归档状态
v$archive_processes -->归档相关的后台进程信息
select * from v$logfile;
select member,bytes/1024/1024 from v$log a,v$logfile b
where a.group#=b.group#
select NAME,STATUS from v$archived_log;
4、如何确保已经提交的事务不会丢失
5、LGWR 绕过 OS 缓存直接写入磁盘,但是绕不过存储的写缓存
6、Log buffer 大小设置
9i 以前,一般是 3M
在 10g 中 ORACLE 会自动调整它的值,他遵循这样一个原则,'Fixed SGA Size'+ 'Redo
Buffers'是 granule size 的整数倍
select * from v$sgainfo where name in ('Fixed SGA Size','Redo
Buffers','Granule Size');
--在 10.2.0.3 中 Log Buffer 默认值是 14M,在 10.2.0.4 中,默认值是 15M
select * from v$version where rownum<2;
8、LGWR 触发条件:Write-Ahead-Log:日志写入优先
1.用户提交
2.有 1/3 重做日志缓冲区未被写入磁盘
3.有大于 1M 的重做日志缓冲区未被写入磁盘
4.每隔 3 秒钟
5.DBWR 需要写入的数据的 SCN 大于 LGWR 记录的 SCN,DBWR 触发 LGWR 写入
评论