美文网首页
Zabbix 5.0版本-使用percona对Mysql进行监控

Zabbix 5.0版本-使用percona对Mysql进行监控

作者: Chris0Yang | 来源:发表于2023-04-06 12:14 被阅读0次

    percona:专门应用于针对数据库进行自动化维护的工具
    通过zabbix监控Mysql步骤:

    服务端

    # 下载
    wget https://www.percona.com/downloads/percona-monitoring-plugins/percona-monitoring-plugins-1.1.8/binary/redhat/7/x86_64/percona-zabbix-templates-1.1.8-1.noarch.rpm
    
    # 准备服务端安装(两种方式)
    rpm -ivh percona-zabbix-templates-1.1.8-1.noarch.rpm
    yum localinstall percona-zabbix-templates-1.1.8-1.noarch.rpm -y
    
    # 文件结构
    [root@AdminController opt]# rpm -ql percona-zabbix-templates
    /var/lib/zabbix/percona
    /var/lib/zabbix/percona/scripts                             #插件脚本存放位置
    /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh  #she11脚本,用于针对监控数据进行取值
    /var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php      #php脚本,真正获取Mysg1数据库数据的脚本
    /var/lib/zabbix/percona/templates                           #zabbix-agent客户端监控项配置文件
    /var/lib/zabbix/percona/templates/userparameter_percona_mysql.conf  #模板
    /var/lib/zabbix/percona/templates/zabbix_agent_template_percona_mysql_server_ht_2.0.9-sver1.1.8.xml
    

    模板: 监控项+触发器+自动发现+web检测+图形化展示

    20301b5230b6f91b1ec285dedd56632.png

    客服端

    # zabbix安装percona插件(跳过)
    cd /var/lib/zabbix/percona/templates/
    cat userparameter_percona_mysql.conf
    ....
    
    # 拷贝文件
    cp /var/lib/zabbix/percona/templates/userparameter_percona_mysql.conf /etc/zabbix/zabbix_agent2.d/
    
    # 重启
    systemctl restart zabbix-agent2.service
    
    # 安装 数据库 和 php 服务
    yum install -y centos-release-scl rh-php72-php-fpm mariadb-server
    
    # 启动服务
    systemctl start rh-php72-php-fpm mariadb-server && systemctl enable rh-php72-php-fpm mariadb-server
    
    
    # 设置密码
    mysqladmin password 123456
    mysql -uroot -p123456
    
    # 编写php配置文件
    cat /var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php
    ...
    30 $mysql_user = 'root';
    31 $mysql_pass = '123456';
    ...
    
    # 拷贝php
    cp /opt/rh/rh-php72/root/bin/php /usr/bin/php
    
    # 客户端测试脚本是否异常
    /usr/bin/php -q /var/lib/zabbix/percona/scripts/ss_get_mysql_stats.php --host localhost --items gg
    /var/lib/zabbix/percona/scripts/get_mysql_stats_wrapper.sh ju
    
    # 服务端测试
    zabbix_agent2 -t MySQL.Questions
    
    # 导入模板
    sz /var/lib/zabbix/percona/templates/zabbix_agent_template_percona_mysql_server_ht_2.0.9-sver1.1.8.xml
    

    相关文章

      网友评论

          本文标题:Zabbix 5.0版本-使用percona对Mysql进行监控

          本文链接:https://www.haomeiwen.com/subject/oecuddtx.html