监控数据库分为三种:

1.Zabbix Server 自带模板监控无密码MySQL数据库

2.Zabbix Server 自带模板监控有密码MySQL数据库

3.Zabbix Server 自带模板监控更加灵活MySQL数据库

一:

一.安装MariaDB

1>.安装MariaDB 

[root@node102 ~]# yum -y install mariadb-server
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.aliyun.com
* updates: mirrors.163.com
Resolving Dependencies
--> Running transaction check
---> Package mariadb-server.x86_64 1:5.5.60-1.el7_5 will be installed
--> Processing Dependency: perl-DBI for package: 1:mariadb-server-5.5.60-1.el7_5.x86_64
--> Processing Dependency: perl-DBD-MySQL for package: 1:mariadb-server-5.5.60-1.el7_5.x86_64
--> Processing Dependency: perl(Data::Dumper) for package: 1:mariadb-server-5.5.60-1.el7_5.x86_64
--> Processing Dependency: perl(DBI) for package: 1:mariadb-server-5.5.60-1.el7_5.x86_64
--> Processing Dependency: libaio.so.1(LIBAIO_0.4)(64bit) for package: 1:mariadb-server-5.5.60-1.el7_5.x86_64
--> Processing Dependency: libaio.so.1(LIBAIO_0.1)(64bit) for package: 1:mariadb-server-5.5.60-1.el7_5.x86_64
--> Processing Dependency: libaio.so.1()(64bit) for package: 1:mariadb-server-5.5.60-1.el7_5.x86_64
--> Running transaction check
---> Package libaio.x86_64 0:0.3.109-13.el7 will be installed
---> Package perl-DBD-MySQL.x86_64 0:4.023-6.el7 will be installed
---> Package perl-DBI.x86_64 0:1.627-4.el7 will be installed
--> Processing Dependency: perl(RPC::PlServer) >= 0.2001 for package: perl-DBI-1.627-4.el7.x86_64
--> Processing Dependency: perl(RPC::PlClient) >= 0.2000 for package: perl-DBI-1.627-4.el7.x86_64
---> Package perl-Data-Dumper.x86_64 0:2.145-3.el7 will be installed
--> Running transaction check
---> Package perl-PlRPC.noarch 0:0.2020-14.el7 will be installed
--> Processing Dependency: perl(Net::Daemon) >= 0.13 for package: perl-PlRPC-0.2020-14.el7.noarch
--> Processing Dependency: perl(Net::Daemon::Test) for package: perl-PlRPC-0.2020-14.el7.noarch
--> Processing Dependency: perl(Net::Daemon::Log) for package: perl-PlRPC-0.2020-14.el7.noarch
--> Processing Dependency: perl(Compress::Zlib) for package: perl-PlRPC-0.2020-14.el7.noarch
--> Running transaction check
---> Package perl-IO-Compress.noarch 0:2.061-2.el7 will be installed
--> Processing Dependency: perl(Compress::Raw::Zlib) >= 2.061 for package: perl-IO-Compress-2.061-2.el7.noarch
--> Processing Dependency: perl(Compress::Raw::Bzip2) >= 2.061 for package: perl-IO-Compress-2.061-2.el7.noarch
---> Package perl-Net-Daemon.noarch 0:0.48-5.el7 will be installed
--> Running transaction check
---> Package perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7 will be installed
---> Package perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7 will be installed
--> Finished Dependency Resolution Dependencies Resolved ===========================================================================================================================================================================================
Package Arch Version Repository Size
===========================================================================================================================================================================================
Installing:
mariadb-server x86_64 1:5.5.60-1.el7_5 base 11 M
Installing for dependencies:
libaio x86_64 0.3.109-13.el7 base 24 k
perl-Compress-Raw-Bzip2 x86_64 2.061-3.el7 base 32 k
perl-Compress-Raw-Zlib x86_64 1:2.061-4.el7 base 57 k
perl-DBD-MySQL x86_64 4.023-6.el7 base 140 k
perl-DBI x86_64 1.627-4.el7 base 802 k
perl-Data-Dumper x86_64 2.145-3.el7 base 47 k
perl-IO-Compress noarch 2.061-2.el7 base 260 k
perl-Net-Daemon noarch 0.48-5.el7 base 51 k
perl-PlRPC noarch 0.2020-14.el7 base 36 k Transaction Summary
===========================================================================================================================================================================================
Install 1 Package (+9 Dependent packages) Total download size: 12 M
Installed size: 62 M
Downloading packages:
(1/10): libaio-0.3.109-13.el7.x86_64.rpm | 24 kB 00:00:00
(2/10): perl-Compress-Raw-Zlib-2.061-4.el7.x86_64.rpm | 57 kB 00:00:00
(3/10): perl-Data-Dumper-2.145-3.el7.x86_64.rpm | 47 kB 00:00:00
(4/10): perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64.rpm | 32 kB 00:00:00
(5/10): perl-IO-Compress-2.061-2.el7.noarch.rpm | 260 kB 00:00:00
(6/10): perl-Net-Daemon-0.48-5.el7.noarch.rpm | 51 kB 00:00:00
(7/10): perl-PlRPC-0.2020-14.el7.noarch.rpm | 36 kB 00:00:00
(8/10): perl-DBD-MySQL-4.023-6.el7.x86_64.rpm | 140 kB 00:00:00
(9/10): perl-DBI-1.627-4.el7.x86_64.rpm | 802 kB 00:00:00
(10/10): mariadb-server-5.5.60-1.el7_5.x86_64.rpm | 11 MB 00:00:07
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 1.7 MB/s | 12 MB 00:00:07
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : perl-Data-Dumper-2.145-3.el7.x86_64 1/10
Installing : libaio-0.3.109-13.el7.x86_64 2/10
Installing : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64 3/10
Installing : perl-Net-Daemon-0.48-5.el7.noarch 4/10
Installing : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64 5/10
Installing : perl-IO-Compress-2.061-2.el7.noarch 6/10
Installing : perl-PlRPC-0.2020-14.el7.noarch 7/10
Installing : perl-DBI-1.627-4.el7.x86_64 8/10
Installing : perl-DBD-MySQL-4.023-6.el7.x86_64 9/10
Installing : 1:mariadb-server-5.5.60-1.el7_5.x86_64 10/10
Verifying : 1:mariadb-server-5.5.60-1.el7_5.x86_64 1/10
Verifying : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64 2/10
Verifying : perl-Net-Daemon-0.48-5.el7.noarch 3/10
Verifying : perl-Data-Dumper-2.145-3.el7.x86_64 4/10
Verifying : perl-DBD-MySQL-4.023-6.el7.x86_64 5/10
Verifying : perl-IO-Compress-2.061-2.el7.noarch 6/10
Verifying : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64 7/10
Verifying : perl-DBI-1.627-4.el7.x86_64 8/10
Verifying : libaio-0.3.109-13.el7.x86_64 9/10
Verifying : perl-PlRPC-0.2020-14.el7.noarch 10/10 Installed:
mariadb-server.x86_64 1:5.5.60-1.el7_5 Dependency Installed:
libaio.x86_64 0:0.3.109-13.el7 perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7 perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7 perl-DBD-MySQL.x86_64 0:4.023-6.el7
perl-DBI.x86_64 0:1.627-4.el7 perl-Data-Dumper.x86_64 0:2.145-3.el7 perl-IO-Compress.noarch 0:2.061-2.el7 perl-Net-Daemon.noarch 0:0.48-5.el7
perl-PlRPC.noarch 0:0.2020-14.el7 Complete!
[root@node102 ~]#

