https://blogs.oracle.com/wim/entry/mysql_5_6_20_4?utm_source=tuicool&utm_medium=referral

By WimCoekaerts-Oracle on Jul 31, 2014

The MySQL team just released MySQL 5.6.20. One of the cool new things for Oracle Linux users is the addition of MySQL DTrace probes. When you use Oracle Linux 6, or 7 with UEKr3 (3.8.x) and the latest DTrace utils/tools, then you can make use of this. MySQL 5.6 is available for install through ULN or from public-yum. You can just install it using yum.

# yum install mysql-community-server

Then install dtrace utils from ULN.

# yum install dtrace-utils

As root, enable DTrace and allow normal users to record trace information:

# modprobe fasttrap
# chmod 666 /dev/dtrace/helper

Start MySQL server.

# /etc/init.d/mysqld start

Now you can try out various dtrace scripts. You can find the reference manual for MySQL DTrace support here.

Example1

Save the script below as query.d.

#!/usr/sbin/dtrace -qws
#pragma D option strsize=1024 mysql*:::query-start /* using the mysql provider */
{ self->query = copyinstr(arg0); /* Get the query */
self->connid = arg1; /* Get the connection ID */
self->db = copyinstr(arg2); /* Get the DB name */
self->who = strjoin(copyinstr(arg3),strjoin("@",
copyinstr(arg4))); /* Get the username */ printf("%Y\t %20s\t Connection ID: %d \t Database: %s \t Query: %s\n",
walltimestamp, self->who ,self->connid, self->db, self->query); }

Run it, in another terminal, connect to MySQL server and run a few queries.

# dtrace -s query.d
dtrace: script 'query.d' matched 22 probes
CPU ID FUNCTION:NAME
0 4133 _Z16dispatch_command19enum_server_commandP3THDPcj:query-start 2014
Jul 29 12:32:21 root@localhost Connection ID: 5 Database:
Query: select @@version_comment limit 1 0 4133 _Z16dispatch_command19enum_server_commandP3THDPcj:query-start 2014
Jul 29 12:32:28 root@localhost Connection ID: 5 Database:
Query: SELECT DATABASE() 0 4133 _Z16dispatch_command19enum_server_commandP3THDPcj:query-start 2014
Jul 29 12:32:28 root@localhost Connection ID: 5 Database: database
Query: show databases 0 4133 _Z16dispatch_command19enum_server_commandP3THDPcj:query-start 2014
Jul 29 12:32:28 root@localhost Connection ID: 5 Database: database
Query: show tables 0 4133 _Z16dispatch_command19enum_server_commandP3THDPcj:query-start 2014
Jul 29 12:32:31 root@localhost Connection ID: 5 Database: database
Query: select * from foo

Example 2

Save the script below as statement.d.

#!/usr/sbin/dtrace -s

#pragma D option quiet

dtrace:::BEGIN
{
printf("%-60s %-8s %-8s %-8s\n", "Query", "RowsU", "RowsM", "Dur (ms)");
} mysql*:::update-start, mysql*:::insert-start,
mysql*:::delete-start, mysql*:::multi-delete-start,
mysql*:::multi-delete-done, mysql*:::select-start,
mysql*:::insert-select-start, mysql*:::multi-update-start
{
self->query = copyinstr(arg0);
self->querystart = timestamp;
} mysql*:::insert-done, mysql*:::select-done,
mysql*:::delete-done, mysql*:::multi-delete-done, mysql*:::insert-select-done
/ self->querystart /
{
this->elapsed = ((timestamp - self->querystart)/1000000);
printf("%-60s %-8d %-8d %d\n",
self->query,
0,
arg1,
this->elapsed);
self->querystart = 0;
} mysql*:::update-done, mysql*:::multi-update-done
/ self->querystart /
{
this->elapsed = ((timestamp - self->querystart)/1000000);
printf("%-60s %-8d %-8d %d\n",
self->query,
arg1,
arg2,
this->elapsed);
self->querystart = 0;
}

Run it and do a few queries.

# dtrace -s statement.d
Query RowsU RowsM Dur (ms)
select @@version_comment limit 1 0 1 0
SELECT DATABASE() 0 1 0
show databases 0 6 0
show tables 0 2 0
select * from foo 0 1 0

