How to install and configure Box Anemometer?

Source: Internet
Author: User

How to install and configure Box Anemometer?

Box Anemometer is a very good MySQL slow query visualization tool platform, the specific is not detailed, the official website is https://github.com/box/Anemometer

Recently, I have started a manual setup. For details about the setup process, refer to the instructions on http://www.cnblogs.com/xuanzhi201111/p/4128894.htmland official network.

Here are some of the pitfalls:

1. Resource Planning:

192.168.17.205 Box Anemometer server, install httpd service, php, MySQL service for storing Anemometer slow query data.

For the MySQL server whose 192.168.16.21/22/23/24/25/*** needs to be monitored, install percona-toolkit and configure related script tasks to collect data using pt-query-digest.

2. Installation Process and pitfalls:

2.1. A MySQL5.7.20 service was compiled and installed on 192.168.17.205.

According to the tutorial on the internet, httpd is installed on yum, php is installed on yum, and Anemometer is configured.

An error is reported and the MySQL server cannot be connected. I suspect that the default Mysql client driver for installing php In yum is too low. So re-compile and install php. The compilation configuration is as follows:

./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 --with-apxs2=/usr/sbin/apxs --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 --enable-opcache=no  

The result is still an error and the mysql server cannot be connected. But the error information has changed. The final solution is to disable Selinux.

2.2 authorization of the Anemometer database and user authorization of the monitored database:

2.2.1. the authorization of the MySQL database 192.168.17.205 used by Anemometer to save the collected slow query data is as follows:

GRANT SELECT, UPDATE ON `slow_query_log`.* TO 'app_anemometer_rw'@'localhost'

The corresponding configuration is as follows:

[root@oracle conf]# pwd/var/www/html/anemometer/conf[root@oracle conf]# vi datasource_localhost.inc.php <?php$conf['datasources']['localhost'] = array(        'host'  => '127.0.0.1',        'port'  => 3306,        'db'    => 'slow_query_log',        'user'  => 'app_anemometer_r',        'password' => 'Your@StrongPassword',        'tables' => array(                'global_query_review' => 'fact',                'global_query_review_history' => 'dimension'        ),        'source_type' => 'slow_query_log');

2.2.2. In addition, the database also needs to authorize the script programs of the monitored databases:

GRANT SELECT, INSERT, UPDATE, DELETE ON `slow_query_log`.* TO 'app_anemometer_rw'@'192.168.16.2%'

2.2.3 The Anemometer program must be authorized to access the monitored databases to obtain execution plan and other data:

GRANT SELECT, SUPER ON *.* TO 'app_anemometer_r'@'192.168.17.205'

The corresponding configuration (/var/www/html/anemometer/conf/config. inc. php) is as follows:

3. After configuration, you can finally open the Home Page. However, the SQL length displayed on the home page is too short and only 20 characters long. As a result, you cannot clearly know the query from this list:

You can also modify the/var/www/html/anemometer/conf/config. inc. php file to configure the file:

The default value is the leftmost 20 digits. Change the value to the desired length.

4. Finally, the python script used to collect slow query logs in various MySQL servers is attached:

#!/usr/bin/env python2#-*- coding: utf-8 -*-import subprocessPATH='/bin:/usr/bin'LOG='/log/slow.log'SERVER_HOST='192.168.17.205'DB='slow_query_log'TAB1='global_query_review'TAB2='global_query_review_history'MYSQL_USER='app_anemometer_rw'MYSQL_PASSWD='Your@StrongPassword'hostname='MySQL-M-16-21'print MYSQL_PASSWDcmd='pt-query-digest --user='+MYSQL_USER+' --password='+ MYSQL_PASSWD + ' --port=3306 --review h='+SERVER_HOST+',D='+DB+',t='+TAB1+'  --history h='+SERVER_HOST+',D='+DB+',t='+TAB2 +' --no-report --limit=0% --filter=" \$event->{Bytes} = length(\$event->{arg}) and \$event->{hostname}=\\"'+hostname+'\\"" ' +LOGprint cmdsubprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)

4.1 because the anemometer server uses the hostname defined in the preceding python script to access the monitored servers in turn, it is used to obtain execution plans and other related information.

Therefore, if the hostname is not configured with an Ip address, you must configure the hosts file on the anemometer server 192.168.17.205:

[root@oracle conf]# vi /etc/hosts127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4::1         localhost localhost.localdomain localhost6 localhost6.localdomain6192.168.16.21 MySQL-M-16-21

Link: http://www.cnblogs.com/ajiangg/p/8258926.html

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.