MPM周到监督MySQL

By admin in 美高梅手机版4858 on 2019年7月7日

Zabbix和MPM监控MySQL

  • ##### 情况表明

    A: 192.168.1.190,
    系统CentOS
    6.3,部署Zabbix Server
    B: 192.168.1.191, 系统CentOS 6.3,部署Zabbix Agent, MySQL 5.5.29
    (MySQL Slave)

  • ##### MPM/Zabbix监察和控制结构及配置步骤

    MPM/Zabbix监察和控制结构:

    美高梅手机版4858 1

    MPM/Zabbix监控MySQL的概略步骤如下:

    • 设置配置Zabbix
    • 下载安装MPM(Performance Monitor for MySQL)及其依赖的Perl模块
    • 导入MPM模板
    • 创建host group(可选)
    • 始建host (即MPM agent配置中的database)
      值得注意的是:Hostname必须与MPM agent配置中的所运用的一样
    • 将挑选的模版关联到创建的host
    • 配置MPM agent
    • 将MPM agent”挂钩”到Zabbix agent
      # cat /path_to_zabbix_agent_conf/zabbix_agentd.conf
      UserParameter=FromDual.MySQL.check,/path_to_mpm_agent/FromDualMySQLagent.pl
      \
      /path_to_mpm_agent_conf/FromDualMySQLagent
    • 重启Zabbix agent
  • ##### 安装配置Zabbix

    请参考《安装配置遍及式监察和控制系统Zabbix
    2.06》
    http://www.linuxidc.com/Linux/2013-07/86942.htm

  • ##### MPM下载及其信Ryan装

    MPM(PE福特ExplorerFORMANCE MONITOPRADO FO奥迪Q5 MYSQL)重视的连锁Perl模块安装:

    # yum install perl-File-Which perl-libwww-perl perl-Digest-SHA1 perl-DBD-MySQL perl-Time-HiRes perl-Crypt-SSLeay
    

    下载MPM并解压:

    # wget -c http://www.shinguz.ch/download/mysql_performance_monitor-latest.tar.gz
    # tar zxvf mysql_performance_monitor-latest.tar.gz
    
  • ##### Zabbix Web UI导入MPM模板

    MPM模板:

    # tar zxvf mysql_performance_monitor_templates-0.9.1.tar.gz
    # cd mysql_performance_monitor_templates-0.9.1/xml
    

    在Zabbix Web
    UI导入监察和控制所需的模板(“Configuration”->”Templates”->”Import”):
    Template_FromDual.MySQL.mpm.xml (监察和控制mpm agent本人,那么些必须导入)
    Template_FromDual.MySQL.server.xml
    (监察和控制Linux系统跟数据库使用有关的附加项)
    Template_FromDual.MySQL.process.xml
    (监察和控制各个Linux进度[比如:mysqld,ndbd])
    Template_FromDual.MySQL.mysql.xml (监察和控制MySQL常用状态变量)
    Template_FromDual.MySQL.innodb.xml (监察和控制InnoDB存款和储蓄引擎状态变量)
    Template_FromDual.MySQL.myisam.xml (监察和控制MyISAM存储引擎状态变量)
    Template_FromDual.MySQL.master.xml
    (监察和控制MySQL主从复制的Master状态)
    Template_FromDual.MySQL.slave.xml (监察和控制MySQL主从复制的Slave状态)

    MPM另外用途的模版:
    Template_FromDual.MySQL.ndb.xml (监控MySQL Cluster)
    MPM周到监督MySQL。Template_FromDual.MySQL.galera.xml (监控MySQL Galera Cluster)
    Template_FromDual.MySQL.pbxt.xml (监察和控制PBXT存款和储蓄引擎状态变量)
    Template_FromDual.MySQL.aria.xml (监察和控制Aria存储引擎的状态变量)
    Template_FromDual.MySQL.drbd.xml (监察和控制DRBD设备情状音信)

  • ##### 安装MPM和配置MPM Agent的Zabbix Keys

    安装MPM:

    # tar zxvf mysql_performance_monitor_agent-0.9.1.tar.gz
    # mv mysql_performance_monitor_agent-0.9.1 /usr/local/mysql_performance_monitor-agent
    

    修改FromDualMySQLagent.pl中的zabbix_sender的路径:

    # cd /usr/local/mysql_performance_monitor-agent/
    # sed -i 's|/usr/local/bin|/usr/local/zabbix/bin/|g' FromDualMySQLagent.pl
    

    将MPM Agent的Keys配置加上到Zabbix Agentd配置文件目录中:

    # cd /usr/local/zabbix/etc/zabbix_agentd.conf.d
    # vi FromDual_MySQL_monitoring.conf
    # cat FromDual_MySQL_monitoring.conf 
    
    UserParameter=FromDual.MySQL.check,/usr/local/mysql_performance_monitor-agent/FromDualMySQLagent.pl /usr/local/mysql_performance_monitor-agent/etc/FromDualMySQLagent.conf
    

