参考文档:
https://www.zabbix.com/download?zabbix=4.0&os_distribution=centos&os_version=7&db=mysql
1. httpd 和 php的安装
yum -y install httpd php
2. mysql的安装
略
3. Install Zabbix repository
rpm -Uvh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-2.el7.noarch.rpm
然后修改/etc/yum.repos.d/zabbix.repo 为阿里云的源:
执行:yum clean all
安装: yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent
4. 新建zabbix 需要的用户和数据库表结构等
create database zabbix character set utf8 collate utf8_bin;
grant all privileges on zabbix.* to zabbix@localhost identified by 'xxxxxx';
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -p zabbix
5. Configure the database for Zabbix server
/etc/httpd/conf.d/zabbix.conf
6. 时区修改
7. 启动
8. installing_frontend
参考:https://www.zabbix.com/documentation/4.0/manual/installation/install#installing_frontend
基本就是一下步。
配置数据库这一步可能报错:
Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (13)
处理方法:
host从 localhost 改成 127.0.0.1
然后新增一个数据库用户:grant all privileges on zabbix.* to zabbix@127.0.0.1 identified by 'xxxxxx';
安装成功,并且生成了配置文件:/etc/zabbix/web/zabbix.conf.php
最后使用 Admin/zabbix登录:
如果 Zabbix server is running 的值是 No 时,需要查看日志:
tail -f /var/log/zabbix/zabbix_server.log
可能会报错 Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (13)、
处理方法,修改 /etc/zabbix/zabbix_server.conf
然后重启:
systemctl restart zabbix-server zabbix-agent httpd
应该就好了。
如果还是不行则修改 /etc/php.ini 中 [MySQL]下面的 mysql.default_socket = /tmp/mysql.sock
9. zabbix-agent
zabbix-server可以通过zabbix-agent来监控自己,对应的配置文件为:/etc/zabbix/zabbix_agentd.conf
主动模式,允许那个ip的zabbix server向我拉取监控数据;
被动模式,允许那个ip的zabbix server向我拉取监控数据;
启动 zabbix-agent:
systemctl start zabbix-agent.service