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. ios copy assign retain

    一,retain, copy, assign区别 1. 假设你用malloc分配了一块内存,并且把它的地址赋值给了指针a,后来你希望指针b也共享这块内存,于是你又把a赋值给(assign)了b.此时a ...

  2. HTML5开发手机应用--viewport的作用--20150216

    在用HTML5开发手机应用或手机网页时,<head>部分总会有如下一段代码,这段代码到底什么意思呢.在网上,大家会得到很多答案.我从网上搜集了部分介绍,整理一下,以留备用. <met ...

  3. STL 之 vector的应用

    关于vector vector是C++提供的一个容器,它是一个能够存放任意类型的动态数组,可以随时增加和压缩数据. 使用vector时需要注意以下几点: 1. 如果要表示的向量长度较长(需要为向量内部 ...

  4. 【树形dp】bzoj1304: [CQOI2009]叶子的染色

    又是一道优美的dp Description 给一棵m个结点的无根树,你可以选择一个度数大于1的结点作为根,然后给一些结点(根.内部结点和叶子均可)着以黑色或白色.你的着色方案应该保证根结点到每个叶子的 ...

  5. [LUOGU] P1551 亲戚

    题目背景 若某个家族人员过于庞大,要判断两个是否是亲戚,确实还很不容易,现在给出某个亲戚关系图,求任意给出的两个人是否具有亲戚关系. 题目描述 规定:x和y是亲戚,y和z是亲戚,那么x和z也是亲戚.如 ...

  6. nginx常用功能配置

    一.规范优化nginx配置文件 nginx的主配置文件为nginx.conf,主配置文件包含的所有虚拟主机的子配置文件会统一放入extra目录中,虚拟主机的配置文件按照网站的域名或功能取名,例如www ...

  7. 【http】http协议的队首阻塞

    1 队首阻塞 就是需要排队,队首的事情没有处理完的时候,后面的人都要等着. 2 http1.0的队首阻塞 对于同一个tcp连接,所有的http1.0请求放入队列中,只有前一个请求的响应收到了,然后才能 ...

  8. 第一章 pyhton基础

    一 .pyhton2与python3的区别 在pyhton2中,其中编码默认使用的是ascii编码,输出格式为print"xxx",输入为raw_input(“请输入”),在整型中 ...

  9. (转)git clone: error: RPC failed; result=18, HTTP code = 200 解决办法

    git clone: error: RPC failed; result=18, HTTP code = 200 解决办法 分类: git2013-09-01 17:03 10753人阅读 评论(2) ...

  10. i.mx53开发的一些问题

    i.mx53开发的一些问题 转载于此:http://blog.csdn.net/shell_albert/article/details/8242288   原来i.mx53上4GB的Nand Fla ...