美高梅手机版4858 2

mysql mpm

美高梅手机版4858 3

 

Paste_Image.png

 

yum install php56w-cli php56w-process php56w-mysqli php56w-memcached
php56w-posix

参照他事他说加以考察文章

cat << _EOF >/etc/php.d/fpmmm.ini
variables_order = “EGPCS”
_EOF

1、形成难题:

美高梅手机版4858 4

1

竭泽而渔:修改php的安顿文件

 

vim /etc/php.ini
  date.timezone = PRC
/etc/init.d/httpd restart

 

测试:

mpm官网:

[root@h01 bin]# /usr/local/fpmmm/bin/fpmmm --config=/usr/local/fpmmm/fpmmm.conf > /dev/null
PHP Warning:  Module 'mbstring' already loaded in Unknown on line 0

1、安装配备Zabbix

2、但是还大概有别的一条报错:

2、MPM(PEXC60FORMANCE MONITO冠道 FOCRUISER MYSQL)依赖的连带Perl模块安装:
# yum install -y perl-File-Which perl-libwww-perl perl-Digest-SHA1
perl-DBD-MySQL perl-Time-HiRes perl-Crypt-SSLeay  zabbix-sender
下载MPM并解压
解压缩软件包后,会发觉有五个文件mysql_performance_monitor_agent-0.9.3.tar.gz和mysql_performance_monitor_templates-0.9.3.tar.gz。
其中mysql_performance_monitor_agent-0.9.3.tar.gz是身处监察和控制机器上的计划音信
mysql_performance_monitor_templates-0.9.3.tar.gz则是要让大家导入到zabbix
server的模板数据。

PHP Warning:  Module 'mbstring' already loaded in Unknown on line 0

wget

tar zxvf mysql_performance_monitor-latest.tar.gz

解决:

server端配置

在/etc/php.ini 中注释
;extension=mbstring.so

3、Zabbix Web UI导入MPM模板
MPM模板:

3、问题:

# tar zxvf mysql_performance_monitor_templates-0.9.1.tar.gz

美高梅手机版4858 5

# sz mysql_performance_monitor_templates-0.9.1.tar.gz

2.png

# cd mysql_performance_monitor_templates-0.9.1/xml
在Zabbix Web
UI导入监察和控制所需的模板(“Configuration”->”Templates”->”Import”):
Template_FromDual.MySQL.mpm.xml (监察和控制mpm agent本身,这一个必须导入)
Template_FromDual.MySQL.server.xml
(监察和控制Linux系统跟数据库使用有关的附加项)
Template_FromDual.MySQL.process.xml
(监察和控制种种Linux进程[比如:mysqld,ndbd])
Template_FromDual.MySQL.mysql.xml (监察和控制MySQL常用状态变量)
Template_FromDual.MySQL.innodb.xml (监察和控制InnoDB存款和储蓄引擎状态变量)
Template_FromDual.MySQL.myisam.xml (监察和控制MyISAM存款和储蓄引擎状态变量)
Template_FromDual.MySQL.master.xml (监察和控制MySQL主从复制的Master状态)
Template_FromDual.MySQL.slave.xml (监察和控制MySQL主从复制的Slave状态)

解决:

MPM其它用途的模版:
Template_FromDual.MySQL.ndb.xml (监控MySQL Cluster)
Template_FromDual.MySQL.galera.xml (监控MySQL Galera Cluster)
Template_FromDual.MySQL.pbxt.xml (监察和控制PBXT存款和储蓄引擎状态变量)
Template_FromDual.MySQL.aria.xml (监察和控制Aria存款和储蓄引擎的状态变量)
Template_FromDual.MySQL.drbd.xml (监察和控制DRBD设备景况新闻)

ln -s /usr/local/zabbix/bin/zabbix_sender  /usr/bin

美高梅手机版4858 6

4、问题:

创立 Host groups,举例随意三个名字:GZNWMySQL
将已有的mysql机器(GZNWX-CASH-DB01)参与到GZNWMySQL组

美高梅手机版4858 7

美高梅手机版4858 8
值得注意的是:Hostname必须与MPM agent配置中的所选拔的一样

3.png

