Bo's Oracle Station

查看: 6524|回复: 10

请教关于异步IO的问题

[复制链接]

81

主题

181

帖子

781

积分

高级会员

Rank: 4

积分
781
发表于 2017-1-23 10:22:52 | 显示全部楼层 |阅读模式
唐老师:
    下面这种情况kiocb  0      0是不是以为这异步IO没有启用?
[root@DB ~]# cat /proc/slabinfo | grep kio
kioctx               148    290    384   10    1 : tunables   54   27    8 : slabdata     29     29      0
kiocb                  0      0    256   15    1 : tunables  120   60    8 : slabdata      0      0      0

环境是ASM的,我核对了下面2个参数:disk_asynch_io ,filesystemio_options
SQL> set linesize 1000

SQL> show parameter disk_async
NAME                                 TYPE                             VALUE
------------------------------------ -------------------------------- ------------------------------
disk_asynch_io                       boolean                          TRUE

SQL> show parameter filesystem
NAME                                 TYPE                             VALUE
------------------------------------ -------------------------------- ------------------------------
filesystemio_options                 string                           none

这2个参数的结果跟上课推送的环境是一样的,但是我在上课推送的环境上看看,是有异步IO的,我不明白为什么会有这样的差异?
[root@station79 ~]# cat /proc/slabinfo | grep kio
kioctx               113    180    192   20    1 : tunables  120   60    8 : slabdata      9      9      0
kiocb                  6     30    128   30    1 : tunables  120   60    8 : slabdata      1      1      0

filesystemio_options 参数在OCP考试里面出现过,记得在ASM环境下,这个参数是可以为NONE的,该参数用户文件系统下的数据库。linux下建议值为:SETALL
disk_asynch_io  参数是默认值 true

唐sir,我不明白课堂推送的环境跟我自己搭建的环境差异在哪里?同样ASM,我自己搭建的好几个环境回头去检查,都没有异步IO。
由此产生另外一问,在生产环境中,如果是文件系统的,是不是应该无条件启用异步io(filesystemio_options=SETALL)

回复

使用道具 举报

1005

主题

1469

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
12012
发表于 2017-1-23 15:37:34 | 显示全部楼层
本帖最后由 botang 于 2017-1-23 15:56 编辑

SETALL 使得 DIRECT IO 或 ASYCNH IO 都成为可能,所以你看过得所有资料都推荐SETALL。这个对LINUX文件系统的库有效。
而ASM的库,由于类似raw设备IO机制,与以上没有任何关系。MOS上的237299.1, 272520.1, 169706.1, 233659.1, 164768.1, 282036.1, 1050577.6, 1030522.6, 1038968.6都提到以上内容。

第一个问题,可能是你搭建的环境缺libaio和libaio-devel包。
检查下:

ldd $ORACLE_HOME/bin/oracle | grep libaio
有这个吗?
libaio.so.1 => /lib64/libaio.so.1 (0x00000037e3400000)

nm $ORACLE_HOME/bin/oracle | grep io_getevent
有这个吗?
w io_getevents@@LIBAIO_0.4

sysctl -A | grep aio
有这些吗?
fs.aio-pinned = 0
fs.aio-max-pinned = 73720
fs.aio-max-size = 131072
fs.aio-max-nr = 65536
fs.aio-nr = 0

还有就是使用RHEL(OEL)的核,在11g时不要使用uek的核。
回复 支持 反对

使用道具 举报

81

主题

181

帖子

781

积分

高级会员

Rank: 4

积分
781
 楼主| 发表于 2017-1-24 10:03:00 | 显示全部楼层
本帖最后由 lujiaguai 于 2017-1-24 14:29 编辑

我的情况是这样的:
[oracle@TEST ~]$ ldd $ORACLE_HOME/bin/oracle | grep libaio
        libaio.so.1 => /lib64/libaio.so.1 (0x0000003d5bc00000)


[oracle@TEST ~]$ nm $ORACLE_HOME/bin/oracle | grep io_getevent
                 w io_getevents@@LIBAIO_0.4

[root@TEST ~]# sysctl -A | grep aio
fs.aio-max-nr = 1048576
fs.aio-nr = 19200

