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 ,由于网络原因你可能会安装失败,因为安装过程中部分细节会到亚马逊云服务器上获取文件.本文主要讨论在不变更 ...
随机推荐
- java二分法搜索
二分法就是要将数据每次都分成两份然后再去找到你想要的数据 在二分法查找时要求传入的数据必须已经有序,假设现在为升序,然后每次将所寻找的值与中间值(数组左边界+(右边界-左边界)/2)作比较,大了则去寻 ...
- webapi+ajax跨域问题及cookie设置
最近小玩了点东西,发现简单的东西总能遇到点问题 1.webapi跨域设置 [EnableCors(origins: "*", headers: "*", met ...
- java.lang.RuntimeException: Class "org.apache.maven.cli.MavenCli$CliRequest" not found
IDEA版本:14.1 maven版本:apache-maven-3.3.9-bin IDEA的maven项目,在pom文件执行Maven--Reimport,引入jar包依赖,报错java.lang ...
- 多功能网页刷新工具,刷pv工具
多功能网页刷新工具,刷pv工具,在线刷流量,刷PV,刷UV小牛刷新助手功能介绍:1.设置多个刷新网页地址.2.设置刷新时间3.开始工作4.其他操作:老板键:打开时自动刷新:置系统托盘5.可手动输入地址 ...
- ApplicationListener接口的生命周期
create:游戏初次创建时被调用,一般在这里创建ApplicationListener对象,初始化布景信息,将数据或UI布局绑定到监听器等,执行完该方法后会执行resize方法,是游戏创建立即执行的 ...
- Java框架spring 学习笔记(十):bean管理(注解和配置文件混合使用)
配置文件和注解混合使用 创建对象操作使用配置文件方式实现 注入属性的操作使用注解方式实现 编写BookDao.java和OrderDao.java文件 BookDao.java package com ...
- mysql内容总体回顾
数据类型: 数值类型: 整形 浮点型 字符串: char(定长)\varchar(不定长) char(定长):插入数据或查询数据都快,因为char在磁盘上插入数据时的存储空间是固定的,简单粗暴,直接就 ...
- jasper打印文件出现空白页面
EG:打印文件结果打印出一片空白 原因:使用了null的数据源而不是JREmptyDataSource 以下为正确代码 public <T> List<JasperPrint> ...
- Microsoft SQL Server 错误:948
版本655指的是SQL2008, 版本611指的是SQL2005, (还有一个版本539指的是SQL2000) 楼主的情况属于典型的从高版本降低至低版本使用的情景. 按微软的官方说法, 是不支持从高版 ...
- OO_多项式求导_单元总结
概述: 面向对象第一单元的作业是三次难度依次递增的多项式求导.第一次作业是仅包含带符号整数和幂函数的多项式求导,例如:-1+xˆ233-xˆ06:第二次是在前面的基础上增加了三角函数的求导,例如:-1 ...