実戦zabbix 3.0.2 percona mysqlプラグインを使用してmysql 5.7を監視

5081 ワード

1.システム環境
[root@shard0 templates]# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.2 (Maipo)

2.インストールに必要なソフトウェアzabbix-agent php-mysqlをダウンロードする
wget http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-agent-3.2.7-1.el7.x86_64.rpm

rpm -i zabbix-agent-3.2.7-1.el7.x86_64.rpm

yum install php  php-mysql 

[root@shard0 zabbix]# rpm -qa zabbix-agent php php-mysql
php-5.4.16-42.el7.x86_64
php-mysql-5.4.16-42.el7.x86_64
zabbix-agent-3.2.7-1.el7.x86_64

3.インストールperconaのダウンロード
wget https://www.percona.com/downloads/percona-monitoring-plugins/1.1.6/percona-zabbix-templates-1.1.6-1.noarch.rpm

rpm -i percona-zabbix-templates-1.1.6-1.noarch.rpm

#         scripts:      templates:    
[root@shard0 templates]# cd /var/lib/zabbix/percona
[root@shard0 percona]# ll
total 4
drwxr-xr-x. 2 root root   68 Mar 15 01:17 scripts
drwxr-xr-x. 2 root root 4096 Mar 15 01:17 templates

[root@shard0 percona]# ll scripts/
total 64
-rwxr-xr-x. 1 root root  1251 Jan 11  2016 get_mysql_stats_wrapper.sh
-rwxr-xr-x. 1 root root 59640 Jan 11  2016 ss_get_mysql_stats.php
[root@shard0 percona]# ll templates/
total 284
-rw-r--r--. 1 root root  18866 Jan 11  2016 userparameter_percona_mysql.conf
-rw-r--r--. 1 root root 269258 Jan 11  2016 zabbix_agent_template_percona_mysql_server_ht_2.0.9-sver1.1.6.xml

/var/lib/zabbix/percona/scripts/ディレクトリでは、shのスクリプトはMySQLステータスの取得を監視し、phpファイルは接続データベースのユーザー名パスワードを構成します.
/var/lib/zabbix/percona/templates/ディレクトリ、confファイルはagent側/etc/zabbix/zabbix/zabbix_Agentd.d/以下、XMLファイルはテンプレートファイルです.
4.mysqlを監視する管理アカウントの作成
my3306->GRANT SELECT, PROCESS, SUPER, REPLICATION CLIENT ON *.* TO 'zabbix'@'localhost' IDENTIFIED BY "123456";         
                   
my3306->flush privileges;
Query OK, 0 rows affected (0.00 sec)

5.ss_を修正するget_mysql_stats.phpプロファイル
[root@shard0 scripts]# cd var/lib/zabbix/percona/scripts
[root@shard0 scripts]# vim ss_get_mysql_stats.php 

6.監視スクリプトの変更
#1           ,    rm    
vim /tmp/localhost-mysql_cacti_stats.txt
chown -R zabbix.zabbix /tmp/$HOST-mysql_cacti_stats.txt 

#2   MySQL   3306,        ,   3317  
vim /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh
CACHEFILE="/tmp/$HOST-mysql_cacti_stats.txt "
  :
CACHEFILE="/tmp/$HOST-mysql_zabbix_stats.txt:3317"

TIMEFLM=`stat -c %Y /tmp/$HOST-mysql_cacti_stats.txt`
  :
TIMEFLM=`stat -c %Y /tmp/$HOST-mysql_zabbix_stats.txt:3317 

#3   mysql      ,     MySQL     ,       /u01/MySQL5.7/bin

#RES=`HOME=~zabbix mysql -e 'SHOW SLAVE STATUS\G' | egrep '(Slave_IO_Running|Slave_SQL_Running):' | awk -F: '{print $2}' | tr '
' ','` : RES=`/u01/MySQL5.7/bin -u root -e 'SHOW SLAVE STATUS\G' | egrep '(Slave_IO_Running|Slave_SQL_Running):' | awk -F: '{print $2}' | tr '
' ','`

7.パラメータファイルの変更/etc/my.cnf
      6     mysql -uroot       :
  /u01/MySQL5.7/bin  -u root -pxxxx -e 'SHOW SLAVE STATUS\G'
         ,Warning: Using a password on the command line interface can be insecure.
    zabbix           !

 #    :
 vim /etc/my.cnf

[mysql]    
user=your_backup_user_name    
password=your_backup_password     

8.パラメータファイルのコピー
cp /var/lib/zabbix/percona/templates/userparameter_percona_mysql.conf /etc/zabbix/zabbix_agentd.d/

9.zabbix_の変更Agentプロファイル
[root@shard0 zabbix]# cd /etc/zabbix/
[root@shard0 zabbix]# vi zabbix_agentd.conf 

Server=172.253.32.79

ServerActive=172.253.32.79

Hostname=DESKTOP-4O8JRR9

    :

Server:  zabbix server ip  ,

ServerActive: zabbix     server ip  ,

  Server ServerActive   zabbix Server IP  ,    ,          。    Server         
172.253.32.79  ip      。 ServerActive 172.253.32.79    ,           。

Hostname    ,    ,     。Hostname   zabbix web      ,  zabbix          。
  agent         server,          ?server              ,      。

zabbix agent      (agent active)   (agent)    ,             agent    。

  :agent  server          ,                  server/proxy

  :server agent          ,agent    。

10.zabbix_を再起動agent
[root@shard0 zabbix]# systemctl restart zabbix-agent

11.テンプレートファイルをダウンロードし、zabbixサーバ側にインポートします.
wget https://www.percona.com/downloads/percona-monitoring-plugins/1.1.6/percona-monitoring-plugins-1.1.6.tar.gz

12.エラーのインポート
    :
 zabbix_agent_template_percona_mysql_server_ht_2.0.9-sver1.1.7.xml  zabbix2.4    。       xml  
 3.2     。

          share ,   :https://download.csdn.net/download/chinesern/10472518

13.Received value [sh:/var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh: Permission denied] is not suitable for value type [Numeric (float)]
#    
vi /etc/selinux/config  
#SELINUX=enforcing           
  SELINUX=disabled
SELINUXTYPE=targeted     


#       
setenforce 0