存档

2009年5月 的存档

google patch v4 for mysql

2009年5月31日

下载地址: http://google-mysql-tools.googlecode.com/svn/trunk/mysql-patches/all.v4-mysql-5.0.37.patch.gz

Features


  • displays more data in SHOW INNODB STATUS and SHOW STATUS including per-file IO statistics
  • uses less CPU while processing background IO requests
  • enforces innodb_max_dirty_pages_pct
  • prevents the insert buffer from getting full (and becoming useless)
  • changes the main background IO thread to be simpler and use more asynchronous IO
  • adds many my.cnf variables
  • Reimplements adaptive checkpoints as first described by Percona
  • Changes the computation of the percentage of dirty buffer pool pages. Before this change the percentage exluded pages borrowed from the buffer pool for other uses. While that may be more accurate, it also requires the caller to lock/unlock a hot mutex. It also made the percentage vary a bit too much as the insert buffer grew and shrank. The v4 patch doesn’t exclude the borrowed pages. As most of the borrowed pages should be used in the insert buffer and the insert buffer should be smaller (thanks to ibuf_max_pct_of_buffer), this is probably a good thing.


Performance


谭俊青 MySQL, MySQL HA

Inniostat - InnoDB IO Statistics

2009年5月31日

原文:http://blogs.sun.com/realneel/entry/inniostat_innodb_io_statistics

文中工具用到solaris下的dtrace数据,因此linux下不能使用.

例子:

#./inniostat -h
Usage: inniostat [-h] [-d] [-p pid] [interval]
                 -h : Print this message
                 -p : MySQL PID
                 -d : Dump dtrace script being used

# ./inniostat
 __physical__  ___Innodb___ ____read____     ______write______
   r/s    w/s    r/s    w/s   data    pre    log dblbuf dflush     Time
    24    121     24     50     24      0     50      0      0 16:00:57
    26    130     26     51     26      0     51      0      0 16:00:58
    18    134     18     54     18      0     54      0      0 16:00:59
    25    129     25     51     25      0     51      0      0 16:01:00
    29    116     46     47     17     29     47      0      0 16:01:01
    10    140     10    132     10      0     52      0     80 16:01:02
    29    129     35     53     14     21     53      0      0 16:01:03
Col Description
r/s Physical (Actual) reads per sec
w/s Physical (Actual) writes per sec
r/s Reads issued by Innodb per sec
w/s Writes issued by Innodb per sec
data Regular Reads issued by Innodb to the datafiles per sec
pre Prefetch Reads issued by Innodb to the datafiles per sec
log Log writes issued by Innodb per sec
dblbuf Double buffer writes per sec
dflush Writes due to flushing of Innodb buffers to disk.

谭俊青 news / tools

6.0.11 will be the last release of MySQL 6.0

2009年5月25日

来源: http://lists.mysql.com/packagers/418

MySQL 6.0.11-alpha, a new version of the MySQL database system has been
released.  The main page for MySQL 6.0 release is at

  http://www.mysql.com/mysql60/

6.0.11 will be the last release of 6.0.  After this we will be
transitioning into a New Release Model for the MySQL Server

  http://forge.mysql.com/wiki/Development_Cycle

The goal of this transition is to enable more frequent and timely
releases of the MySQL Server.
希望新的Release Model能给mysql带来更大的活力。

谭俊青 MySQL

BBU电池电量的监控

2009年5月19日

Author: ivan@mysqlab.net

早上6点被电话叫醒,有应用报警,根据经验应该是raid卡电池没电了,一查果然有2台机器没电了,还有2台已经充电完成。

[root@userminfo2:2.20 ~]# MegaCli -AdpBbuCmd -GetBbuStatus -aALL

BBU status for Adapter: 0
BatteryType: TBBU
Voltage: 3858 mV
Current: 932 mA
Temperature: 24 C
Firmware Status: 00000008
Battery state: 
GasGuageStatus:
  Fully Discharged        : No
  Fully Charged           : No
  Discharging             : No
  Initialized             : Yes
  Remaining Time Alarm    : No
  Remaining Capacity Alarm: No
  Discharge Terminated    : No
  Over Temperature        : No
  Charging Terminated     : No
  Over Charged            : No