前两项在唐SIR教导下不可能犯依赖包没有装的低级错误
最后这一项sysctl -A | grep aio结果2行,我比对过课堂环境,也是这2行,看上去是一样的,并没有问题。
只是fs.aio-nr 的值偏低了,推出来环境是30273,我的是19200,但唐老师回帖是0。。。。
其他3行无论是我自己装的,还是课堂推出来的,都是没有的
下面是课堂推出来环境的值:
[root@station79 ~]# sysctl -A | grep aio
fs.aio-max-nr = 1048576
fs.aio-nr = 30273

UEK核的问题还真的没有注意,我今天换一个不是oel的装一个试试,用centos看看,有结果再来反馈
-------------------------
oel的内核如下,这里看不到异步IO
[root@TEST ~]# uname -a
Linux TEST 3.8.13-16.2.1.el6uek.x86_64 #1 SMP Thu Nov 7 17:01:44 PST 2013 x86_64 x86_64 x86_64 GNU/Linux

上课推送出来的环境内核如下,看得到异步IO
[oracle@station79 ~]$ uname -a
Linux station79.example.com 2.6.18-238.el5PAE #1 SMP Sun Dec 19 14:42:44 EST 2010 i686 i686 i386 GNU/Linux

今天刚装的centos6.6环境,也看不到异步IO
[root@test ~]# uname -a
Linux test 2.6.32-504.el6.x86_64 #1 SMP Wed Oct 15 04:27:16 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux

我不明白,为什么我装出来的都是看不到异步IO的。。。。
下面是新装的环境结果,刷新的同时在select  *  from sh.customers
[root@test ~]# cat /proc/slabinfo | grep kio
kioctx                77    110    384   10    1 : tunables   54   27    8 : slabdata     11     11      0
kiocb                  0      0    256   15    1 : tunables  120   60    8 : slabdata      0      0      0
[root@test ~]# cat /proc/slabinfo | grep kio
kioctx                90    110    384   10    1 : tunables   54   27    8 : slabdata     11     11      0
kiocb                  0      0    256   15    1 : tunables  120   60    8 : slabdata      0      0      0
[root@test ~]# cat /proc/slabinfo | grep kio
kioctx                79    110    384   10    1 : tunables   54   27    8 : slabdata     11     11      0
kiocb                  0      0    256   15    1 : tunables  120   60    8 : slabdata      0      0      0
[root@test ~]# cat /proc/slabinfo | grep kio
kioctx                79    110    384   10    1 : tunables   54   27    8 : slabdata     11     11      0
kiocb                  0      0    256   15    1 : tunables  120   60    8 : slabdata      0      0      0
[root@test ~]# cat /proc/slabinfo | grep kio
kioctx                77    110    384   10    1 : tunables   54   27    8 : slabdata     11     11      0
kiocb                  0      0    256   15    1 : tunables  120   60    8 : slabdata      0      0      0



回复 支持 反对

使用道具 举报

1005

主题

1469

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
12012
发表于 2017-1-25 10:05:58 | 显示全部楼层
lujiaguai 发表于 2017-1-24 10:03
我的情况是这样的:
[oracle@TEST ~]$ ldd $ORACLE_HOME/bin/oracle | grep libaio
        libaio.so.1  ...

与内核和硬件有巨大关系,不要介意我的fs.aio-nr = 0和其他fs.aio参数。
这个问题很复杂,我的ASM生产环境系统有dio比kioctx+kiocb更好
cat /proc/slabinfo | grep io
dio                  188    228    640    6    1 : tunables   54   27    8 : slabdata     38     38      0
blkdev_ioc           243    390    104   39    1 : tunables  120   60    8 : slabdata     10     10      0
回复 支持 反对

使用道具 举报

81

主题

181

帖子

781

积分

高级会员

Rank: 4

积分
781
 楼主| 发表于 2017-2-4 11:32:09 | 显示全部楼层
本帖最后由 lujiaguai 于 2017-2-4 13:48 编辑

唐老师,上午我用oel5.5又做了一个系统跟数据库
结果是有异步IO的,这个结果跟课堂环境类似,课堂环境也是linux5系列的操作系统
结果如下:
[root@oel55 ~]# uname -a
Linux oel55 2.6.18-194.el5xen #1 SMP Mon Mar 29 22:22:00 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux

