如何从远程服务器监控数据库?

aij0ehis  于 2021-06-21  发布在  Mysql
关注(0)|答案(1)|浏览(231)

我在一台服务器(ubuntu16.04)上安装了zabbix,以监视另一台服务器的性能。我可以看到它的cpu使用率,内存使用率,等等。
但是,这个服务器(ubuntu16.04)也包含一个数据库,我还想监视它的性能(每分钟的查询数、执行时间等)。我还没有找到如何使用zabbix。
有人能指导我怎么做吗?如果zabbix不能做到这一点,有没有其他工具可以监控远程数据库?
谢谢。

pbpqsu0x

pbpqsu0x1#

zabbix由两部分组成
存储所有收集的数据、处理和激发触发器的zabbix服务器
zabbix代理可以安装在大多数操作系统上,它允许从系统中收集深入的数据。然后代理将收集的数据发送回zabbix服务器
因此,在您的情况下,最好在db服务器上安装zabbix代理,然后使用zabbix中包含的mysql监视工具。这样您就不必允许网络访问您的mysql服务器。
最常见的问题是,您需要一个名为zabbix(或您在配置文件中定义的)的db用户,该用户对mysql的统计信息具有读取权限。
在这里创建mysql用户并分配权限

root@web01:~# mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 5
Server version: 5.7.17-0ubuntu0.16.04.1 (Ubuntu)

Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

mysql> create user 'zabbix_admin'@'localhost' IDENTIFIED BY 'Password';
Query OK, 0 rows affected (0.00 sec)

mysql> GRANT USAGE ON *.* TO 'zabbix_admin'@'localhost' IDENTIFIED BY 'Password';
Query OK, 0 rows affected, 1 warning (0.00 sec)

mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)

mysql> exit
Bye

然后在zabbix config文件夹中指定登录信息

root@web01:~# vi /etc/zabbix/.my.cnf

# 

[mysql]
user=zabbix_admin
password=Password
[mysqladmin]
user=zabbix_admin
password=Password

而在 /etc/zabbix/zabbix_agentd.conf.d/userparameter_mysql.conf 文件指定要监视的内容(从模板中获取)这里还有一些其他指针:
http://yallalabs.com/linux/how-to-monitor-mysqlmariadb-using-zabbix-server/ 作为教程
https://www.zabbix.com/forum/zabbix-help/39943-how-do-i-monitor-mysql-on-a-target-host 更多细节
https://share.zabbix.com/databases/mysql 对mysql进行更深入的监控

相关问题