2>.启动MariaDB

[root@node102 ~]# systemctl status mariadb
● mariadb.service - MariaDB database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
Active: inactive (dead)
[root@node102 ~]#
[root@node102 ~]# systemctl start mariadb
[root@node102 ~]#
[root@node102 ~]#
[root@node102 ~]# systemctl enable mariadb
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@node102 ~]#
[root@node102 ~]#
[root@node102 ~]# systemctl status mariadb
● mariadb.service - MariaDB database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
Active: active (running) since Tue 2019-02-19 08:01:16 PST; 7s ago
Main PID: 3860 (mysqld_safe)
CGroup: /system.slice/mariadb.service
├─3860 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
└─4022 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/run/mariadb/... Feb 19 08:01:14 node102.yinzhengjie.org.cn mariadb-prepare-db-dir[3782]: MySQL manual for more instructions.
Feb 19 08:01:14 node102.yinzhengjie.org.cn mariadb-prepare-db-dir[3782]: Please report any problems at http://mariadb.org/jira
Feb 19 08:01:14 node102.yinzhengjie.org.cn mariadb-prepare-db-dir[3782]: The latest information about MariaDB is available at http://mariadb.org/.
Feb 19 08:01:14 node102.yinzhengjie.org.cn mariadb-prepare-db-dir[3782]: You can find additional information about the MySQL part at:
Feb 19 08:01:14 node102.yinzhengjie.org.cn mariadb-prepare-db-dir[3782]: http://dev.mysql.com
Feb 19 08:01:14 node102.yinzhengjie.org.cn mariadb-prepare-db-dir[3782]: Consider joining MariaDB's strong and vibrant community:
Feb 19 08:01:14 node102.yinzhengjie.org.cn mariadb-prepare-db-dir[3782]: https://mariadb.org/get-involved/
Feb 19 08:01:14 node102.yinzhengjie.org.cn mysqld_safe[3860]: 190219 08:01:14 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
Feb 19 08:01:14 node102.yinzhengjie.org.cn mysqld_safe[3860]: 190219 08:01:14 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Feb 19 08:01:16 node102.yinzhengjie.org.cn systemd[1]: Started MariaDB database server.
[root@node102 ~]#
[root@node102 ~]#

