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. awk纯干货

    AWK的惊人表现: Awk设计的目的:简化一般文本处理的工作. 属于POSIX的一部分. AWK命令行: Awk的调用可以定义变量.提供程序并且指定输入文件: Awk [ -F fs ]  [ -v ...

  2. Ubuntu sudo 出现 is not in the sudoers file解决方案

    前言: 自己想额外创建一个Linux账户,但是发现新创建的用户(lgq)并不能使用sudo指令. 但是在安装系统时创建的用户(abc)是可以正常使用的. 原因是新创建的用户并没有被赋予使用sudo指令 ...

  3. python--MySQl单表查询

    一.  关键字的执行优先级(重点) from where group by having # 使用是要放在group by 后面而且前面必须有group by select distinct # 去重 ...

  4. C/C++编程之内存管理

    内存分配方式 内存分配方式一共有三种: (1)从静态存储区域分配: 内存在程序编译的时候就已经分配好,这块内存在程序的整个运行期间都存在,例如,全局变量,静态变量. (2)在栈上创建: 在执行函数时, ...

  5. Verilog学习笔记基本语法篇(三)·········赋值语句(待补充)

    在Verilog HDL语言中,信号有两种赋值方式. A)非阻塞赋值(Non-Blocking)方式(如:b<=a;) (1)在语句块中,上面语句所赋值的变量不能立即为下面的语句所用: (2)块 ...

  6. failed to execute goal org.apache.maven.plugins:maven-archetype-plugin错误解决方法

    使用maven创建project时碰到如下错误: D:\codes\JSF>mvn archetype:create -DgroupId=com.tutorialspoint.test -Dar ...

  7. Java的9种基本数据类型以及封装类

    Java的9种基本数据类型以及封装类 基本类型 大小(单位/字节) 默认值 封装类 byte 1 (byte)0 Byte short 2 (short)0 Short int 4 0 Integer ...

  8. log4net.dll配置以及在项目中应用

    1,首先在项目中引用log4net.dll,然后项目中添加一个配置文件log4net.config <?xml version="1.0" encoding="ut ...

  9. Leetcode 327.区间和的个数

    区间和的个数 给定一个整数数组 nums,返回区间和在 [lower, upper] 之间的个数,包含 lower 和 upper.区间和 S(i, j) 表示在 nums 中,位置从 i 到 j 的 ...

  10. numpy array_split()

    numpy.array_split(ary, indices_or_sections, axis=0)[source] Split an array into multiple sub-arrays. ...