zabbix实际生产故障案例

背景环境:公司新搭建的zabbix监控系统,使用mariadb数据库,一直运行正常,然后某天突然发现zabbix打不开了,进入服务器重启zabbix-server和mariadb直接卡住不动。
配置:centos7.6 zabbix4.0
解决步骤:
1.登录df -h 查看磁盘空间使用率,发现/var 占用100%,进行无关文件删除之后重启服务器;
2.但是登录zabbix发现提示警告mysql最大连接数有问题,于是登录mariadb进行排查解决,具体步骤如下
提示如下:
connection to database 'zabbix' failed: [1040] Too many connections
解决:
1.进入数据库

mysql
show variables like 'max_connections';

2、修改/etc/my.cnf配置文件
在[mysqld]新添加一行:

[root@zabbix-server ]# vi /etc/my.cnf
max_connections=1000

重启mariadb服务,并验证最大连接数(没显示我们修改的):

[root@zabbix-server ]# systemctl restart mariadb.service
[root@zabbix-server ]# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 446
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)]> show variables like 'max_connections';
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| max_connections | 214   |
+-----------------+-------+
1 row in set (0.00 sec)

3、配置/usr/lib/systemd/system/mariadb.service来调大打开文件数目

[root@zabbix-server ]# vi /usr/lib/systemd/system/mariadb.service
在[Service]新加这两行:
LimitNOFILE=10000
LimitNPROC=10000

4、重新加载系统服务,并重启mariadb服务

systemctl daemon-reload

[root@zabbix-server ]#  systemctl --system daemon-reload
[root@zabbix-server ]#  systemctl restart mariadb.service

5、重新验证下,是否为1000

MariaDB [(none)]> show variables like 'max_connections';
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id:    5
Current database: *** NONE ***
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| max_connections | 1000  |
+-----------------+-------+
1 row in set (0.00 sec)

ok 打开zabbix服务运行正常

posted @ 2020-04-11 22:47  老王教你学Linux  阅读(879)  评论(0编辑  收藏  举报