MySQL 5.6.20-4 and Oracle Linux DTrace

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 [email protected]	  Connection ID: 5 	 Database:
    Query: select @@version_comment limit 1

  0   4133 _Z16dispatch_command19enum_server_commandP3THDPcj:query-start 2014
    Jul 29 12:32:28 [email protected]	  Connection ID: 5 	 Database:
    Query: SELECT DATABASE()

  0   4133 _Z16dispatch_command19enum_server_commandP3THDPcj:query-start 2014
    Jul 29 12:32:28 [email protected]	  Connection ID: 5 	 Database: database
    Query: show databases

  0   4133 _Z16dispatch_command19enum_server_commandP3THDPcj:query-start 2014
    Jul 29 12:32:28 [email protected]	  Connection ID: 5 	 Database: database
    Query: show tables

  0   4133 _Z16dispatch_command19enum_server_commandP3THDPcj:query-start 2014
    Jul 29 12:32:31 [email protected]	  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
时间: 2024-10-13 17:28:54

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

在 Oracle Linux 上使用 DTrace

作者:Richard Friedman 简要介绍适用于 Oracle Linux 的 DTrace 探测器和提供程序,以及与 Oracle Solaris 中 DTrace 探测器和提供程序的区别.还介绍了 DTrace 命令和脚本编写. 2013 年 6 月发布 DTrace 是一个全面的动态跟踪工具,最初是为 Oracle Solaris 操作系统开发的,现在 Oracle Linux 客户也可以使用.DTrace 旨在提供运营洞察力,允许用户实时动态调整和排除操作系统和应用程序故障.DTr

在Oracle Linux上安装dtrace

http://www.ohsdba.cn/index.php?g=Home&m=Article&a=show&id=171 时间: 2016-10-09 00:40:04  | 作者: ohsdba  | English 如非注明,本站文章皆为原创.欢迎转载,转载时请注明出处和作者信息. DTrace(dynamic tracing)是Sun Solaris系统上主要的性能诊断工具,可以对kernel和用户应用程序进行动态跟踪,并且对系统运行不构成任何危险的技术,后被Oracle公

oracle linux 4.8安装oracle 10g rac环境之cluster安装

安装环境: 操作系统:oracle linux 4.8 64位 集群软件:10201_clusterware_linux_x86_64.cpio.gz 数据库:10201_database_linux_x86_64.cpio.gz cpu:1颗 内存:必须1.5G以上(一般是2G) 本地磁盘:20G(根分区17G,swap是4G,boot分区是512M) asm下载地址:http://www.oracle.com/technetwork/server-storage/linux/download

Switching from Redhat Linux to Oracle Linux in about 5,000 easy steps

Wayback When I remember being at Oracle Open World when Larry Ellison unveiled Oracle Enterprise Linux (OEL, which is now just Oracle Linux, or OL).    I think I even have a foam Oracle penguin and maybe even a t-shirt somewhere.  I was trying to und

oracle linux 6.3安装图形界面软件

副标题:oracle linux 6.3无法切换到图形界面处理 1.问题现象 1.1 startx命令不可用 [[email protected] cdrom]# startx -bash: startx: command not found 1.3 init 5无法执行完成 [[email protected] /]#init 5 [[email protected] /]#Calling the system activity data collector(sadc): starting p

Linux操作系统各版本ISO镜像下载(包括oracle linux\redhat\centos\u

Linux操作系统各版本ISO镜像下载(包括oracle linux\redhat\centos\ubuntu\debian等) 2015年2月25日, 下午7:49 1.Oracle Linux(下载地址) (1)OracleLinux-Release6-Update0-x86_64-dvd.iso(2)OracleLinux-Release6-Update1-x86_64-dvd.iso(3)OracleLinux-Release6-Update2-x86_64-dvd.iso(4)Orac

oracle 11g之一 oracle linux 6.5 安装

1.准备安装文件   VirtualBox-5.2.8   Oracle Linux 6.5 iso镜像文件   xmanager5 2.创建虚拟机 VirtualBox-5.2.8的安装略过 2.1 在 菜单 管理->主机网络管理器中设置全局ip,设置与主机ip为同一网段.这里选择host-only的连接方式. 2.2 新建虚拟机 菜单 新建 2.3分配内存 单实例的话两个g就可以了 2.3分配磁盘 2.4选择磁盘类型,默认即可 2.5分配磁盘大小 三 安装Oracle Linux 6.5 3

Quick and Easy Installation of Oracle Database 12c on Oracle Linux in Oracle VM VirtualBox

发贴人 Sergio-Oracle 于2018-4-18 23:10:15在Oracle Linux Introduction How Does This Work? Requirements Before You Get Started Steps Clone the vagrant-boxes repository from GitHub Download Oracle Database Installation Files Place the downloaded Database ins

Oracle Linux Server 6.9下oracle与ogg的挂载

准备工作:打开虚拟机端的Oracle Linux Server 6.9的系统,然后使用root用户登录.打开终端界面,输入ifconfig -a查看IP地址. 然后在本地打开XShell软件使用以下命令进入虚拟机的终端. ssh root@192.168.91.129 192.168.91.129为自己的IP地址.查看硬盘分区 [root@ambition ~]# fdisk -l 得到以下内容:其中/dev/sdb用来挂载oracle,/dev/sdc用来挂载ogg. Disk /dev/sd