[root@oel55 ~]# cat /proc/slabinfo | grep kio
kioctx                74    120    320   12    1 : tunables   54   27    8 : slabdata     10     10      0
kiocb                 15     30    256   15    1 : tunables  120   60    8 : slabdata      2      2      0

但是再centos6.6和OEL6.5上做不出这样的结果。

另外,唐老师提到的DIO,我看过,在OEL6.5和centOS6.6上,dio也都为0
唐老师能否告知,看到DIO的操作系统是哪一个版本,我再试一次?
参数是不是要设置成这样,操有效果?或者filesystemio_options=directio?
SQL> show parameter filesystem
NAME         TYPE          VALUE
------------------------------------ --------------------------------- ------------------------------
filesystemio_options       string          setall

我有点糊涂了,对ASM和裸设备来说,只直接IO好,还是异步IO好?


另外,linux5系列操作系统上是否没有DIO? 只有linux6上才有这个

还有,唐老师说过,ksh是pdksh的升级。
那么linux6上面ksh,能否替代linux5上的pdksh? linux6先决条件检查缺少pdksh,能否直接忽略掉?还是说替换回原来的PDKSH包?




回复 支持 反对

使用道具 举报

1005

主题

1469

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
12012
发表于 2017-2-4 14:49:29 | 显示全部楼层
lujiaguai 发表于 2017-2-4 11:32
唐老师,上午我用oel5.5又做了一个系统跟数据库
结果是有异步IO的,这个结果跟课堂环境类似,课堂环境也是 ...

DIO使用的 Oracle Enterprise Linux 6.8 uek核

另外,可以把
pdksh-5.2.14-36.el5.i386.rpm
pdksh-5.2.14-36.el5.x86_64.rpm
装在RHEL6上的。
回复 支持 反对

使用道具 举报

81

主题

181

帖子

781

积分

高级会员

Rank: 4

积分
781
 楼主| 发表于 2017-2-4 17:41:21 | 显示全部楼层
唐老师,oel68下周抽空再试一次

我刚才发现再centos6.6那一台上面,如果shutdown掉数据库
然后再startup的时候,在nomount到mount的过程中,DIO出现了一点数值。
但是dio数值在数据库mount完,快要open的时候,就逐渐归0了。
如下:
[root@test ~]#  cat /proc/slabinfo | grep dio
dio                    2      6    640    6    1 : tunables   54   27    8 : slabdata      1      1      0
[root@test ~]#  cat /proc/slabinfo | grep dio
dio                    1      6    640    6    1 : tunables   54   27    8 : slabdata      1      1      0
[root@test ~]#  cat /proc/slabinfo | grep dio
dio                    1      6    640    6    1 : tunables   54   27    8 : slabdata      1      1      0
[root@test ~]#  cat /proc/slabinfo | grep dio
dio                    1      6    640    6    1 : tunables   54   27    8 : slabdata      1      1      0
[root@test ~]#  cat /proc/slabinfo | grep dio
dio                    0      6    640    6    1 : tunables   54   27    8 : slabdata      0      1      0
[root@test ~]#  cat /proc/slabinfo | grep dio
dio                    0      6    640    6    1 : tunables   54   27    8 : slabdata      0      1      0
[root@test ~]#  cat /proc/slabinfo | grep dio
dio                    0      6    640    6    1 : tunables   54   27    8 : slabdata      0      1      0
[root@test ~]#  cat /proc/slabinfo | grep dio
dio                    0      6    640    6    1 : tunables   54   27    8 : slabdata      0      1      0
[root@test ~]#  cat /proc/slabinfo | grep dio
dio                    0      0    640    6    1 : tunables   54   27    8 : slabdata      0      0      0
[root@test ~]#  cat /proc/slabinfo | grep dio
dio                    0      0    640    6    1 : tunables   54   27    8 : slabdata      0      0      0

这是否说明其实DIO还是有的,只是这个空的数据库没有出现写数据吗?
我也尝试过,如果插入一些数据,然后switch logfile切换日志,再观察,DIO也依然是0,没有变动

看到一些文档,说在ASM下,filesystemio_options参数被忽略,默认directio
Oracle bypasses the file system layer for ASM.  Thefilesystemio_options parameters is always ignored and direct I/O is always used.  SeeDocument 751463.1 for more