MySQL 5.6.20-4 and Oracle Linux DTrace的更多相关文章

  1. mysql server advanced 5.6基于oracle linux 6.6的安装

    mysql 安装有两种,rpm安装和源码包安装,两种包都可以从www.mysql.com官网下载,这次我测试下rpm安装方式. 1.安装环境以及mysql版本: 1.1vcenter 虚拟机环境 1. ...

  2. oracle linux dtrace

    http://docs.oracle.com/cd/E37670_01/E38608/html/pref.html

  3. 在 Oracle Linux 上使用 DTrace

    作者:Richard Friedman 简要介绍适用于 Oracle Linux 的 DTrace 探测器和提供程序,以及与 Oracle Solaris 中 DTrace 探测器和提供程序的区别.还 ...

  4. 在Oracle Linux上安装dtrace

    http://www.ohsdba.cn/index.php?g=Home&m=Article&a=show&id=171   时间: 2016-10-09 00:40:04 ...

  5. oracle linux 7.3 下用dtrace 跟踪 mysql-community-server-5.6.20

    第一部分:oracle linux 7.3 dtrace 安装: http://public-yum.oracle.com/   内核升极到 [root@server1 SPECS]# uname - ...

  6. linux MySQL 5.7.20安装教程

    安装MySQL 5.7.20shell> cd /usr/localshell> groupadd mysqlshell> useradd -g mysql mysqlshell&g ...

  7. Setup JIRA Service Desk 3.9.2 on Oracle Linux 6.8

    OS Oracle Linux 6.8 V138414-01.iso Database mysql5.6.30 MySQL-5.6.30-1.el6.x86_64.rpm-bundle.tar JIR ...

  8. Oracle Linux(64位)安装64位Oracle10g遇到ins_ctx.mk问题

    在Oracle Linux Server Release 5.7上安装64位Oracle 10g 时,遇到如下问题: Error in invoking target 'install' of mak ...

  9. 在Oracle Linux Server release 6.4下配置ocfs2文件系统

    ① 安装ocfs-tools-1.8 如果是使用RedHat Enterprise Linux 6.4,也可以安装ocfs-tools-1.8的,只是要插入Oracle Linux Server re ...

随机推荐

  1. js和JQuery中的获取宽、高、位置等方法整理

    1.获取当前窗口宽度区别(需要注意的是用的window还是document)JQuery:console.log($(window).width()); //获取窗口可视区域的宽度 console.l ...

  2. CSS3-transform-style

    transform-style属性 transform-style属性是3D空间一个重要属性,指定嵌套元素如何在3D空间中呈现.他主要有两个属性值:flat和preserve-3d. transfor ...

  3. Shell中各种括号的作用

    一.小括号,圆括号() 1.单小括号 () ① 命令组.括号中的命令将会新开一个子shell顺序执行,所以括号中的变量不能够被脚本余下的部分使用.括号中多个命令之间用分号隔开,最后一个命令可以没有分号 ...

  4. Python对Dict排序

    对下面的Dict: aps = {} for key in T.keys(): ap = average_precision(T[key], P[key]) aps[key] = ap 如果用valu ...

  5. ASP.NET使用Memcached高缓存实例的初级介绍

    Memcached 是一个高性能的分布式内存对象缓存系统,用于动态Web应用以减轻数据库负载.它通过在内存中缓存数据和对象来减少读取数据库的次数,从而提供动态.数据库驱动网站的速度.Memcached ...

  6. Python9-day11-作业

    # 1.编写装饰器,为多个函数加上认证的功能(用户的账号密码来源于文件),# 要求登录成功一次,后续的函数都无需再输入用户名和密码 FLAG = False def login(func): def ...

  7. eclipse去除js(JavaScript)验证错误

    第一步: 去除eclipse的JS验证: 将windows->preference->Java Script->Validator->Errors/Warnings-> ...

  8. JavaScript正则表达式-边界符

    ^:表示字符串开始位置,在多行匹配中表示一行的开始位置. /^\w+/匹配字符串中第一个单词. $:表示字符串结束的位置,在多行匹配中表示一行的结束位置. /\w+$/匹配字符串中最后一个单词. /@ ...

  9. java中ArrayList、LinkedList、Vector的区别

    ArrayList.LinkedList.Vector这三个类都实现了List接口. ArrayList是一个可以处理变长数组的类型,可以存放任意类型的对象.ArrayList的所有方法都是默认在单一 ...

  10. Virtualbox虚拟机相关

    Virtualbox虚拟机相关 Virtualbox是我一直使用的虚拟机,由于需要一些测试环境等,会经常使用多个虚拟机.经常捣腾.之前有涉及到一些virtualbox方面的问题的处理,并没有记录下来, ...