Template_FromDual.MySQL.mpm.xml (监察和控制mpm agent本身,这些必须导入)
Template_FromDual.MySQL.server.xml
(监察和控制Linux系统跟数据库使用相关的附加项)
Template_FromDual.MySQL.mysql.xml (监察和控制MySQL常用状态变量)
Template_FromDual.MySQL.innodb.xml (监察和控制InnoDB存款和储蓄引擎状态变量)
Template_FromDual.MySQL.process.xml
(监察和控制各个Linux过程[比如:mysqld,ndbd])

解决:

将地点的那些5个模板关联到GZNWX-CASH-DB01

[root@h01 fpmmm]# chmod o+r /usr/local/mysql/data/h01.vm.com.pid

美高梅手机版4858 9

5、切记:在web端导入的模板,须求在被监察和控制端fpmmm配置文件中写出该模块,
不然不出数据。

美高梅手机版4858 10

例如:web端监察和控制 master那几个模板,在被监察和控制端的配置文件中也要增加master。


美高梅手机版4858 11

agent端配置

4.png

安装MPM和配置MPM Agent的Zabbix Keys
安装MPM:

6、记录:增加的五个日志权限改为zabbix

 

Template_FromDual.MySQL.mpm.xml (监察和控制mpm agent本身,这几个必须导入)
Template_FromDual.MySQL.server.xml
(监察和控制Linux系统跟数据库使用有关的附加项)
Template_FromDual.MySQL.process.xml
(监控各个Linux进度[比如:mysqld,ndbd])
Template_FromDual.MySQL.mysql.xml (监察和控制MySQL常用状态变量)
Template_FromDual.MySQL.innodb.xml (监察和控制InnoDB存款和储蓄引擎状态变量)
Template_FromDual.MySQL.myisam.xml (监察和控制MyISAM存款和储蓄引擎状态变量)
Template_FromDual.MySQL.master.xml (监察和控制MySQL主从复制的Master状态)
Template_FromDual.MySQL.slave.xml (监察和控制MySQL主从复制的Slave状态)

yum install -y perl-File-Which perl-libwww-perl perl-Digest-SHA1
perl-DBD-MySQL perl-Time-HiRes perl-Crypt-SSLeay  zabbix-sender

