zabbix安装
在上一篇文章当中,已经配置好了yum源,那么接下来的安装过程就会显得非常简单了。
安装zabbix各种服务
yum install zabbix-server-mysql
yum install zabbix-anget
yum install zabbix-web-mysql
创建mysql数据库,并且导入初始化数据库
create database zabbix character set utf8 collate utf8_bin;(这个命令是放到mysql客户端里面执行的)
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
这里需要注意的是,创建数据库的时候一定要加上后面的字符集和collate选项,不然zabbix-server和前端页面连接数据库时会报错。
修改zabbix配置,用于连接数据库
打开文件/etc/zabbix/zabbix_server.conf,修改数据库配置
DBHost=127.0.0.1
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
关闭selinux
setenforce 0
需要先关闭selinux,如果不关闭,后面可能server起不来,会报如下的错
[root@localhost msb_5_7_21]# service zabbix-server start
Redirecting to /bin/systemctl start zabbix-server.service
Job for zabbix-server.service failed because a configured resource limit was exceeded. See "systemctl status zabbix-server.service" and "journalctl -xe" for details.
[root@localhost msb_5_7_21]# systemctl status zabbix-server.service
● zabbix-server.service - Zabbix Server
Loaded: loaded (/usr/lib/systemd/system/zabbix-server.service; disabled; vendor preset: disabled)
Active: activating (auto-restart) (Result: resources) since 一 2020-05-18 11:33:04 CST; 6s ago
Process: 32268 ExecStart=/usr/sbin/zabbix_server -c $CONFFILE (code=exited, status=0/SUCCESS)
5月 18 11:33:04 localhost.localdomain systemd[1]: zabbix-server.service never wrote its PID file. Failing.
5月 18 11:33:04 localhost.localdomain systemd[1]: Failed to start Zabbix Server.
5月 18 11:33:04 localhost.localdomain systemd[1]: Unit zabbix-server.service entered failed state.
5月 18 11:33:04 localhost.localdomain systemd[1]: zabbix-server.service failed.
[root@localhost msb_5_7_21]# journalctl -xe
5月 18 11:34:06 localhost.localdomain systemd[1]: zabbix-server.service failed.
5月 18 11:34:16 localhost.localdomain systemd[1]: zabbix-server.service holdoff time over, scheduling restart.
5月 18 11:34:16 localhost.localdomain systemd[1]: Starting Zabbix Server...
-- Subject: Unit zabbix-server.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit zabbix-server.service has begun starting up.
5月 18 11:34:16 localhost.localdomain systemd[1]: PID file /run/zabbix/zabbix_server.pid not readable (yet?) after start.
5月 18 11:34:16 localhost.localdomain systemd[1]: zabbix-server.service never wrote its PID file. Failing.
5月 18 11:34:16 localhost.localdomain systemd[1]: Failed to start Zabbix Server.
-- Subject: Unit zabbix-server.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit zabbix-server.service has failed.
--
-- The result is failed.
5月 18 11:34:16 localhost.localdomain systemd[1]: Unit zabbix-server.service entered failed state.
5月 18 11:34:16 localhost.localdomain systemd[1]: zabbix-server.service failed.
或者zabbix-agent启动也会报错如下
[root@localhost ~]# service zabbix-agent start
Redirecting to /bin/systemctl start zabbix-agent.service
Job for zabbix-agent.service failed. See "systemctl status zabbix-agent.service" and "journalctl -xe" for details.
[root@localhost ~]# journalctl -xe
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit zabbix-agent.service has begun starting up.
5月 25 06:29:50 localhost systemd[1]: Can't open PID file /run/zabbix/zabbix_agentd.pid (yet?) after start: No such file or directory
5月 25 06:29:50 localhost zabbix_agentd[4233]: zabbix_agentd [4235]: cannot open "/var/log/zabbix/zabbix_agentd.log": [13] Permission denied
5月 25 06:29:50 localhost systemd[1]: Daemon never wrote its PID file. Failing.
5月 25 06:29:50 localhost systemd[1]: Failed to start Zabbix Agent.
-- Subject: Unit zabbix-agent.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit zabbix-agent.service has failed.
--
-- The result is failed.
5月 25 06:29:50 localhost systemd[1]: Unit zabbix-agent.service entered failed state.
5月 25 06:29:50 localhost systemd[1]: zabbix-agent.service failed.
5月 25 06:29:50 localhost polkitd[532]: Unregistered Authentication Agent for unix-process:4077:84102569 (system bus name :1.3306, object path /org/
开启zabbix-server,观察后台日志
service zabbix-server start
service zabbix-agent start
tail -10f /var/log/zabbix
开启httpd服务并且关闭防火墙
service httpd start;
systemctl stop firewalld.service
修改/etc/php-fpm.d/zabbix.conf的时间设置
php_value date.timezone Asia/Shanghai
跟着https://www.zabbix.com/documentation/4.4/manual/installation/install#installing_frontend上面的步骤来修改前端页面的配置
设置开机启动zabbix-server,zabbis-agent和httpd
systemctl enable zabbix-server zabbix-agent httpd