回复 支持 反对

使用道具 举报

1005

主题

1469

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
12012
发表于 2017-2-4 22:16:30 | 显示全部楼层
lujiaguai 发表于 2017-2-4 17:41
唐老师,oel68下周抽空再试一次

我刚才发现再centos6.6那一台上面,如果shutdown掉数据库

/proc是Linux内核空间投向外界的窗口,因此应该是显示问题。与Kernel版本有关,应该在6.5以后实际都支持DIO,不必介意了。
回复 支持 反对

使用道具 举报

81

主题

181

帖子

781

积分

高级会员

Rank: 4

积分
781
 楼主| 发表于 2017-2-6 09:32:09 | 显示全部楼层
唐老师,这个问题是不是跟硬件也有关系,因为我这些环境都在虚拟平台上
另外我看到这样一篇文章,不知道出处是不是官方?
大意是不是说,ASM在内核2.6版本以上,使用asmlib的,异步IO只取决于参数:disk_asynch_io
我们正常的库默认disk_asynch_io=true,那么正常就会有AIO,但是没有。

而唐老师的库却是dio,那么唐老师的库上disk_asynch_io参数是false的吗?我尝试过修改位false,结果dio也为0
我现在如果不纠结这个问题,那么有一点还是要搞清楚。
对ASM来说,究竟是DIO合适?还是AIO合适?
Goal
In this document we are going to explain how to check that asynchronous I/O (AIO) is working. AIO can be enabled in Oracle 9i 9.2 and higher.

Many times there is a requirement to check if Asynchronous I/O is working on Linux Platform, so we can try to use it for our datafiles access inside database.


Solution
The slabinfo maintains statistics about objects in memory. Some of the structs used by Asynchronous I/O are threated as objects in the virtual memory, so we can look for those structs on slabinfo. The ones related to AIO are named kio*.

$ cat /proc/slabinfo | grep kio

If Async I/O is enabled:
$ cat /proc/slabinfo | grep kio
kioctx 270 270 128 9 9 1 : 252 126
kiocb 66080 66080 96 1652 1652 1 : 252 126
kiobuf 236 236 64 4 4 1 : 252 126

and if Async I/O is disabled:
$ cat /proc/slabinfo | grep kio
kioctx 0 0 128 0 0 1 : 252 126
kiocb 0 0 96 0 0 1 : 252 126
kiobuf 0 0 64 0 0 1 : 252 126
In the SLAB allocator there are three different caches involved. The kioctx and kiocb are Async I/O data structures that are defined in aio.h header file. If it shows a non zero value that means async io is enabled.

If you have the source code loaded, you can review it at file aio.h. This file is located under:

/usr/src/linux-<version>/include/linux/aio.h

These data structures are using to track the I/O requests, and are allocated as part of the __init_aio_setup() call in aio.c.

Example strace of dbw0 process with AIO enabled (init.ora parameter filesystemio_options = asynch) shows:

...io_submit(3071864832, 1, {{0xb7302e34, 0, 1, 0, 21}}) = 1gettimeofday({1176916625, 58882}, NULL) = 0io_getevents(-1223102464, 1, 1024, {{0xb7302e34, 0xb7302e34, 8192, 0}}, {600, 0}) = 1...Example strace of dbw0 process with AIO disabled (filesystemio_options = none):

