zabbix监控mysql主从状态+mysql流量

    技术2022-07-15  67

    一、安装zabbix

    配置前提:

    192.168.253.137    zabiix主机+mysql主192.168.253.120    mysql从主机

    1.配置zabbix的yum源

    [root@localhost yum.repos.d]# vim zabbix.repo

    [zabbix] name=Zabbix Official Repository - $basearch baseurl=http://mirrors.aliyun.com/zabbix/zabbix/4.4/rhel/7/$basearch/ enabled=1 gpgcheck=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591

    [zabbix-debuginfo] name=Zabbix Official Repository debuginfo - $basearch baseurl=http://mirrors.aliyun.com/zabbix/zabbix/4.4/rhel/7/$basearch/debuginfo/ enabled=0 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX-A14FE591 gpgcheck=0

    [zabbix-non-supported] name=Zabbix Official Repository non-supported - $basearch baseurl=http://mirrors.aliyun.com/zabbix/non-supported/rhel/7/$basearch/ enabled=1 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX gpgcheck=0

     2.安装

    [root@localhost ~]# systemctl stop firewalld [root@localhost ~]# setenforce 0 [root@localhost ~]# yum -y install zabbix-web-mysql zabbix-server-mysql zabbix-agent mariadb mariadb-server

    3.配置

    [root@localhost ~]# systemctl  enable mariadb

    [root@localhost ~]# systemctl  start mariadb

    [root@localhost ~]# mysqlMariaDB [(none)]> create database zabbix charset utf8 collate utf8_bin;     #数据库字符集和一个数据库校对规则 Query OK, 1 row affected (0.00 sec) MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix'; Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> flush privileges; Query OK, 0 rows affected (0.00 sec) [root@localhost ~]# zcat /usr/share/doc/zabbix-server-mysql-4.4.9/create.sql.gz | mysql -uzabbix -pzabbix zabbix

     

    [root@localhost ~]# vim /etc/zabbix/zabbix_server.conf  DBPassword=zabbix 修改时区

    [root@localhost ~]# vim /etc/php.ini

    date.timezone = Asia/Shanghai

    [root@localhost ~]# systemctl  start zabbix-server zabbix-agent httpd [root@localhost ~]# netstat -antp | egrep "80|10050|10051"

    4.登录

    汉化

    二丶搭建主从

    主库

    从库

    四、zabbix监控mysql

     

     

     

     

     

    测试触发器报警

    监控mysql流量

    增加监控项

    vim /etc/zabbix/zabbix_agentd.d/userparameter_Bytes_sent.conf

    1

    UserParameter=Bytes_sent[*],/etc/zabbix/scripts/pv_uv.sh $1

    vim /etc/zabbix/zabbix_agentd.d/userparameter_Bytes_receive.conf

    1

    UserParameter=Bytes_receive[*],/etc/zabbix/scripts/pv_uv.sh $1

     

    Processed: 0.012, SQL: 9