自贵 的个人资料Smithy's Sky照片日志列表更多 ![]() | 帮助 |
|
8月24日 DB2与AIX 性能调优基础[zt]Are you running DB2 on AIX? Ever wondered what you can you do within AIX to produce noticeable DB2 performance improvements? This article addresses that question, and also discusses the most important combination of DB2 and AIX tuning parameters for optimum DB2 performance. The author shows you how to implement and design your database with performance in mind, depending on your workload and data requirements. He introduces the best database layout from an operating system perspective, and the best performance settings for both the operating system and the relational database environments. When performance problems arise, the problem is either related to a system resource issue or an application issue (or both). When it comes to system resource usage, AIX provides performance tuning parameters to achieve optimal resource usage for your business objectives. From an application perspective, DB2 is considered middle tier yet at the same time runs within application process space. Like AIX it provides the capability to monitor performance from both an application and SQL statement perspective, providing a wealth of tuning data. Some tuning parameters can be reviewed on their own and changed based on known workload requirements, and others must be considered as part of a larger picture. This article shows you how to recognize problems, and analyze and tune performance from both an AIX and DB2 perspective. Often within a DB2 AIX environment, performance can be attributed to two areas within the system: memory and disk I/O. From an operating system perspective, excessive paging generally indicates insufficient amount of memory in the system. For most cases the easiest fix is to add more memory. As far as poor disk I/O, there are several things you can do within AIX to improve performance, which is what makes AIX unique from other operating systems. The I/O settings you are able to adjust within AIX for performance will compliment the performance gains you will be able to obtain through DB2. You can exceptionally improve database performance within a DB2 AIX environment. On the other hand, within DB2 poor disk I/O can be attributed to either poor tablespace layout or inadequate memory utilization. But, improving tablespace performance within DB2 is rare since it would mean a redesign of your database, which is not always feasible. Good memory management within DB2 would improve disk I/O performance without a redesign of your tablespace, as you will see later. Often within DB2 poor performance can be attributed to large amounts of disk I/O. Minimizing the number of times DB2 has to retrieve data from disk increases performance. (Some disk I/O, such as logging, is unavoidable.) Consequently, DB2 uses buffer pools to improve performance. A buffer pool is a finite area in memory that DB2 uses as a staging area for data for transactional processing, and for reading and writing data to and from disk. The configuration parameters involved with tuning the buffer pool are:
Before tuning the buffer pool, you must first analyze what activity is occurring in the buffer pool and record the relevant values. Then you will have an indicator to measure the performance results of any changes made to the buffer pool parameters. DB2 has the snapshot monitor to capture realtime information on buffer pool utilization. This displays all activity related to pages being written to and read from memory. Before getting snapshot data for buffer pool, you must first turn on the monitoring switch by issuing:
which will yield:
Notice that before running the
After issuing the To obtain buffer pool information you must run the following command:
You must have a connection to the database for the get snapshotcommand to work.
The following data elements can be measured to evaluate how the buffer pool is being used:
The key to tuning the buffer pool is to increase as much as possible the buffer pool and index pool hit ratio, which is the percentage of time that the database manager DID NOT need to load a page from disk in order to service a page request.
The formula is similar to the Index Pool Hit Ratio:
For best performance we would ideally want these values to be as close to 75% as possible. 100% would mean that the entire database is loaded into memory, which is unrealistic in most cases. To increase hit ratio in the buffer pool or index pool you must play with increasing the buffer pool size (BUFFPAGE). However, when you increase this value you would likely want to also monitor the usage of system memory to ensure no paging is occurring as a result of your changes to BUFFPAGE. To monitor system memory use Sometimes instead of tuning BUFFPAGE, it may be that only a reorganization of data is necessary to improve the hit ratio of index pool and buffer pool. It is advisable to first perform a Prefetching is the retrieval of data (one or more extent pages) from disk in anticipation of their use. This can significantly improve performance in SELECT statements by reducing the time waiting for I/O to complete. Setting the PREFETCHSIZE tells DB2 to place that number of pages in the buffer pool in anticipation of its use. The default is 32, but performance is improved when this value is set to When tweaking the PREFETCHSIZE the NUM_IOSERVERS must also be changed. This value should be at least:
whereNrepresents one or more additional servers. NUM_IOSERVERS represent the number of I/O servers that perform prefetching for the database. Having additional I/O servers will not hurt performance, as unused I/O server memory pages will get paged out. For optimum parallel I/O this value should at least be set to the number of physical disks or containers in the database. The buffer pool consists of pages that are eitherin use, meaning the pages are being updated or read, ordirty, meaning the pages have not yet been written to disk. Once dirty pages are written to disk they remain in the buffer pool, but their status changes to clean for reuse or for continual use by other database transactions. This is where the page cleaner (NUM_IOCLEANERS) comes into play. It is a friend to the DB2 agents, since cleaning dirty pages from buffer pool would otherwise have to be done by the individual agents. The page cleaners write changed (dirty) pages from the buffer pool to disk. As a result, application transactions are faster because DB2 agents do not have wait idle for I/O. If your database usage is only for querying, it is safe to leave NUM_IOCLEANERS set at its default of 1. But, if your application will be doing updates, inserts, and other action transactions then it is recommended that this value be set to at least the number of physical disks in the database. CHNGPGS_THRESH is also a configuration parameter used along with NUM_IOCLEANERS. It tells NUM_IOCLEANERS when to go and look for dirty pages in the buffer pool. When the percentage of changed pages in buffer pool exceeds the threshold (CHNGPGS_THRESH), DB2 will dispatch page cleaners as necessary up to the number specified in NUM_IOCLEANERS to write dirty pages to disk. For most applications the default percentage (60) will suffice, but for databases with a small number of large tables, increasing this value to 75% will help performance. One of the most important decisions a database administrator has to make when designing a database is how the data will be laid out across physical partitions. Overlooking this important step can drastically affect I/O performance. From an operating system layer, DB2 is only as good as the file system on which it runs. In AIX, that file system is controlled by the Logical Volume Manager (LVM). LVM is a subsystem within AIX that controls disk resources and provides a logical mapping between storage and physical disks. To achieve the most from LVM in I/O performance, it is important that you properly plan your database layout across physical disks. The following are some recommended file system layouts and accompanying tuning parameters that will help you get maximum performance from LVM and DB2. The following settings are recommended to allow maximum resource usage of AIX by DB2.
Striping, also known as RAID 0, is a technology that was developed to achieve maximum I/O performance. The basic concept is that data is written and read from the file system in chunks across the width of the physical disk layout in parallel. The width represents the number of disks within the layout, and striping represents the contiguous layout of data across separate disks. From a high availability perspective, striping does not provide redundancy. Failure of one physical disk would render your data useless. However, to add redundancy AIX provides a layout of striping plusmirroring. The following are some general recommendations that would increase performance in a striped layout. max_coalesce
where hdiskN is the physical volume number. To change the value, use:
For example, for a RAID 5 ( 5+P ) we set max_coalesce to 0x50000 which is 5x64kb:
queue_depth
For example, for a RAID 5 ( 5+P ) we set queue_depth to 15 which is 3 *N = 15
Note that these values can be also changed through smit by executing minpgahead and maxpgahead Whenever maxpgahead is increased, make sure that maxfree is also increased so that the difference between maxfree and minfree is at least equal to the value of maxpgahead. These settings only affect I/O that goes through the AIX LVM layer; raw device I/O is not affected. Usage:
On AIX 5.2 and higher, /usr/samples/kernel/vmtune was replaced with vmo. lvm_bufcnt Usage:
Intensively used container Mirroring, also known as RAID 1, is a feature on AIX that can be useful within a DB2 data layout. The objective of mirroring is redundancy and high availability of data. Having two or more copies of data is important from a high availability standpoint in reducing downtime. If one copy goes bad, the system automatically starts using the other copy. AIX offers the capability to provide up to three copies of data in a mirrored environment. In AIX LVM an important concept to understand is that mirroring occursonlyat the logical volume layer, and not at the physical disk layer. Users are often duped into thinking that a mirrored disk layout will give performance gains in an OLTP type of system where many reads from the database are a requirement. Normally in a mirrored configuration, during a read function if one copy is busy the system will automatically perform the read on the other unused copy, consequently enabling for parallel I/O. However, this is not always the case, as is explained below inRead performance penalty. Write scheduling policy To check the scheduling policy, you can use SMIT or the
In the example above you'll also notice that MIRROR WRITE CONSISTENCY and WRITE VERIFY are both set to OFF. Setting these attributes to ON has performance implications discussed below. WRITE VERIFY MIRROR WRITE CONSISTENCY To check if your SSA have fast cache modules installed you can run the following command:
The SSA adapter on this system does have a Fast Cache Module installed that's 32 megabytes (Device ID: Z1). From a DB2 and AIX point of view, data redundancy and availability are the objectives in a mirrored environment and therefore MWC cache and SSA cache are important. The preferred method is to use SSA cache and leave MWC off. If MWC is required, try to place the logical volumes on the outer edges of the disk, as this is where the MWC cache is located. This will help minimize disk head movements when performing writes. Read performance penalty In a production environment, database performance tuning is a complicated matter and should never be entered into for the sake of only gaining performance. First determine if there is a performance problem. If so, identify it and work from there. When designing a database, you should know what kind of performance you expect from it beforehand. Poor planning can affect performance by a factor of over 60% compared to good planning. Regardless of whether you are designing a database or trying to improve the performance on a production database, from a DB2 perspective to increase I/O you should add at least one buffer pool to each of your containers. Afterwards, tune the BUFFPAGE of each container until you get a good hit ratio. When you've got your hit ratio up, continue tuning PREFETCHSIZE, NUM_IOCLEANERS, CHNGPGS_THRESH, and NUM_IOSERVERS until you get the expected results. (Use both the snapshot monitor and iostat to monitor I/O performance.) From an AIX perspective, planning is important and good disk layouts are imperative for optimum DB2 performance. This is one of the most overlooked areas in database planning. I addressed mirroring and striping, two of the most popular layouts. If performance is what you have in mind, striping is what you want. If high availability of data is important, mirroring should be your choice. There are, however, tradeoffs to be considered in each layout. For instance, although striping gives you the best performance in parallel reads and writes, failure of a single disk will render your data useless. Although mirroring will give you data redundancy, writing of data to disk is costly because it would mean up to three writes depending on how many copies you have configured. But, because of the flexibility of the LVM in AIX, you could minimize the penalty factor of each one of these configurations by tuning the following parameters:
AIX Version 4.3.3 introduced the new mirroring and striping function (also known as RAID 0+1 or RAID 10 technology). This is by far the ideal configuration from a DB2 perspective. The mirroring and striping function offers the best of both configurations -- performance with the ability of parallel I/O, and redundancy with the capability of having up to three copies of the data. The one big disadvantage of this configuration is disk cost. The number of required physical disks and their individual capacity can double or even triple when using the mirroring and striping function.
This article highlighted most of the tuning parameters in both AIX and DB2 for optimal DB2 performance. It touched on file system layouts from an AIX perspective, and buffer pool management from a DB2 perspective. It also showed a few monitoring utilities in DB2 and AIX to aid in capturing performance data, and recommended some specific operating system environment settings to allow for maximum resource usage by DB2. 8月13日 惬意的周末室友们都出去了
家里就我一个人
早晨起床去市场买了只童子鸡回来
炖了一锅汤,另外小炒了几个菜
喝着小酒,一个人慢慢地享受着
呵呵,菜竟然吃了两天,呵呵
空闲时间看看电视(2007斯诺克荣威大师赛,我最喜爱的军旅片),睡觉,看书,好不惬意啊!
这个周末我的心好静,好静!
又一个星期了,新的起点,新的动力!!! 8月10日 第一次爱的人灰色的天你的脸 爱过也哭过笑过痛过之后只剩再见 我的眼泪湿了脸 失去第一次爱的人竟然是这种感觉 总以为爱是全部的心跳 失去爱我们就要~ 就要一点点慢慢的死掉 当我失去你那一秒心突然就变老 the day you went away 喧闹的街没发现我的泪被遗忘在街角 the day you went away 我看着你走过街 还穿着去年夏天我送你的那双球鞋 银色手炼还耀眼 你的世界似乎一点也没有因此改变 总以为爱是全部的心跳 失去爱我们就要~ 就要一点点慢慢的死掉 当我失去你那一秒心突然就变老 the day you went away 喧闹的街没发现我的泪被遗忘在街角 the day you went away 总以为爱是全部的心跳 失去爱我们就要~ 就要一点点慢慢的死掉 当我失去你那一秒心突然就变老 the day you went away 喧闹的街没发现我的泪被遗忘在街角 the day you went away 有一天也许我能把自己治好 再一次想起来应该要怎么笑 第一次爱的人它的坏他的好 却像胸口刺青是永远的记号 跟着我的呼吸直到停止心跳 没有你了笑容睡着了 而眼泪还醒着 呼吸慢慢的 像吹着以前的味道 眼睛绽放着 而眼神枯萎了 那呵护的人 她摘下爱情 不回来了 我太爱你了 我失去你了 像一觉醒来 全世界都变坏 思绪一片空白 自己轻的像一颗尘埃 吹落以前 还要你来主宰噢 我失去你了 因为我太爱了 我知道你的心 是一片窗外云彩 誓言变成空白 空白得装不下未来 星星和月亮 今夜就要分开 ---- 快乐睡着了 而孤独还醒着 过去美丽的 恨自己清楚都记得 回忆绽放着 而感觉枯萎了 8月7日 我到底爱谁?昨晚心血来潮
去寻找我以前的学习笔记
可是,看到是你她以前给我留下的信
突然之间,我有种想重新拥有她的感觉
可是,理智战胜了我
我已经不可能再和她在一起了
我知道,不管是曾经或是现在,都有爱我的女孩
可是,我到底爱谁?
现在,我已经惧怕付出我的感情
不敢再去伤害女孩子了
我倒愿意单身过上这一辈子了
可是,有些时候,我又并不理智
我到底爱谁?我的终点在哪里? 8月6日 快乐周末过后,又一个新的星期开始周六和同事一起打牌,打台球,呵呵
运气不错,真是大杀四方啊
没想到,原来我的台球水平已经很厉害了
周日中午下了一把厨房
呵呵,还不错,不过倒是让我想起了她,当然咯,瞬间就会忘记的
下午和同学去游泳馆游泳,呵呵,一个半小时,不错
就是人多了点
比较郁闷的是,美女比较少啊
大多是三口之家型的
难得有单独的女孩,都实在是。。。,哎
呵呵,游了一个半小时小来,好累啊
晚上回家吃完饭就睡觉了,一觉到今天早晨8点
不过比较惨的是,睡多了点,脖子都扭了,呜呜
happy过后,好好开始新的星期,学习学习
AIX,DB2,NBU等等,都是我现在的学习的目标
加油,小贵子,你是最好的!
8月3日 明天就周末了,爽吗?明天就周末了,去做些什么呢?
呵呵,打算当然有咯
周六和同事去打牌,打台球
周日嘛,和同学去游泳,^_^
他还特意给我配了个眼睛,说什么是用来看美女的,呵呵
不错的周末安排吧,不爽才怪!
一起happy去吧 8月1日 杂记 一直都很想正儿八经的写点东西
可是,每次坐在电脑前,却不知道该如何去写
我的爱情?感情?
我的工作,事业?
其实,有些东西,不写出来可能会更好的
我一个朋友以前的女朋友,她把和其他男人偷情的细节,mk的情形都写出来
就这个,一个角度讲,我很佩服她的大胆开放,一个角度讲,我很看不起
扯远了,事不关己,不去了解也好啊
从离家到北京求学到现在事业还算顺利,已经有7个年头啦
感情上嘛,经历了很多
也许是自己的挑剔,我的高要求?曾经有过让我后悔过,但是,一切都是美好的回忆
现在的,要去珍惜,可是,这些却是件很难的事情,要考虑的事情太多,受影响的因数也太多
工作上,一切都还算顺利的
呵呵,不说了,说点别的八挂吧
今天真热,早晨等车,竟然等了快45分钟了,真想投诉公交公司
哎。。。。。。。。。。。。
好咯,开心工作要紧!呵呵哈
|
|
|