我们试一下用strace窥视一下LGWR的行为。
首先找出LGWR的进程号:
1
[oracle@www.linuxidc.com ~]$ ps -ef | grep $ORACLE_SID | grep lgwr
2
oracle 5140 1 0 Nov09 ? 00:00:12 ora_lgwr_mydb
在一个终端中执行命令,我们比较关心LGWR对文件的打开操作:
1
[oracle@www.linuxidc.com ~]$ strace -p 5140 2>&1 | grep -i open
在sqlplus中执行以下语句,用于添加一组新的online redo log:
1
ALTER DATABASE ADD LOGFILE ('/u02/oradata/mydb/redolog/group04/redo05a.log',
2
'/u02/oradata/mydb/redolog/group04/redo05b.log')
3
SIZE 50m;
然后多次切换logfile:
1
alter system switch logfile;
2
alter system switch logfile;
3
alter system switch logfile;
4
alter system switch logfile;
5
alter system switch logfile;
6
alter system switch logfile;
此时 strace 这边就有输出了:
01
open("/u02/oradata/mydb/redolog/group04/redo05a.log", O_RDONLY) = 60
02
open("/u02/oradata/mydb/redolog/group04/redo05a.log", O_RDWR|O_SYNC) = 60
03
open("/u02/oradata/mydb/redolog/group04/redo05b.log", O_RDONLY) = 61
04
open("/u02/oradata/mydb/redolog/group04/redo05b.log", O_RDWR|O_SYNC) = 61
05
open("/proc/5164/stat", O_RDONLY) = 62
06
open("/u01/app/admin/mydb/bdump/alert_mydb.log", O_WRONLY|O_CREAT|O_APPEND, 0664) = 8
07
open("/u01/app/admin/mydb/bdump/alert_mydb.log", O_WRONLY|O_CREAT|O_APPEND, 0664) = 8
08
open("/u01/app/admin/mydb/bdump/alert_mydb.log", O_WRONLY|O_CREAT|O_APPEND, 0664) = 8
09
.......
10
.......
11
.......
我们可以看到LGWR对新的一组redo进行了打开操作,后面是一堆对 alert文件的打开并写入操作,可以看到LGWR对online redo log的open操作采用 O_SYNC 标志,从google中得知,该标志用于绕过文件系统的缓存。
我们可以再看看文件系统的缓存的巨大作用,用dd命令来模拟一下:
01
[ora11g@FWDB ~]$ time dd if=/dev/zero of=/tmp/bigfile.bin bs=1048576 count=2048 ; time sync ;
02
2048+0 records in
03
2048+0 records out
04
2147483648 bytes (2.1 GB) copied, 11.7151 seconds, 183 MB/s
05
06
real 0m11.763s
07
user 0m0.002s
08
sys 0m5.189s
09
10
real 0m9.671s
11
user 0m0.000s
12
sys 0m0.561s
13
14
15
[ora11g@FWDB ~]$ time dd if=/dev/zero of=/tmp/bigfile.bin bs=1048576 count=2048 oflag=sync; time sync ;
16
2048+0 records in
17
2048+0 records out
18
2147483648 bytes (2.1 GB) copied, 17.3505 seconds, 124 MB/s
19
20
real 0m17.900s
21
user 0m0.002s
22
sys 0m6.546s
23
24
real 0m0.150s
25
user 0m0.000s
26
sys 0m0.003s
可以看到文件系统的缓存表面上大大增加了吞吐能力,但是如果一旦断电就有可能产生数据丢失的情况。
if ($ != jQuery) { $ = jQuery.noConflict(); } var isLogined = false; var cb_blogId = 21523; var cb_entryId = 1878735; var cb_blogApp = "killkill"; var cb_blogUserGuid = "5560360b-63cf-dd11-9e4d-001cf0cd104b"; var cb_entryCreatedDate = '2010/11/16 17:12:00';