zabbix5.0监控mysql服务器
hostname | ip |
---|---|
zabbix-server | 10.130.16.10 |
mysql | 10.130.16.11 |
mysql:
#zabbix-agent安装
rpm -Uvh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm #使用阿里云的
yum clean all
yum install -y zabbix-agent
#创建账户并赋权
[root@mysql ~]# mysql
MariaDB [(none)]> CREATE USER 'zbx_monitor'@'localhost' IDENTIFIED BY '<password>';
MariaDB [(none)]> GRANT USAGE,REPLICATION CLIENT,PROCESS,SHOW DATABASES,SHOW VIEW ON *.* TO 'zbx_monitor'@'localhost';
MariaDB [(none)]> flush privileges;
###测试
[root@mysql ~]# mysql -uzbx_monitor -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 11879
Server version: 5.5.68-MariaDB MariaDB Server
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| zabbix |
+--------------------+
4 rows in set (0.00 sec)
#这个路径通过rpm -ql找到相应的路径
cp /usr/share/doc/zabbix-agent-5.0.7/userparameter_mysql.conf /etc/zabbix/zabbix_agentd.d/template_db_mysql.conf
### /etc/zabbix/zabbix_agentd.d/template_db_mysql.conf 按实际设置修改
#[client]
#user=zbx_monitor
#password=<password>
###配置账户
mkdir -p /var/lib/zabbix
cat>/var/lib/zabbix/.my.cnf<<EOF
[client]
user='zbx_monitor'
password='<password>'
EOF