|NO.Z.00003|——————————|^^ 构建 ^^|——|ZABBIX常见故障的处理|
报错处理一:
### --- 报错现象:
~~~ zabbix-server的运行值为NO,
~~~ 则修改zabbix-server.conf中zabbix-server.conf=127.0.0.1
~~~ 后重启zabbix-server服务即可。

### --- 报错分析:
~~~ Zabbix server is running NO localhost:10051
~~~ 根据如上如上错误提示,表示zabbix Server服务(核心组件)的进行状态是NO,
~~~ 没有监控本地localhost接口地址+10051端口。
### --- 解决方法:
### --- 通过手工方式检测Zabbix_server服务进程和端口号是否启动。
[root@localhost ~]# ps -ef |grep zabbix // 查看它的服务有没有启动
root 15282 78233 0 15:17 pts/1 00:00:00 grep --color=auto zabbix // grep本身的进程,不算。说明zabbix-server没有启动。
[root@localhost ~]# netstat -tunlp |grep -aw 10051 // 查看10051端口号有没有打开, -a是以文本方式显示 -w是只看文本关键词 --color 加上颜色
### --- 显示为空的话,通过手动方式启动zabbix-server服务脚本即可。
[root@localhost ~]# /etc/init.d/zabbix_server restart
[root@localhost ~]# echo $?
0 // 表示执行结果正常。
### --- OR
~~~ 或者查看zabbix-server.conf文件配置是否正确
~~~ 修改zabbix-server.conf中的DBHost=127.0.0.1后重启服务查看结果。
报错处理二:
### --- 报错现象:
[root@localhost ~]# /etc/init.d/zabbix_server start
Can't find file /usr/local/sbin/zabbix_server
Zabbix server NOT started
### --- 报错分析:
~~~ 根据如上错误的提示,表示启动zabbix server服务时,
~~~ 启动脚本会查找zabbix server主程序文件:/usr/local/sbin/zabix_server。
~~~ 而该文件没有找到,所以zabbix server服务不能启动。
### --- 解决方法:
~~~ 手工方式检测zabbix server主程序是否存在或者权限是否正确;
### --- 检查zabbix sever程序是否存在;
[root@localhost ~]# ls -l /usr/local/sbin/zabbix_server
ls:cannot access /usr/local/sbin/sbin/zabbix_server :No such file or directory // 说明文件不存在
[root@localhost ~]# if [ ! -f /usr/local/sbin/zabbix_server ];then echo The file does not exist.;fi
The file does not exist // 检测到文件不存在。/若存在什么也不输出。
[root@localhost ~]# if [ -f /usr/local/sbin/zabbix_server ];then echo ok ;fi
OK // 若存在输出OK
### --- 通过locate或者find工具查找zabbix_server程序的路径&添加软连接。
[root@localhost ~]# locate zabbix_server
### --- OR
[root@localhost ~]# find / -name zabbix_server
/etc/rc.d/init.d/zabbix_server
/root/zabbix-4.0.25/src/zabbix_server
/root/zabbix-4.0.25/src/zabbix_server/zabbix_server
/root/zabbix-4.0.25/misc/init.d/tru64/zabbix_server
/root/zabbix-4.0.25/misc/init.d/suse/9.3/zabbix_server
/root/zabbix-4.0.25/misc/init.d/suse/9.2/zabbix_server
/root/zabbix-4.0.25/misc/init.d/suse/9.1/zabbix_server
/root/zabbix-4.0.25/misc/init.d/freebsd/zabbix_server
/root/zabbix-4.0.25/misc/init.d/fedora/core/zabbix_server
/root/zabbix-4.0.25/misc/init.d/fedora/core5/zabbix_server
/usr/local/sbin/zabbix_server
/usr/local/zabbix/sbin/zabbix_server
[root@localhost ~]# find / -name zabbix_server |grep -v init |grep -v src // grep -v 排除init、src
### --- OR
[root@localhost ~]# find / -name zabbix_server |grep -vE "init|src" // 或者把两个个grep合在一起,-VE扩展参数。
/usr/local/zabbix/sbin/zabbix_server
### --- 做软连接。
[root@localhost ~]# ln -s /usr/local/zabbix/sbin/zabbix_* /usr/local/sbin/
### --- 或者直接用上面的命令执行以下for循环。
[root@localhost ~]#for i in $(find / -name zabbix_server |grep -vE "init|src");do ln -s $i /usr/local/sbin/;done // for i in把这个结果赋值为i这个变量,do开头,done结束,ln -s 软连接$i /usr/local/sbin/
### --- 或者用管道符;
[root@localhost ~]# find / -name zabbix_server |grep -vE "init|src" |xargs -I {} ln -s {} /usr/local/sbin/ // xargs -I先把参数传过来,传到大括号,再用ln -s去调用大括号里面的内容到/usr/local/sbin下。
报错处理三:
### --- 报错现象:
~~~ 根据以上的解决方案,均无法解决zabbix-server的启动问题时,
~~~ 此时借助zabbix-server软件程序自身的日志来定位问题。
### --- 报错分析:
[root@localhost ~]# tail -fn 30 /tmp/zabbix_server.log // tail -fn 30行来 (背锅侠专用)
[root@localhost ~]# tail -n 30 /tmp/zabbix_server.log // (推荐使用)
Connection to database 'zabbix'failed:[1045]Access denied for user 'zabbix'@'localhost'(usring password:NO)
~~~ 根据如上错误的提示,表示:启动zabbix server 服务时,
~~~ zabbix server主程序会链接后端数据库,通过zabbix用户,
~~~ 通过本地localhost链接,使用空密码链接后端zabbix库,被拒绝访问、
~~~ usring password:NO表示没有密码。
### --- 解决方案:
### --- 登录后端数据库检查zabbix和用户名,密码是否配置正确。
[root@localhost ~]# mysql -uroot -p123456
MariaDB [(none)]> show databases; // 查看库有没有建好
+--------------------+
| Database |
+--------------------+
| information_schema |
| mysql |
| performance_schema |
| zabbix |
+--------------------+
4 rows in set (0.00 sec)
MariaDB [(none)]> select user,host,password from mysql.user; // 在mysql.user表中查看user,password、host三个字段,看是否授权。。
+--------+-----------------------+-------------------------------------------+
| user | host | password |
+--------+-----------------------+-------------------------------------------+
| root | localhost | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| root | localhost.localdomain | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| root | 127.0.0.1 | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| root | ::1 | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| zabbix | localhost | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
+--------+-----------------------+-------------------------------------------+
5 rows in set (0.00 sec)
### --- 授权了,而且还是有密码。
### --- 查看zabbix_server.conf主程序配置文件看是否配置密码。
[root@localhost ~]# vim /usr/local/zabbix/etc/zabbix_server.conf
DBPassword= // 配置为空。默认安装完是空的。
报错处理四:
### --- 报错现象:
### --- zabbix_server启动时报错未创建账号:
[root@localhost ~]# /etc/init.d/zabbix_server restart
zabbix_server [28316]:user zabbix does not exist
zabbix_server [28316]:cannot run as root!
### --- 解决方案:
### --- 创建用户即可
[root@localhost ~]# useradd zabbix
报错处理五:
### --- 报错现象:
[root@localhost ~]# /etc/init.d/zabbix_agentd restart
zabbix_agentd [113015]: user zabbix does not exist
zabbix_agentd [113015]: cannot run as root!
Zabbix agent started.
### --- 解决方案:
### --- 创建用户和用户组即可:
[root@localhost ~]# groupadd zabbix
[root@localhost ~]# useradd -g zabbix zabbix
[root@localhost ~]# usermod -s /sbin/nologin zabbix
Walter Savage Landor:strove with none,for none was worth my strife.Nature I loved and, next to Nature, Art:I warm'd both hands before the fire of life.It sinks, and I am ready to depart
——W.S.Landor
分类:
cdv003-zabbix
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 无需6万激活码!GitHub神秘组织3小时极速复刻Manus,手把手教你使用OpenManus搭建本
· Manus爆火,是硬核还是营销?
· 终于写完轮子一部分:tcp代理 了,记录一下
· 别再用vector<bool>了!Google高级工程师:这可能是STL最大的设计失误
· 单元测试从入门到精通