二.Zabbix Server 配置监控无密码的MariaDB数据库

1>.创建主机

2>.配置host界面

3>.配置zabbix监控数据库的模板

4>.主机添加完成

5>.如下图所示,zabbix默认有14个监控项

6>.查看监控MySQL的图形

 

二:

一.Zabbix-agent端的配置

1>.为数据库设置密码

[root@node102 ~]# mysql -uroot -pyinzhengjie                          #看见没?默认是不需要密码就可以登录的!我们想要设置密码的话,就得进行授权操作!
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[root@node102 ~]#
[root@node102 ~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 227
Server version: 5.5.60-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)]> GRANT ALL ON *.* TO root@'localhost' IDENTIFIED BY 'yinzhengjie';            #创建授权用户
Query OK, 0 rows affected (0.00 sec)
    
MariaDB [(none)]> FLUSH PRIVILEGES;                                        #刷新权限
Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]>
MariaDB [(none)]> quit
Bye
[root@node102 ~]#
[root@node102 ~]# mysql -uroot -pyinzhengjie                                    #验证创建的用户是否可用正常登录!
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 254
Server version: 5.5.60-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)]> quit
Bye
[root@node102 ~]#
[root@node102 ~]#

2>.修改zabbix-agent端的数据库配置文件并重启服务

[root@node102 ~]# cat /etc/zabbix/zabbix_agentd.d/userparameter_mysql.conf  | egrep -v '^#|^$'
UserParameter=mysql.status[*],echo "show global status where Variable_name='$1';" | HOME=/var/lib/zabbix mysql -uroot -pyinzhengjie -N | awk '{print $$2}'      #这里需要修改一些
UserParameter=mysql.size[*],bash -c 'echo "select sum($(case "$3" in both|"") echo "data_length+index_length";; data|index) echo "$3_length";; free) echo "data_free";; esac)) from information_schema.tables$([[ "$1" = "all" || ! "$1" ]] || echo " where table_schema=\"$1\"")$([[ "$2" = "all" || ! "$2" ]] || echo "and table_name=\"$2\"");" | HOME=/var/lib/zabbix mysql -N'
UserParameter=mysql.ping,HOME=/var/lib/zabbix mysqladmin ping -uroot -pyinzhengjie | grep -c alive                                        #除了修改第一个,我们还需要修改这一行,把上面的配置的用户和密码加入进去!
UserParameter=mysql.version,mysql -V
[root@node102 ~]#
[root@node102 ~]#
[root@node102 ~]# systemctl restart zabbix-agent
[root@node102 ~]#
[root@node102 ~]#