Relative State of Charge: 17 %
Charger Status: In Progress
Remaining Capacity: 253 mAh
Full Charge Capacity: 1502 mAh
isSOHGood: Yes


[root@user-stat1:2.31 ~]# MegaCli -AdpBbuCmd -GetBbuStatus -aALL
                                     
BBU status for Adapter: 0

BatteryType: TBBU
Voltage: 4065 mV
Current: 0 mA
Temperature: 22 C
Firmware Status: 00000000

Battery state:

GasGuageStatus:
  Fully Discharged        : No
  Fully Charged           : Yes
  Discharging             : Yes
  Initialized             : Yes
  Remaining Time Alarm    : No
  Remaining Capacity Alarm: No
  Discharge Terminated    : No
  Over Temperature        : No
  Charging Terminated     : Yes
  Over Charged            : No

Relative State of Charge: 100 %
Charger Status: Complete
Remaining Capacity: 1639 mAh
Full Charge Capacity: 1642 mAh
isSOHGood: Yes


其实这问题都遇上N次了,为啥都遇上问题才得以解决?就是因为对BBU电量比例并没有监控。

对于出现问题的机器,一般临时处理办法都是更改trx参数(这是个非常危险的操作,如果这段时间按掉电死机之类的就会造成数据丢失),而这些都是可以预警和自动完成的。

新的监控系统将加入Raid卡BBU电池电量的监控,实现预警。至于是否自动更改redo日志的写策略可以配置,根据不同业务需求而定。

ivan 于 2009-05-19 早上6点

谭俊青 MySQL

MegaCli 常用命令备查

2009年5月14日

=======================================================
Display BBU Status Information
=======================================================
MegaCli -AdpBbuCmd -GetBbuStatus -aN|-a0,1,2|-aALL
——————————————————-
MegaCli -AdpBbuCmd -GetBbuStatus -aALL


=======================================================
Display BBU Capacity Information
=======================================================
MegaCli -AdpBbuCmd -GetBbuCapacityInfo -aN|-a0,1,2|-aALL
——————————————————-
MegaCli -AdpBbuCmd -GetBbuCapacityInfo -aALL

 
=======================================================
Display BBU Design Parameters
=======================================================
MegaCli -AdpBbuCmd -GetBbuDesignInfo -aN|-a0,1,2|-aALL
——————————————————-
MegaCli -AdpBbuCmd -GetBbuDesignInfo -aALL

 
=======================================================
Display Current BBU Properties
=======================================================
MegaCli -AdpBbuCmd -GetBbuProperties -aN|-a0,1,2|-aALL
——————————————————-
MegaCli -AdpBbuCmd -GetBbuProperties -aALL

 
=======================================================
Start BBU Learning Cycle
=======================================================
Description Starts the learning cycle on the BBU.
No parameter is needed for this option.
——————————————————-
MegaCli -AdpBbuCmd -BbuLearn -aN|-a0,1,2|-aALL

 
=======================================================
Change Virtual Disk Cache and Access Parameters
=======================================================
Description Allows you to change the following virtual disk parameters:
-WT (Write through), WB (Write back): Selects write policy.
-NORA (No read ahead), RA (Read ahead), ADRA (Adaptive read ahead): Selects read policy.
-Cached, -Direct: Selects cache policy.
-RW, -RO, Blocked: Selects access policy.
-EnDskCache: Enables disk cache.
-DisDskCache: Disables disk cache.
——————————————————-
MegaCli -LDSetProp { WT | WB|NORA |RA | ADRA|-Cached|Direct} |
{-RW|RO|Blocked} |
{-Name[string]} |
{-EnDskCache|DisDskCache} –Lx |
-L0,1,2|-Lall -aN|-a0,1,2|-aALL

——————————————————-
MegaCli -LDSetProp WT -L0 -a0

 
=======================================================
Display Virtual Disk Cache and Access Parameters
=======================================================
MegaCli -LDGetProp -Cache | -Access | -Name | -DskCache -Lx|-L0,1,2|
-Lall -aN|-a0,1,2|-aALL

