zoukankan      html  css  js  c++  java
  • Zabbix Server 自带模板监控有密码MySQL数据库

                    Zabbix Server 自带模板监控有密码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端的数据库

       服务端配置大同小异,可参考:https://www.cnblogs.com/yinzhengjie/p/10404028.html

  • 相关阅读:
    关于日期
    修改video标签自带按钮的默认样式
    vue相关
    手机
    国内优秀npm镜像
    一些技能整理
    小程序
    $('.mydiv>ul')和$('.mydiv ul')的不同
    Python 字符编码
    Python 正则表达式 补充
  • 原文地址:https://www.cnblogs.com/yinzhengjie/p/10404242.html
Copyright © 2011-2022 走看看