...pwrite64(21, "\6\242\0\0004\21\300\0\220B\243\0\0\0\1\6\207\357\0\0\1"..., 8192, 36077568) = 8192times(NULL) = 1775653082times(NULL) = 1775653082pwrite64(21, "\6\242\0\0<\21\300\0\220B\243\0\0\0\1\6\254\0\0\0\2\0*"..., 8192, 36143104) = 8192...Caveat for ASMLib
If Oracle ASMLib (see  http://oss.oracle.com/projects/oracleasm ) is deployed, the kiocb structs are not used. ASMLib does not use the POSIX aio_*() functions. You will never see any kioctx or kiocb structures from ASMLib. It is far lower level than that.

In fact, ASMLib does AIO or SyncIO depending on how the I/O is passed to it, It makes no decisions at all. This is entirely up to kfk and the layers above it, kfk is entirely controlled by the disk_asynch_io parameter. So, we can check whether ASMLib is doing AIO by PL/SQL command "show param disk_asynch_io". (You can disable AIO by setting disk_asynch_io=false)

With ASMLib, AIO is done via ioctl() calls (2.4 kernel), or read() calls (2.6 kernel) on the ASM device. Whether ASMLib uses aio depends on whether oracle is configured to do aio, In oracle 10g, if ASMLib is in use, the i/o is asynchronous, because oracle 10g enables aio by default.

The strace when using ASMlib will show read calls that look like this:

...read(16, "MSA\0\2\0\10\0P\0\0\0\222\377\377\377@\313\373\5\0\0\0"..., 80) = 80...The first 3 characters, byte-swapped, are ASM, indicating an ASMLib I/O command structure.

另外,有一篇MOS文档,提到的也是类似的问题
Things To Consider For Setting filesystemio_options And disk_asynch_io (文档 ID 1987437.1)
在该文章中的“File System–specific Notes”部分,有如下论述:

File System–specific Notes


File System

Notes

Raw device
Raw device access to disks does not involve a file system.  The filesystemio_options parameters is always ignored and direct I/O is always used.  Under Linux, block devices are also treated this way.

Direct use of raw or block devices is not supported as of 12c.

ACFS
ACFS is not supported for database files that can be stored directly in ASM, including data files, redo files, and control files, but there is an exception for Linux Exadata.  SeeDocument 1929629.1 and  Document 1369107.1.

ASM
Oracle bypasses the file system layer for ASM.  Thefilesystemio_options parameters is always ignored and direct I/O is always used.  SeeDocument 751463.1 for more

FUSE (Linux)
Direct I/O cannot be enabled on FUSE-based file systems.

JFS (IBM)
Not to be confused with JFS or OnlineJFS on HP-UX, which is VxFS as supplied with HP-UX.

JFS comes in two versions.  Version 1 of JFS (JFS1) is available on AIX only.  Version 2 of JFS (JFS2) is available on several OSes, and is usually called "JFS" on operating systems other than AIX.

JFS1 does not support concurrent I/O, but JFS2 does.

NFS
Using direct I/O is recommended to avoid potential data corruption.  See  Document 437005.1 for more.

Whether concurrent I/O is used is controlled by the NFS server.

Direct NFS (dNFS) Oracle bypasses the file system layer when using Direct NFS.  The filesystemio_options parameters is always ignored and direct I/O is always used.
VxFS/JFS/OnlineJFS (Veritas)
VxFS as supplied with HP-UX is known as JFS or OnlineJFS; not to be confused with IBM JFS.

Direct I/O cannot be set using filesystemio_options on platforms other than HP-UX.  Instead, use the convosync=direct and mincache=direct mount options to force direct I/O or the cio option to force concurrent I/O.

Concurrent I/O is an extra option on VxFS (called "Concurrent I/O").  It is also available through the Quick IO option or ODM.  Otherwise concurrency will be limited.  NB: ODM is the preferred method of accessing Oracle files on VxFS.

VxFS ODM Oracle bypasses the file system layer when using ODM on VxFS.  The filesystemio_options parameters is always ignored and direct I/O is always used.  Asynchronous I/O is supported natively by the ODM interface.
ZFS
ZFS does not support direct I/O and consequently cannot be used with RAC.  

With ZFS you can limit how much RAM the ARC consumes in certain Solaris releases.  SeeDocument 1663862.1.
回复 支持 反对

使用道具 举报

1005

主题

1469

帖子

1万

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
12012
发表于 2017-2-6 15:38:05 | 显示全部楼层
lujiaguai 发表于 2017-2-6 09:32
唐老师,这个问题是不是跟硬件也有关系,因为我这些环境都在虚拟平台上
另外我看到这样一篇文章,不知道出 ...

上面的两段,我都看了。基本和以前讨论不矛盾。
我的系统肯定是disk_async_io=true
这个参数怎能是false在生产环境?因此,AIO还是DIO是内核版本的显示问题,我认为至少不是sync IO。最后要看对数据仓库型的SQL或某个Top SQL,是否感受到IO环节的Waiting Event。

回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|Bo's Oracle Station   

GMT+8, 2024-3-29 14:49 , Processed in 0.044421 second(s), 24 queries .

快速回复 返回顶部 返回列表