概述
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("%Yt %20st Connection ID: %d t Database: %s t Query: %sn",
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 %-8sn", "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 %dn",
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 %dn",
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
标签:using mod var uek strong meta ble record dtrace
本条技术文章来源于互联网,如果无意侵犯您的权益请点击此处反馈版权投诉
本文系统来源:http://www.cnblogs.com/zengkefu/p/6351673.html
最后
以上就是传统大山为你收集整理的mysql dtrace_MySQL 5.6.20-4 and Oracle Linux DTrace的全部内容,希望文章能够帮你解决mysql dtrace_MySQL 5.6.20-4 and Oracle Linux DTrace所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
发表评论 取消回复