anemometer安装
1.背景介绍:
nginx:1.9.3 安装路径/data/nginx
php:5.5.27 安装路径 /data/php
mysql:5.7.18 安装路径/usr/local/mysql
软件下载目录 /usr/local/src
2.nginx安装
# yum install pcre*
# yum install openssl*
# yum install openssl-devel
# cd /usr/local/src
# wget http://nginx.org/download/nginx-1.9.3.tar.gz
# tar -zxvf nginx-1.9.3.tar.gz
# cd nginx-1.9.3
# ./configure --prefix=/data/nginx \
--with-http_ssl_module --with-http_spdy_module \
--with-http_stub_status_module \
--with-pcre
# make && make install
# ln –s /data/nginx /usr/local/nginx
# mkdir /data/nginx/sites-enabled
# cd /data/nginx/conf
# vi nginx.conf
#在http{}内,server前添加以下内容
include /usr/local/nginx/sites-enabled/*.conf;
# vi /data/nginx/conf/fcgi.conf
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param REDIRECT_STATUS ;
# cd /data/nginx/sites-enabled
# vi hdqa.anemometer.com.conf
#for dba-test-hzj01.qa.hengjs.com
log_format anemometer '$http_x_real_ip - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" $http_x_forwarded_for' '"$request_time"';
access_log /usr/local/nginx/logs/access_anemometer.log anemometer;
server
{
listen ;
server_name dba-test-hzj01.qa.hengjs.com;
if ($http_user_agent ~* "(Googlebot|Baiduspider|Sosospider)" ) {
return ;
}
root /var/www/html/anemometer/;
index index.php;
location ~ "\.(js|ico|gif|jpg|png|css)$" {
expires 1w;
}
location / {
fastcgi_ignore_client_abort on;
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
include fcgi.conf;
index index.php;
if (!-e $request_filename) {
rewrite . /index.php last;
break;
}
}
}
检查下配置是否有问题:
/usr/local/nginx/sbin/nginx -t
启动nginx
/usr/local/nginx/sbin/nginx
3.php安装
# yum install gcc make gd-devel libjpeg-turbo-devel libpng-devel libxml2-devel bzip2-devel libcurl-devel –y
# cd /etc/yum.repos.d/
# wget http://www.atomicorp.com/installers/atomic
# bash atomic
# yum install php-mcrypt -y
# yum install libmcrypt -y
# yum install libmcrypt-devel -y
# ./configure --prefix=/data/php \
--enable-fpm \
--with-fpm-user=daemon \
--with-fpm-group=daemon \
--with-config-file-path=/usr/local/php/etc \
--with-mysql=mysqlnd \
--with-mysqli=mysqlnd \
--with-pdo-mysql=mysqlnd \
--with-iconv \
--with-iconv-dir \
--with-freetype-dir \
--with-jpeg-dir \
--with-png-dir \
--with-gd \
--with-zlib \
--with-libxml-dir \
--with-curl \
--with-mhash \
--with-xmlrpc \
--with-mcrypt \
--with-openssl \
--enable-xml \
--disable-rpath \
--enable-bcmath \
--enable-shmop \
--enable-sysvsem \
--enable-inline-optimization \
--enable-mbregex \
--enable-mbstring \
--enable-gd-native-ttf \
--enable-ftp \
--enable-pcntl \
--enable-sockets \
--enable-zip \
--enable-soap \
--disable-debug \
--disable-ipv6 \
--with-gettext \
--enable-calendar \
--enable-dom
# make && make install
# ln –s /data/php /usr/local/php
# vi /etc/profile #添加变量
export PHP_HOME=/usr/local/php
export PATH=$PATH:$PHP_HOME/bin
# source /etc/profile
# cd /usr/local/src/php-5.5.27
# cp -rf sapi/fpm/php-fpm.conf /usr/local/php/etc/
# cp -rf sapi/fpm/init.d.php-fpm /etc/init.d/php-fpm
# cp -rf php.ini-production /usr/local/php/etc/php.ini
# echo "/etc/init.d/php-fpm start">>/etc/rc.local
# cd /usr/local/php/etc
# echo ";error_log = /usr/local/php/var/log/php-fpm.log
;log_level = notice
;emergency_restart_threshold = 10
;emergency_restart_interval = 1m
;process_control_timeout = 5
;daemonize = yes
;listen.owner = daemon
;listen.group = daemon
;listen.mode = 0666
;pm = dynamic
;pm.max_children = 256
;pm.min_spare_servers = 128
;pm.max_spare_servers = 256
;pm.max_requests = 1024(*)
;request_terminate_timeout = 600s(*)
;request_slowlog_timeout = 300s
;rlimit_files = 65536
;rlimit_core = 65536">> php-fpm.conf
# vi /usr/local/php/etc/php.ini
max_execution_time =
memory_limit = 128M
post_max_size = 16M
upload_max_filesize = 2M
max_input_time =
date.timezone = PRC
vi /etc/php.ini
[Date]
date.timezone = Asia/Chongqing
[MySQLi]
extension=php_mysqli.dll
extension=mysqli.so
#启动php
# /etc/init.d/php-fpm start
4.安装mysql server
(略)
5.安装anemometer
wget http://www.percona.com/downloads/percona-toolkit/2.2.12/deb/percona-toolkit_2.2.12.tar.gz
#安装pt工具
tar zxf percona-toolkit_2.2.12.tar.gz
cd percona-toolkit_2.2.12
perl Makefile.PL
make && make install
ln -s /usr/local/bin/pt-visual-explain /usr/bin/pt-visual-explain
#安装anemometer
unzip Anemometer-master.zip
mv Anemometer-master /var/www/html/anemometer
mysql -uroot -p</var/www/html/anemometer/mysql56-install.sql
mysql -uroot -p </var/www/html/anemometer/install.sql
mysql -uroot -p </var/www/html/anemometer/mysql56-save_history.sql
grant all on slow_query_log.* to 'anemometer'@'%' identified by '123456';
cd /var/www/html/anemometer/conf
mv sample.config.inc.php config.inc.php (修改此文件,可以实现很多定制化的功能)
$conf['datasources']['localhost'] = array(
'host' => 'localhost',
'port' => ,
'db' => 'slow_query_log',
'user' => 'anemometer',
'password' => '',
'tables' => array(
'global_query_review' => 'fact',
'global_query_review_history' => 'dimension'
),
'source_type' => 'slow_query_log'
);
...
$conf['plugins'] = array(
'visual_explain' => '/usr/bin/pt-visual-explain',
# percona toolkit has removed query advisor
# 'query_advisor' => '/usr/bin/pt-query-advisor',
'show_create' => true,
'show_status' => true,
'explain' => function ($sample) {
$conn = array();
if (!array_key_exists('hostname_max',$sample) or strlen($sample['hostname_max']) < )
{
return;
}
$pos = strpos($sample['hostname_max'], ':');
if ($pos === false)
{
$conn['port'] = ;
$conn['host'] = $sample['hostname_max'];
}
else
{
$parts = preg_split("/:/", $sample['hostname_max']);
$conn['host'] = $parts[];
$conn['port'] = $parts[];
}
$conn['db'] = 'mysql';
if ($sample['db_max'] != '')
{
$conn['db'] = $sample['db_max'];
}
$conn['user'] = 'anemometer';
$conn['password'] = '';
return $conn;
},
);
vi /var/www/html/anemometer/lib/Anemometer.php
$timezone = ini_get('date.timezone','Asia/Shanghai');
6.启动访问
/etc/init.d/php-fpm start
/usr/local/nginx/sbin/nginx -s reload
http://172.16.59.97:8082
7.采集服务器部署
安装pt软件
# yum install perl-Digest-MD5
# wget https://www.percona.com/downloads/percona-toolkit/2.2.15/tarball/percona-toolkit-2.2.15.tar.gz
# tar zxvf percona-toolkit-2.2.15.tar.gz
# cd percona-toolkit-2.2.15
# perl Makefile.PL install
# make && make install
# ln -s /usr/local/bin/pt-visual-explain /usr/bin/pt-visual-explain
创建anemometer用户:
mysql> GRANT SELECT ON *.* TO 'anemometer'@'172.16.59.97' identified by '123456';
Query OK, 0 rows affected (0.01 sec)
mysql> GRANT ALL PRIVILEGES ON `slow_query_log`.* TO 'anemometer'@'172.16.59.97';
Query OK, 0 rows affected (0.02 sec)
部署采集脚本:
# vi /home/mysql/bin/collect_slow_log.sh
echo "begin "`date`
/usr/local/bin/pt-query-digest --user=anemometer --password=123456 --socket=/tmp/mysql.sock --port=43306 --since=24h --review h='172.16.59.97',D=slow_query_log,t=global_query
_review --history h='172.16.59.97',D=slow_query_log,t=global_query_review_history --no-report --limit=0% --filter=" \$event->{Bytes} = length(\$ev
ent->{arg}) and \$event->{hostname}=\"$HOSTNAME\"" /data/mysql/log/mysql-slow.log
echo "end "`date`
chown -R mysql.mysql /home/mysql/bin/collect_slow_log.sh
chmod a+x collect_slow_log.sh
# 定时任务
10 2 * * * /home/mysql/bin/collect_slow_log.sh >>/home/mysql/log/collect_slow_log.log 2>&1
8.碰到的问题
Can't locate ExtUtils/MakeMaker.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at Makefile.PL line 1.
BEGIN failed--compilation aborted at Makefile.PL line 1.
解决办法:
yum install perl-ExtUtils-CBuilder perl-ExtUtils-MakeMaker
/usr/local/bin/pt-query-digest
Can't locate Digest/MD5.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /usr/local/bin/pt-query-digest line 2434.
BEGIN failed--compilation aborted at /usr/local/bin/pt-query-digest line 2434.
解决办法:
yum -y install perl-Digest-MD
anemometer安装的更多相关文章
- Box Anemometer
https://sourceforge.net/projects/pydev/files/pydev/ Eclipse + Pydev 配置Python开发环境 JDK安装http://jingyan ...
- 关于Box Anemometer的安装配置遇到的几个坑
Box Anemometer是一个非常不错的MySQL慢查询可视化工具平台,具体就不多详述了,官网是https://github.com/box/Anemometer 最近动自己动手搭了一个,具体搭建 ...
- 【转载】 使用Anemometer基于pt-query-digest将MySQL慢查询可视化
原文地址:使用Anemometer基于pt-query-digest将MySQL慢查询可视化 作者:84223932 本文主要介绍使用Anemometer基于pt-query-digest将MySQL ...
- 使用Anemometer基于pt-query-digest将MySQL慢查询可视化
最近玩MySQL,发现了一个很不错的工具,可以把MySQL慢查询可视化,方便我们去找出和分析慢询语句,搭建的步骤不多,但网上详细教程比较少,说得也不够详细,一不小心,估计得蛋痛一会,哈哈 Percon ...
- 使用Anemometer分析MySQL慢查询记录
数据库管理员一般是用percona的toolkit工具来分析MySQL慢查询记录,但是不够直观. 下面介绍一款比较直观的工具来统计分析MySQL慢查询记录anemometer. 在使用之前需要安装pe ...
- MySQL慢日志简介及Anemometer工具介绍
作者:王航威 - fordba.com 来源:http://fordba.com/box-anemometer-visual-mysql-slow.html,叶师傅对原文内容略有调整 备注:王航威是知 ...
- 十分钟部署Anemometer作为Mysql慢查询可视化系统
前言 采用Anemometer将Mysql慢查询日志可视化,可以更便捷的查询慢查询日志,并根据时间戳进行历史查询.如下是单机版Anemometer部署的演示,实际应用中,为安全起见,建议把anemom ...
- docker——容器安装tomcat
写在前面: 继续docker的学习,学习了docker的基本常用命令之后,我在docker上安装jdk,tomcat两个基本的java web工具,这里对操作流程记录一下. 软件准备: 1.jdk-7 ...
- 网络原因导致 npm 软件包 node-sass / gulp-sass 安装失败的处理办法
如果你正在构建一个基于 gulp 的前端自动化开发环境,那么极有可能会用到 gulp-sass ,由于网络原因你可能会安装失败,因为安装过程中部分细节会到亚马逊云服务器上获取文件.本文主要讨论在不变更 ...
随机推荐
- vue mock
如果后端不肯来帮你 mock 数据的话,前端自己来 mock 也是很简单的.你可以使用mock server 或者使用 mockjs + rap 也是很方便的. 不久前出的 easy-mock也相当的 ...
- spring mvc 参数绑定
基础类型 原始类型:id必须要传,否则报错. @RequestMapping("/test") @ResponseBody public ResponseData test(int ...
- 9. maps
C++有vertor,java有HashMap,C语言想使用则需要自行封装,不同的类型还需要再封装,特别麻烦. 看看Go语言的map的使用方法:var member map[string]int,创建 ...
- CentOS7 PHP+Redis实现Session共享
先yum简单的安装redis wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/epel-7.repo ...
- PCA降维参数介绍
https://www.cnblogs.com/pinard/p/6243025.html#undefined
- java基础 ----- 程序的调试
--- -- 什么是程序调试 当程序出错时,我们希望可以这样 逐条语句执行程序 ----- 观察程序的执行情况 ------ 发现问题 ----- 解决问题 但是,程序一闪就运行结束 ...
- spring aop做什么介绍
1.AOP(Aspect Orient Programming),称为面向切面编程,它作为面向对象(OOP)的一种补充,用于处理系统中分布于各个模板的横切关注点,比如事务管理.日志.缓存等.AOP实现 ...
- CentOS7 Failed to start LSB: Bring up/down解决方法
刚刚装好的虚拟机突然不能上网了,报错很诡异,具体报错如下: /etc/init.d/network restart Restarting network (via systemctl): Job f ...
- windows server 2012 FTP连接报530 User 用户名 cannot log in home directory inaccessible的解决方法
我最近在创建个人网站,经过了万网购买域名注册(www.lingcup.xyz ,www.lingcup.com),在主机屋购买免费云服务器(ip是49.4.142.41),域名别名解析(cname)到 ...
- boost多线程入门介绍
:first-child { margin-top: 0px; } .markdown-preview:not([data-use-github-style]) h1, .markdown-previ ...