mysql监控的项目_项目实战:zabbix监控MySQL状态、服务信息

Zabbix监控MySQL数据库一、客户端

Ubuntu普通用户登录

1、  登陆MySQL

$ mysql -uroot -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or g.

Your MySQL connection id is 20000023

Server version: 5.5.46-0ubuntu0.14.04.2 (Ubuntu)

Copyright (c) 2000, 2015, 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>

22976_0.jpg

2、  创建zabbix用户用于发送数据

mysql>  GRANT USAGE ON*.*TO'zabbix'@'localhost'IDENTIFIED BY'You_passwd';

Query OK, 0 rows affected (0.00 sec)

mysql> FLUSH PRIVILEGES;

Query OK, 0 rows affected (0.00 sec)

mysql> q

Bye

22976_1.jpg

3、  测试zabbix用户登陆

$ mysql -uzabbix -p

Enter password:

Welcome to the MySQL monitor.  Commands end with ; or g.

Your MySQL connection id is 20000582

Server version: 5.5.46-0ubuntu0.14.04.2 (Ubuntu)

Copyright (c) 2000, 2015, 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> q

Bye

22976_2.jpg

4、  查找MySQL进程所在的位置

$ sudo find / -name *sock -print

[sudo] password for bdyun:

/run/mysqld/mysqld.sock        #MySQL进程所在的位置

/sys/kernel/debug/tracing/events/sock

/lib/modules/3.13.0-32-generic/kernel/net/vmw_vsock

/usr/src/linux-headers-3.13.0-32/net/vmw_vsock

5、  新建配置文件

$ sudo vi /etc/zabbix/.my.cnf

$ cat /etc/zabbix/.my.cnf

[mysql]

host=localhost

user=zabbix                                 #用来发送数据的用户

password=Bd_zabbix                #用来发送数据的用户密码

socket=/run/mysqld/mysqld.sock

[mysqladmin]

host=localhost

user=zabbix                                 #用来发送数据的用户

password=Bd_zabbix                         #用来发送数据的用户密码

socket=/run/mysqld/mysqld.sock   #MySQL进程所在的位置

22976_3.jpg

6、  修改文件userparameter_mysql.conf

查找文件所在位置

$ sudo find / -name userparameter_mysql.conf

/usr/share/doc/zabbix-agent/examples/userparameter_mysql.conf

复制文件到/etc/zabbix/zabbix_agentd.conf.d/userparameter_mysql.conf

$ sudo cp /usr/share/doc/zabbix-agent/examples/userparameter_mysql.conf /etc/zabbix/zabbix_agentd.conf.d/userparameter_mysql.conf

$ ls /etc/zabbix/zabbix_agentd.conf.d/

nginx.conf  userparameter_mysql.conf

这个文件用于制定Zabbix Agent如何获取MySQL数据,我们需要将所有的/var/lib/zabbix修改为当前.my.cnf文件的路径/etc/zabbix。设置完 成之后保存并重启Zabbix Agent

$ sudo sed -i 's@/var/lib/zabbix@/etc/zabbix@g' /etc/zabbix/zabbix_agentd.conf.d/userparameter_mysql.conf

$ sudo service zabbix-agent restart

zabbix-agent stop/waiting

zabbix-agent start/running, process 32121

7、  重启服务

$ sudo service zabbix-agent restart

zabbix-agent stop/waiting

zabbix-agent start/running, process 32121

二、服务端

1、为监控主机选择、添加MySQL模板

ConfigurationèHostsèTemplates

22976_4.jpg

2、查看图组数据图形

22976_5.jpg

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值