Tuning VMM kernel parameter in AIX for Oracle

on

Updated@2013-01-30
对于运行Oracle数据库的AIX操作系统VMM(Virtual Memory Management)层面的系统内核参数如何进行调整,这是一个很古老的话题。这篇文章力图解释一些概念,同时与时俱进地提出一些设置的建议。

通常对VMM系统内核调优的目的,在于最大限度的保护计算内存页(computational memory)不被page-out到paging space中,因为对于计算内存页(特定于Oracle数据库来说就比如是SGA和PGA)来说被page-out出去的内存页总在之后的某一时刻又会被重新page-in,通常这样会对系统性能产生负面影响。另外对于像Oracle数据库这样拥有自己的数据缓存机制(data buffer cache)的数据库应用来说,保护计算内存页更显得格外重要。

在IBM AIX 5.3 ML1之前,对于作为Oracle Database Server用途并且使用裸设备作为Datafile存储的的AIX操作系统内核参数调优的经验通常如下:

maxperm%=maxclient%=(通常是一个很低的值,小于20或者30)
设置较小maxperm%值的原因在于,如果文件内存页在内存中的比例高过该参数值,那么VMM换页算法将只从文件内存页中进行偷页。将maxperm%值降低就意味着有更大的机会让VMM只从文件内存页中偷页。
minperm%=5(通常是一个比maxperm%更低的值)
lru_file_repage = 1(这是默认值)

比如以下的VMM参数设置就符合该种调优方式。

root@hostname:/> vmo -a |grep "maxclient%"
            maxclient% = 15            
root@hostname:/> vmo -a |grep "maxperm%"
              maxperm% = 15
root@hostname:/> vmo -a |grep "minperm%"
              minperm% = 10              
root@hostname:/> vmo -a |grep "lru_file_repage"
       	lru_file_repage = 1

但是实际上在AIX 5.3 引入了lru_file_repage参数之后,对于操作系统VMM层的内核参数调整方法已经发生了改变。现在的VMM参数调优建议应该如下。

maxperm%=maxclient%=(较高值,通常为90%)
因为较高的maxperm%值能够防止不必要的lrud进程运行,lrud进程是系统核心进程负责在需要的时候偷取内存页(stealing memory)。如果可以,maxperm%应该大于numclient%值(通过vmstat -v可以获得)。(如果服务器文件系统使用较多,那么此参数另有建议,参见后文)。
minperm%=(较低值,对于超过64G物理内存的服务器来说通常为20%,IBM甚至建议将该值设置为3%,在AIX6.1中该值已经默认为3%)
较低的minperm%值用以保证lru_file_repage参数作用不至于无法体现。通常minperm%值应该低于numperm%值(通过vmstat -v可以获得),如果当前的minperm%=5%满足需求那么可以不用修改。
strict_maxperm=0(这是默认值,表示这不是一个hard limit)
strict_maxclient=1(这是默认值,表示这是一个hard limit)
lru_file_repage = 0
当该参数设置为0的时候,VMM将会优先尝试从文件内存页中进行偷页操作,而不影响到计算内存页。在AIX6.1中该值已经默认为0。

更详细地看一下lru_file_repage参数是如何影响VMM偷页算法的。

由于空闲页低于了minfree参数值,或者其它的一些触发机制(比如说client page数量超过了maxclient%并且strict_maxclient=1)导致lrud进程要开始偷页操作,此时如果lru_file_repage =1(这是默认值)那么lrud进程将会根据多种内核参数和系统当前状况进行判断,可能是只从文件内存页中偷页也可能是不管内存段的类型从整个内存中进行偷页,这就可能导致计算内存页被page-out出去,而如果lru_file_repage =0,那么只要文件内存页(file memory)占内存的比值(numperm)高于minperm并且VMM确实能够从文件内存页中偷取到足够的内存以满足需求,那么就只会做文件内存页的page-out。因此,保护了Oracle数据库SGA在内存中的稳定性。

另外可以调整的参数包括:
page_steal_method = 1(应该为默认值)

参看如下解释:

The VMM maintains a logical list of free page frames that it uses to accommodate page faults. In most environments, the VMM must occasionally add to the free list by reassigning some page frames owned by running processes. The virtual-memory pages whose page frames are to be reassigned are selected by the VMM’s page-replacement algorithm. The VMM thresholds determine the number of frames reassigned.
By default in AIX 6.1, and optionally in AIX 5.3 the LRU algorithm can either use lists or the page frame table. Prior to AIX 5.3, the page frame table method was the only method available. The list-based algorithm provides a list of pages to scan for each type of segment.
You can disable the list-based LRU feature and enable the original physical-address-based scanning with the page_steal_method parameter of the vmo command. The default value for the page_steal_method parameter is 1, which means that the list-based LRU feature is enabled and lists are used to scan pages. If the page_steal_method parameter is set to 0, the physical-address-based scanning is used. The value for the page_steal_method parameter takes effect after a bosboot and reboot.

因此,对于作为Oracle数据库服务器的IBM AIX 5.3之后版本,VMM参数建议值如下。

minperm%=3
maxperm%=90
maxclient%=90
lru_file_repage=0
strict_maxperm=0
strict_maxclient=1
page_steal_method=1

然而如果数据库服务器中文件系统使用较多(比如数据文件存储在文件系统中,或者有大量的RMAN备份归档日志,或者有大量磁盘文件复制转移等操作),那么强烈建议设置maxperm%=maxclient%=(低值,20%或者10%),这是为了保障有安全的物理内存空闲,而不至于给文件内存页占据,因为如果maxclient%设置为90,那么意味着文件内存页可以占据更多的内存(也就是意味完全空闲的内存更低),虽然根据lru_file_repage=0的算法,偷页操作会从文件内存页中进行,但是这部分缓存的释放是需要时间的,也会需要大量IO和换页操作,当某个时间点,数据库服务器上突然出现大量需要消耗内存的操作,就可能导致大量的换页,从而消耗大量系统资源,影响数据库性能,并可能进一步导致数据库服务器的不稳定。这在很多客户系统中已经遇到这样的案例。

因此对于这样的系统,我们建议VMM参数设置如下。

minperm%=3
maxperm%=20
maxclient%=20
lru_file_repage=0
strict_maxperm=0
strict_maxclient=1
page_steal_method=1

修改VMM参数的命令如下。

#!/usr/bin/ksh
vmo -p -o minperm%=3;
vmo -p -o maxperm%=20;
vmo -p -o maxclient%=20;
vmo -p -o lru_file_repage=0;
vmo -p -o strict_maxperm=0;
vmo -p -o strict_maxclient=1;
vmo -r -o page_steal_method=1; 

5 Comments Add yours

  1. boypoo says:

    做了个safa

  2. ztg says:

    page_steal_method = 0 时lock_sga必须设置为true?

  3. bobjoy says:

    我的一个oracle系统也是swap不断上涨的问题,计划要调整内存参数。
    有一点不明,vmm如果要偷页时,要偷文件内存页的话,是直接释放掉这个内存
    还是要把这些文件内存页page-out到swap区?
    感觉这种偷页在vmstat观察看不到pi,po上涨

  4. kamus says:

    @bobjoy
    对于文件内存来说,AIX不预计将会再次从swap进入physical memory,所以应该是直接释放掉。if i’m wrong pls correct me.

Leave a Reply to ztg Cancel reply

Your email address will not be published. Required fields are marked *