在Exadata上,数据库节点跟db节点是通过libcell11.a并缺省使用RDS协议来进行通信的,我们跟踪下看看:
这里我跟踪Exadata的DB节点的ora_dbw0_lunar1进程:
[root@dm01db01 ~]# ps -ef|grep lunar|grep dbw oracle 11771 1 0 2013 ? 00:48:17 ora_dbw0_lunar1 oracle 11773 1 0 2013 ? 00:43:17 ora_dbw1_lunar1 oracle 11775 1 0 2013 ? 00:44:06 ora_dbw2_lunar1 oracle 11777 1 0 2013 ? 00:43:33 ora_dbw3_lunar1 [root@dm01db01 ~]# [root@dm01db01 ~]# strace -c -p 11771 Process 11771 attached - interrupt to quit ^CProcess 11771 detached % time seconds usecs/call calls errors syscall ------ ----------- ----------- --------- --------- ---------------- 100.00 0.000031 0 821 13 recvmsg ---------通过socket读取信息 0.00 0.000000 0 18 poll 0.00 0.000000 0 204 sendmsg ---------通过socket发送信息 0.00 0.000000 0 404 202 setsockopt 0.00 0.000000 0 10 getrusage 0.00 0.000000 0 31 times 0.00 0.000000 0 5 5 semtimedop ------ ----------- ----------- --------- --------- ---------------- 100.00 0.000031 1493 220 total [root@dm01db01 ~]#
这里我们看到主要的IO操作都是recvmsg和sendmsg等等,我们看一下,在Linux环境下的11.2.0.3的libcell11.a中含有哪些目标文件(即 .o 文件,object file)
[root@dm01db01 lib]# ar tv libcell11.a rw-rw-r-- 94110/42424 37504 Sep 17 22:27 2011 ossdisk.o rw-rw-r-- 94110/42424 7928 Sep 17 22:27 2011 osshdl.o rw-rw-r-- 94110/42424 73240 Sep 17 22:27 2011 osslib.o rw-rw-r-- 94110/42424 4512 Sep 17 22:27 2011 ossmem.o rw-rw-r-- 94110/42424 210352 Sep 17 22:27 2011 ossnet.o rw-rw-r-- 94110/42424 15392 Sep 17 22:27 2011 ossutl.o rw-rw-r-- 94110/42424 27480 Sep 17 22:27 2011 ossdebug.o rw-rw-r-- 94110/42424 27152 Sep 17 22:27 2011 ossdscv.o rw-rw-r-- 94110/42424 5424 Sep 17 22:27 2011 osssec.o rw-rw-r-- 94110/42424 6936 Sep 17 22:27 2011 osssec_lib.o rw-rw-r-- 94110/42424 21264 Sep 17 22:27 2011 osscdscv.o rw-rw-r-- 94110/42424 44152 Sep 17 22:27 2011 osserr.o rw-rw-r-- 94110/42424 9216 Sep 17 22:27 2011 osscap.o rw-rw-r-- 94110/42424 21696 Sep 17 22:31 2011 sosscom.o ------Linux上特有的,AIX没有 rw-rw-r-- 94110/42424 20752 Sep 17 22:31 2011 osshugetlb.o ------Linux上特有的,AIX没有 rw-rw-r-- 94110/42424 6352 Sep 17 22:31 2011 sipmiops.o ------Linux上特有的,AIX没有 rw-rw-r-- 94110/42424 97072 Sep 17 22:27 2011 ossconf.o rw-rw-r-- 94110/42424 18008 Sep 17 22:28 2011 sosstcp.o rw-rw-r-- 94110/42424 9520 Sep 17 22:32 2011 osscapcom.o rw-rw-r-- 94110/42424 5944 Sep 17 22:42 2011 osscomdg.o ------Linux上特有的,AIX没有 rw-rw-r-- 94110/42424 3576 Sep 17 22:31 2011 ossrmcvers.o ------Linux上特有的,AIX没有 rw-rw-r-- 94110/42424 10656 Sep 17 23:44 2011 oss_buildversion.o ------Linux上特有的,AIX没有 rw-rw-r-- 94110/42424 15896 Sep 17 22:42 2011 ossfilcs.o rw-rw-r-- 94110/42424 9280 Sep 17 22:42 2011 ossdbcom.o [root@dm01db01 lib]#
那么这里recvmsg和sendmsg函数来自libskgxp11.so,关于libskgxp11.so的由来这里不赘述了,大致的介绍请参见:
在Exadata上,为什么 DUL 和 ODU不能读取ASM数据库的数据,但是Kfed却可以?
我们看到,oracle主要是通过这个libcell11.so函数来跟cell通信,并通过libskgxp11.so在本地调用socket:
[root@dm01db01 lib]# nm -D /u01/app/11.2.0.3/grid/lib/libcell11.so|grep socket
U socket [root@dm01db01 lib]# [root@dm01db01 lib]# nm -D /u01/app/11.2.0.3/grid/lib/libskgxp11.so|grep msg U __cmsg_nxthdr 00000000000b3f60 T lwipc_rcvmsg 00000000000b4f66 T lwipc_rcvmsg_e 00000000000b402c T lwipc_sendmsg U recvmsg U sendmsg [root@dm01db01 lib]# [root@dm01db01 lib]# nm -D /u01/app/11.2.0.3/grid/lib/libskgxp11.so|grep poll U poll [root@dm01db01 lib]# [root@dm01db01 network-config]# nm -D /u01/app/11.2.0.3/grid/lib/libcell11.so|grep cell 000000000001e7da T oss_cell_discovery_close 000000000001e88a T oss_cell_discovery_fetch 000000000001e944 T oss_cell_discovery_open 000000000001ce2c T oss_cellconfig_close 000000000001ce5a T oss_cellconfig_get_next_cell 000000000001cfb4 T oss_cellconfig_open 000000000001d680 T oss_cellipora_getvalue 000000000001ed62 T oss_fd_to_cellsrvpid 000000000001cc26 T oss_monitor_cell -------监控来自cell的请求 000000000001c2f0 T oss_reconnect_cell -------跟cell建立连接通道 000000000001cd6e T oss_report_when_cell_alive 000000000001cb9e T oss_unmonitor_cell 00000000000454b2 T reserve_hugepages_for_cellsrv [root@dm01db01 network-config]#
那么在传统的Oracle数据库环境下,DBWR是怎么工作的的?
这里我们通过一个AIX环境举例说明。
首先,我们跟踪一下ora_dbw0_test570和ora_dbw1_test570进程:
AIX Version 5 Copyright IBM Corporation, 1982, 2010. login: root root's Password: ******************************************************************************* * * * * * Welcome to AIX Version 5.3! * * * * * * Please see the README file in /usr/lpp/bos for information pertinent to * * this release of the AIX Operating System. * * * * * ******************************************************************************* # ps -ef|grep pmon oracle 114904 1 0 Feb 07 - 6:05 ora_pmon_test570 root 835912 499932 0 15:12:54 pts/0 0:00 grep pmon # ps -ef|grep test|grep dbw oracle 156396 1 0 Feb 07 - 1:47 ora_dbw1_test570 oracle 41840 1 0 Feb 07 - 1:47 ora_dbw0_test570 # # truss -cf -p 41840 ^CPstatus: process is not stopped syscall seconds calls errors thread_wait 11.82 4 times .00 8 ---- --- --- sys totals: .00 12 0 usr time: .00 elapsed: .00 #
这里看到ora_dbw0_test570进程空闲,因此,再开辟一个会话,制造一些测试数据,比如,我这里创建了一个表:
—session 2
# su - oracle $ sqlplus / as sysdba SQL*Plus: Release 11.2.0.2.0 Production on Mon Mar 3 15:15:37 2014 Copyright (c) 1982, 2010, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> create table test as select * from dba_objects; Table created. SQL> alter system switch logfile; System altered. SQL>
跟踪一下ora_dbw1_test570进程:
# truss -cf -p 156396 ^CPstatus: process is not stopped syscall seconds calls errors thread_wait 12.19 25 times .00 48 close .00 1 kread .00 1 ----读取操作 open .00 1 listio64 .00 4 aio_nwait_timeout64 .00 4 ---AIO ---- --- sys totals: .00 84 0 usr time: .00 elapsed: .00 #
我们发现,在AIX上的IO操作是通过传统的kread等完成的。
下面我再看看传统的linux环境下,这是一个ASM数据库,是Exadata的ADG,我们跟踪一下ora_dbw0_lunar进程:
[root@oradg ~]# uname -a Linux oradg 2.6.18-238.el5xen #1 SMP Sun Dec 19 14:42:02 EST 2010 x86_64 x86_64 x86_64 GNU/Linux [root@oradg ~]# ps -ef|grep pmon root 1396 1221 0 16:28 pts/1 00:00:00 grep pmon oracle 11320 1 0 2013 ? 00:00:01 asm_pmon_+ASM oracle 21475 1 0 2013 ? 00:00:08 ora_pmon_lunar [root@oradg ~]# ps -ef|grep lunar|grep dbw oracle 21493 1 25 2013 ? 43-11:00:27 ora_dbw0_lunar [root@oradg ~]# [root@oradg ~]# strace -c -p 21493 Process 21493 attached - interrupt to quit Process 21493 detached % time seconds usecs/call calls errors syscall ------ ----------- ----------- --------- --------- ---------------- 68.92 0.059212 2 28790 pwrite -------写入 27.07 0.023259 0 855188 gettimeofday 4.01 0.003447 0 278515 times 0.00 0.000000 0 1 read -----读取 0.00 0.000000 0 1 open 0.00 0.000000 0 1 close 0.00 0.000000 0 16 semctl 0.00 0.000000 0 80 getrusage 0.00 0.000000 0 1 semtimedop ------ ----------- ----------- --------- --------- ---------------- 100.00 0.085918 1162593 total [root@oradg ~]#
我们发现,非Exadata的Linux环境上,IO操作是通过传统的read和pwrite等完成的。
最后,我们记录一下AIX环境下libcell11.a包含了哪些目标文件:
******************************************************************************* * * * * * Welcome to AIX Version 5.3! * * * * * * Please see the README file in /usr/lpp/bos for information pertinent to * * this release of the AIX Operating System. * * * * * ******************************************************************************* # su - oracle $ cd $ORACLE_HOME $ cd lib $ ar -X32_64 -t -v libcell11.a rw-rw-r-- 94110/42424 34613 Oct 7 18:01 2010 ossdisk.o rw-rw-r-- 94110/42424 8654 Oct 7 18:01 2010 osshdl.o rw-rw-r-- 94110/42424 67755 Oct 7 18:01 2010 osslib.o rw-rw-r-- 94110/42424 5055 Oct 7 18:01 2010 ossmem.o rw-rw-r-- 94110/42424 147638 Oct 7 18:02 2010 ossnet.o rw-rw-r-- 94110/42424 15127 Oct 7 18:02 2010 ossutl.o rw-rw-r-- 94110/42424 25030 Oct 7 18:02 2010 ossdebug.o rw-rw-r-- 94110/42424 23666 Oct 7 18:02 2010 ossdscv.o rw-rw-r-- 94110/42424 5227 Oct 7 18:02 2010 osssec.o rw-rw-r-- 94110/42424 6131 Oct 7 18:02 2010 osssec_lib.o rw-rw-r-- 94110/42424 16155 Oct 7 18:02 2010 osscdscv.o rw-rw-r-- 94110/42424 15992 Oct 7 18:02 2010 osserr.o rw-rw-r-- 94110/42424 7950 Oct 7 18:02 2010 osscap.o rw-rw-r-- 94110/42424 12028 Oct 7 18:03 2010 ossfilcs.o rw-rw-r-- 94110/42424 7643 Oct 7 18:03 2010 ossdbcom.o rw-rw-r-- 94110/42424 10507 Oct 7 18:03 2010 sosstcp.o rw-rw-r-- 94110/42424 68422 Oct 7 18:03 2010 ossconf.o rw-rw-r-- 94110/42424 11514 Oct 7 18:03 2010 osscapcom.o $