- CentOS 6.3
- perl 5.10.1
- MySQL 5.5.30
MySQL、fluent-agent-lite、td-agent全てlocalhostで動かしている
- fluent-agent-lite
https://github.com/tagomoris/fluent-agent-lite
-
td-agent(CentOS版)
http://help.treasure-data.com/kb/installing-td-agent-daemon/installing-td-agent-for-redhat-and-centos -
fluent-plugin-mysqlslowquerylog
https://github.com/studio3104/fluent-plugin-mysqlslowquerylog
git clone [email protected]:tagomoris/fluent-agent-lite.git
cd fluent-agent-lite/bin
./install.sh
vi /etc/fluent-agent-lite.conf
TAG_PREFIX="mysql"
LOGS=$(cat <<"EOF"
slowlog.db01 /var/lib/mysql/mysqld-slow.log
EOF
)
PRIMARY_SERVER="localhost:24224"
/etc/init.d/fluent-agent-lite start
touch /etc/yum.repos.d/td.repo
vi /etc/yum.repos.d/td.repo
[treasuredata]
name=TreasureData
baseurl=http://packages.treasure-data.com/redhat/$basearch
gpgcheck=0
yum update
yum install td-agent
/usr/lib/fluent/ruby/bin/fluent-gem install fluent-plugin-mysqlslowquerylog
vi /etc/td-agent/td-agent.conf
<source>
type forward
</source>
<match mysql.slowlog.*>
type mysqlslowquerylog
add_tag_prefix cocatenated.
</match>
<match cocatenated.mysql.slowlog.*>
type file
path /tmp/slowtest
</match>
/etc/init.d/td-agent start
正しく動いていれば、/tmp
の下にslowtest.20130430.*
というようなログが出る。
中を見ると、下記のような感じでログが出ている。
2013-04-30T21:57:28+09:00 cocatenated.mysql.slowlog.db1 {"user":"root[root]","host":"localhost","query_time":0.000376,"lock_time":9.2e-05,"rows_sent":30,"rows_examined":30,"sql":"SET timestamp=1367326648; select * from customers;"}
2013-04-30T21:58:17+09:00 cocatenated.mysql.slowlog.db1 {"user":"root[root]","host":"localhost","query_time":0.000384,"lock_time":9.7e-05,"rows_sent":30,"rows_examined":30,"sql":"SET timestamp=1367326697; select * from customers;"}
2013-04-30T22:05:24+09:00 cocatenated.mysql.slowlog.db1 {"user":"root[root]","host":"localhost","query_time":0.000393,"lock_time":9.8e-05,"rows_sent":30,"rows_examined":30,"sql":"SET timestamp=1367327124; select * from customers;"}