(1)先对数据库进行授权和密码,通过zabbix用户进行获取数据,此处的授权由于试验,就授权了全部权限,正式生产时不能这样设置。
[root@linux-node2 ~]
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection
id
is 711
Server version: 5.5.56-MariaDB MariaDB Server
Copyright (c) 2000, 2017, 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 zabbix@localhost identified by
"zabbix"
;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> quit;
Bye
(2)修改监控配置,添加用户名密码
[root@linux-node2 ~]
UserParameter=mysql.status[*],
echo
"show global status where Variable_name='$1';"
| HOME=
/var/lib/zabbix
mysql -uzabbix -pzabbix -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
-uzabbix -pzabbix |
grep
-c alive
UserParameter=mysql.version,mysql -V
[root@linux-node2 ~]