MPM另外用途的沙盘:
Template_FromDual.MySQL.ndb.xml (监控MySQL Cluster)
Template_FromDual.MySQL.galera.xml (监控MySQL Galera Cluster)
Template_FromDual.MySQL.pbxt.xml (监察和控制PBXT存款和储蓄引擎状态变量)
Template_FromDual.MySQL.aria.xml (监察和控制Aria存款和储蓄引擎的状态变量)
Template_FromDual.MySQL.drbd.xml (监察和控制DRBD设备意况消息

wget

tar zxvf mysql_performance_monitor-latest.tar.gz

官方网站安装:http://www.fromdual.com/fpmmm-installation-guide

# tar zxvf mysql_performance_monitor_agent-0.9.1.tar.gz
# mv mysql_performance_monitor_agent-0.9.1
/usr/local/mysql_performance_monitor-agent

将MPM Agent的Keys配置丰盛到Zabbix Agentd配置文件中

cat >> /etc/zabbix/zabbix_agentd.conf << EOF
UnsafeUserParameters=1
UserParameter=FromDual.MySQL.check,/usr/local/mysql_performance_monitor-agent/FromDualMySQLagent.pl
/etc/zabbix/FromDualMySQLagent.conf
EOF

配置MPM Agent:
cd /usr/local/mysql_performance_monitor-agent/etc
cp FromDualMySQLagent.conf.template
/etc/zabbix/FromDualMySQLagent.conf

mkdir -p /var/log/zabbix /var/log/zabbix/cache
chown -R zabbix:zabbix /var/log/zabbix /var/log/zabbix/cache
授予zabbix对mysql的pid文件的读权限和MPM日志的权力
chmod o+r /data/mysql/mysql3306/tmp/mysql.pid
touch /var/log/zabbix/FromDualMySQLagent.log
chown -R zabbix:zabbix /var/log/zabbix

修改MPM配置文件
[root@oneproxy-vm zabbix]# cat /etc/zabbix/FromDualMySQLagent.conf

cat /etc/zabbix/FromDualMySQLagent.conf

[default]

# Type of section:
# mysqld for a normal MySQL database
# ndbd for a MySQL cluster
Type = mysqld

# Debug levels are:
# 1 is logging only errors
# 2 is logging errors and warnings (this is the default)
# 3 logs some informations messages as well
# 4 logs everything (for debugging purposes only)

Debug = 2
LogFile = /var/log/zabbix/FromDualMySQLagent.log
# Directory where the Cache files should be written to:
CacheFileBase = /var/log/zabbix/cache/FromDualAgentCache

# If you agent is not located in the same time zone as your server
# TimeShift = +0.0

# Information for MySQL connections:
Username = zabbix
Password = zabbix
MysqlHost = 127.0.0.1
MysqlPort = 3306

# Zabbix Server IP address
ZabbixServer = 192.168.0.22

# If section is disabled
Disabled = false

# Possible modules for databases are:
# process mysql myisam aria innodb pbxt ndb master slave drbd galera
memcache
# Possible modules for servers are:
# mpm server
# Usual modules are
Modules = server mysql innodb process

# Special parameter which is used for module ndb and process
ClusterLog = /var/lib/mysql-cluster/ndb_1_cluster.log
PidFile = /ngbs/data/GZNWX-CASH-DB01.pid

# If you want to use Monitoring as a Service:

# MaaS = on
# Hash = <enter hash value we provide you>
# Methodes are: direct, http, email. Currently only http works
# Methode = http
# Url =

#[db_server]

#Type = mysqld
#Modules = server mysql innodb process

# All MySQL databases here
# Try to avoid section names with spaces!

[GZNWX-CASH-DB01] # This MUST match Hostname in Zabbix!

Type = mysqld

MysqlPort = 3306
Modules = server mysql innodb process
PidFile = /ngbs/data/GZNWX-CASH-DB01.pid

 

# [mysql-5.1.41-ndb-7.0.13] # This MUST match Hostname in Zabbix!
#
# Type = mysqld
#
# MysqlPort = 3306
# Modules = slave
# PidFile = /var/lib/mysql/db_server.pid
# Debug = 0
# Disabled = false

# [mariadb-5.2.0] # This MUST match Hostname in Zabbix!
#
#美高梅手机版4858 , Type = mysqld
#
# MysqlPort = 3306
# Modules = pbxt
# PidFile = /var/lib/mysql/db_server.pid

# All MySQL clusters here

# [cl_2_3] # This MUST match Hostname in Zabbix!
#
# Disabled = false
#
# Type = ndbd
# ClusterLog = /usr/local/mysql-cluster/ndb_1_cluster.log
#
# Modules = ndb process
#
# MysqlHost = 127.0.0.1
# MysqlPort = 3306

 

重启zabbix-agent即可
/etc/init.d/zabbix-agent restart

MPM agent 文件的配备要对应Zabbix agent文件的陈设


sender
修改FromDualMySQLagent.pl中的zabbix_sender的路径:
# cd /usr/local/mysql_performance_monitor-agent/
# sed -i ‘s#/usr/local/bin#/usr/local/zabbix/bin/#g’
FromDualMySQLagent.pl

 

 

查阅日志FromDualMySQLagent.log

问题一 :[Z3001] connection to database ‘zabbix’ failed:
在被监督机器加用户
grant all privileges on *.* to zabbix@’%’ identified by ‘zabbix’

 

题目二: 要写被监察和控制主机名
cat /etc/zabbix/FromDualMySQLagent.conf

[GZNWX-CASH-DB01] # This MUST match Hostname in Zabbix!
被监察和控制主机的名字,跟zabbix里的host的名字要一律

Type = mysqld

MysqlPort = 3306
Modules = server mysql innodb process
PidFile = /ngbs/data/GZNWX-CASH-DB01.pid 被监督主机的mysql的pid文件

问题三:测试
测试,返回1则正常
在被监控机器上施行一下
/usr/local/mysql_performance_monitor-agent/FromDualMySQLagent.pl
/etc/zabbix/FromDualMySQLagent.conf

在zabbix服务器上施行一下
zabbix_get -s 192.168.0.21 -p10050 -k “FromDual.MySQL.check”

问题四:Load of cache file failed. rc=1301

1、删除cache目录下具备文件同仁一视启zabbix-agentd
rm -f /var/log/zabbix/cache/*

2、注释源码
vi /usr/local/mysql_performance_monitor-agent/lib/sendData.pm
$rc =
&FromDualMySQLagent::checkConnectionToZabbixServer($main::gParameter{‘ZabbixServer’},
$main::gParameter{‘ZabbixServerPort’}, $main::gParameter{‘Hostname’});

3、cat /etc/zabbix/FromDualMySQLagent.conf 里面Modules不能写mpm
Modules = server mysql innodb process

发表评论

电子邮件地址不会被公开。 必填项已用*标注

网站地图xml地图
Copyright @ 2010-2019 美高梅手机版4858 版权所有