二.Zabbix Server监控Agent端的数据库

  服务端配置大同小异,可参考上面无密码监控mysql

三:

一.zabbix-agent端配置

1>.修改zabbix的item配置文件

[root@node102 ~]# cat /etc/zabbix/zabbix_agentd.d/userparameter_mysql.conf  | egrep -v '^#|^$'
UserParameter=mysql.status[*],echo "show global status where Variable_name='$3';" | HOME=/var/lib/zabbix mysql -u$1 -p$2 -N | awk '{print $$2}'          #注意这里修改了3处
UserParameter=mysql.size[*],bash -c 'echo "select sum($(case "$3" in both|"") echo "data_length+index_length";; data|index) echo "$3_length";; free) echo "data_free";; esac)) from information_schema.tables$([[ "$1" = "all" || ! "$1" ]] || echo " where table_schema=\"$1\"")$([[ "$2" = "all" || ! "$2" ]] || echo "and table_name=\"$2\"");" | HOME=/var/lib/zabbix mysql -N'
UserParameter=mysql.ping[*],HOME=/var/lib/zabbix mysqladmin ping -u$1 -p$2 | grep -c alive                                          #这里也修改了3处
UserParameter=mysql.version,mysql -V
[root@node102 ~]#
[root@node102 ~]# systemctl restart zabbix-agent
[root@node102 ~]#

2>.使用zabbix-Server测试

[root@node101 ~]# zabbix_get -s node102.yinzhengjie.org.cn -k mysql.status[root,yinzhengjie,Uptime]          #很显然,我们是可以取到值的!
3128
[root@node101 ~]#
[root@node101 ~]# zabbix_get -s node102.yinzhengjie.org.cn -k mysql.status[root,yinzhengjie,Uptime]
3129
[root@node101 ~]#
[root@node101 ~]# zabbix_get -s node102.yinzhengjie.org.cn -k mysql.status[root,yinzhengjie,Uptime]
3130
[root@node101 ~]#
[root@node101 ~]#

3>.创建MySQL测试用户

[root@node102 ~]# mysql -uroot -pyinzhengjie
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 728
Server version: 5.5.60-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)]>
MariaDB [(none)]> GRANT ALL ON *.* TO monitor@'localhost' IDENTIFIED BY 'yinzhengjie2019';
Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]>
MariaDB [(none)]> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.01 sec) MariaDB [(none)]> quit
Bye
[root@node102 ~]#

二.zabbix-Server端配置

1>.找到zabbix-server的数据库模板

2>.添加zabbix的变量

3>.更新模板

4>.重复下图操作,将默认的13个监控项的key都添加2个变量

5>.数据库模板配置完成

6>.配置被监控的数据库的用户名和密码

7>.配置完成

8>.在zabbix-server端让配置立即生效

[root@node101 ~]# zabbix_server -R config_cache_reload        #重新加载配置信息
zabbix_server [4009]: command sent successfully
[root@node101 ~]#
[root@node101 ~]#

9>.查看监控图像