——————————————————-
Displays the cache and access policies of the virtual disk(s):
-WT (Write through), WB (Write back): Selects write policy.
-NORA (No read ahead), RA (Read ahead), ADRA (Adaptive read ahead): Selects read policy.
-Cache, -Cached, Direct: Displays cache policy.
-Access, -RW, -RO, Blocked: Displays access policy.
-DskCache: Displays physical disk cache policy.

谭俊青 linux

mylab_sys_exec UDF调用mysql外部系统命令(For linux)

2009年5月13日

有时候为了方便,利用event/trigger调用系统外部命令,可因为安全问题,mysql自身并没有提供相关命令,这里提供个调用系统命令的自定义函数mylab_sys_exec

so文件下载:mylab_sys_exec.so ( mysql5.1.34 测试通过)


加载:

CREATE FUNCTION mylab_sys_exec RETURNS INTEGER SONAME "mylab_sys_exec.so";



使用:

SELECT mylab_sys_exec (‘CMD’);



源码:

my_bool mylab_sys_exec_init (UDF_INIT *initid, UDF_ARGS *args, char *message );
void mylab_sys_exec_deinit (UDF_INIT *initid );
int mylab_sys_exec (UDF_INIT *initid, UDF_ARGS *args, char *is_null, char *error );

my_bool mylab_sys_exec_init( UDF_INIT *initid, UDF_ARGS *args, char *message )
{
    if(args->arg_count == 1  && args->arg_type[0]==STRING_RESULT)
    {
        return 0;
    } else {
        strcpy( message, "One string type parameter expected")
        return 1;
    }
}

void mylab_sys_exec_deinit ( UDF_INIT *initid ){}

int mylab_sys_exec( UDF_INIT *initid , UDF_ARGS *args , char *is_null , char *error )
{
    return system (args->args[0]);
}

文章链接地址:mylab_sys_exec UDF调用mysql外部系统命令(For linux)

谭俊青 C, MySQL

主从数据库记录数直观校验工具Mylab.RecordChecker

2009年5月11日
主从数据库记录校验

主从数据库记录校验工具Mylab.RecordChecker截图

工具采用php+mysqli+extjs实现,要使用需要修改部分代码
暂时命名为:Mylab.RecordChecker v1.0 beta
等svn服务器搭建起来之后,我会继续完善代码,做成通用的工具。

下载链接:Mylab.RecordChecker

谭俊青 MySQL Replication

发布自己的DbSession类(for php)

2009年5月11日

嗯,怎么说呢,自己几乎没用过php自带的session,都是基于这个类实现的。
授权方式:GPL v3.0 (哈哈,其实我自己也不懂这些协议)

阅读全文…

谭俊青 php

MySQL5.4引起的一些争议

2009年5月4日

Author: ivan@mysqlab.net/ 谭俊青

最近看到了一系列有关MySQL5.4 innodb性能比较和测试,如innodb plugin 1.03, xtradb5, mysql5.4(dirty_pages_pct=75), mysql5.4(dirty_pages_pct=15) 等等。不知道是那些人(包括peter等)为什么一直纠缠这些问题。

这些性能的差异是显而易见的,主要是因为5.4中增加的几个google补丁,对io和后台写脏数据到表空间进行的优化。剩下的影响最大的要数dirty_pages_pct了。原则上是越大性能越好,如果大部分是小记录的话,那么1个page的脏数据可涵盖很多个事务,这样ib_logfile中后面出现的数据被提前写入表空间的比率在dirty_pages_pct大的时候概率要大得多,这就是测试结果中显示,在脏数据比例设置较大的时候,高负载的情况下性能有明显提升的原因。

我不知道是他们不懂,还是故意去做些纠缠,吸引后来者的眼球。

再给下我之前在taobao dba team上有关这个参数设置的回复,看来很多人都没明白。
http://rdc.taobao.com/blog/dba/html/221_innodb_max_dirty_pages_pct_checkpoint.html

谭俊青 MySQL