007-Zabbix Server 自带模板监控MySQL数据库的更多相关文章

  1. Zabbix Server 自带模板监控更加灵活MySQL数据库

    Zabbix Server 自带模板监控更加灵活MySQL数据库 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任.  一.zabbix-agent端配置 1>.修改zabbix的 ...

  2. Zabbix Server 自带模板监控有密码MySQL数据库

    Zabbix Server 自带模板监控有密码MySQL数据库 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任.  一.Zabbix-agent端的配置 1>.为数据库设置密码 ...

  3. Zabbix Server 自带模板监控无密码MySQL数据库

    Zabbix Server 自带模板监控无密码MySQL数据库 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任.  一.安装MariaDB 1>.安装MariaDB  [root ...

  4. zabbix 使用自带模板监控mysql

    1.这里可以采用zabbix自带的mysql模版,但是也需要在mysql服务器上准备获取mysql status的脚本chk_mysql.sh,zabbix通过调用这个脚本来获取mysql的运行信息. ...

  5. zabbix利用自带模板-监控mysql性能

    环境: zabbix3.4.4 mariadb 5.5.56 要求:  利用zabbix 自带的模板 监控mariadb 上的 并发连接数,慢查询数量,增删改查.请求流量带宽,mysql响应流量带宽等 ...

  6. zabbix使用自带模板监控MySQL

    监控mysql不能直接使用zabbix自带模板,还需要到被监控的mysql客户端做配置. 1.在zabbix   web配置步骤如下图: 2.配置完之后去看mysql主机监控项的时候看到mysql的监 ...

  7. zabbix用自带模板监控mysql

    本身zabbix-agent没有提供对mysql监控的key,所以需要自定义key来应用这个模板 默认的模板有以下三类 mysql.status[var] mysql.ping mysql.versi ...

  8. zabbix利用自带的模板监控mysql数据库

    zabbix利用自带的模板监控mysql数据库 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. 有些东西你不会的时候觉得它特别难,但是当你去做的时候就发现如此的简单~zabbix功能 ...

  9. Zabbix-agent使用自带模板监控 MySQL

    1.rpm -ivh http://repo.zabbix.com/zabbix/2.4/rhel/6/x86_64/zabbix-release-2.4-1.el6.noarch.rpm 2.yum ...

随机推荐

  1. 全面解读php-php会话控制技术

    一.PHP会话控制技术 1.为什么要使用会话控制技术? 因为http协议是无状态协议,所以同一个用户在请求同一个页面两次的时候,http协议不会认为这两次请求都来自于同一个用户,会把它们当做是两次请求 ...

  2. DeepFaceLab参数详解之Batch-Size的使用和取值!

    Batch-Size简称BS. 这是一个非常常见的参数,所有模型都具备的一个参数. 这其实是深度学习中的一个基础概念.要说理论可以说出一大堆,大家可以先简单的理解为一次处理的图片张数.为了防止吓跑小白 ...

  3. Android动画View Animation与Drawable Animation

    Animations 一.Animations介绍 Animations是一个实现android UI界面动画效果的API,Animations提供了一系列的动画效果,可以进行旋转.缩放.淡入淡出等, ...

  4. java删除文件夹或者文件

    private static void deleteFile(File file) { if (file.exists()) { // 判断文件是否存在 if (file.isFile()) { // ...

  5. navivate 下载

    https://www.jianshu.com/p/5f693b4c9468?mType=Group

  6. 多变量线性回归时使用梯度下降(Gradient Descent)求最小值的注意事项

    梯度下降是回归问题中求cost function最小值的有效方法,对大数据量的训练集而言,其效果要 好于非迭代的normal equation方法. 在将其用于多变量回归时,有两个问题要注意,否则会导 ...

  7. Ubuntu系统下各种报错杂烩(持续更新)

    在Github时报Permanently added the RSA host key for IP address '192.30.252.128' to the list of known hos ...

  8. I/O检测介绍

    I/O性能监测可总结如下:* 任何时间出现CPU等待IO,说明磁盘超载.* 计算出你的磁盘可维持的IOPS值.* 判定你的应用是属于随机磁盘访问型还是有序型.* 通过对比等待时间和服务时间即可判断磁盘 ...

  9. asp.net mvc 依赖注入Ninject

    1.安装Ninject 2.使用Ninject 一 安装Ninject Nuget:Ninject 二 使用Ninject public interface IStudent { string Get ...

  10. slideToggle()---单击隐藏/浮现--jQuery--click() 方法

    click() 方法 模块隐藏/浮现 <html> <head> <script type="text/javascript" src="/ ...