系统 Centos7.4
https://github.com/findsec-cn/zabbix
centos 7 添加阿里云镜像
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
*安装时出现以下情况Another app is currently holding the yum lock; waiting for it to exit… ----- State : Sleeping, pid: 13168
解决方法: cat /var/run/yum.pid显示一个进程id,其他的 可能是系统自动升级正在运行,所以yum被锁定了。
执行rm -rf /var/run/yum.pid 来强行解除锁定,然后你的yum就可以运行了。
yum install epel-release
安装常用的开发组件
yum groups install “Development Tools”
yum groups info “Development Tools”
增加Zabbix镜像源
rpm -ivh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-1.el7.noarch.rpm
关闭SElinux
systemctl stop firewalld.service
systemctl disable firewalld.service
vim /etc/selinux/config
#yum install iptables-services 未操作
安装Zabbix Server和Frontend
yum install zabbix-server-mysql
-----安装出错 Error downloading packages: zabbix-server-mysql-4.0.12-1.el7.x86_64: [Errno 256] No more mirrors to try
yum install http://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-server-mysql-4.0.12-1.el7.x86_64.rpm 就解决了
yum install zabbix-web-mysql 安装出错会导致没有 /etc/php.ini 这个文件
安装MySQL
yum install mariadb-server
systemctl start mariadb.service
systemctl status mariadb.service
mysql_secure_installation 初始化MySQL数据库 回车 n y n y y
安装zabbix-server-mysql-4.0.12-1.el7.x86_64.rpm、zabbix-web-4.0.12-1.el7.noarch.rpm和zabbix-release-4.0-1.el7.noarch.rpm时出错可以先下载到本地,然后 yum install zabbix-server-mysql-4.0.12-1.el7.x86_64.rpm zabbix-web-4.0.12-1.el7.noarch.rpm zabbix-release-4.0-1.el7.noarch.rpm这三个包
创建数据库
mysql -uroot -p
create database zabbix character set utf8 collate utf8_bin;
grant all privileges on zabbix.* to zabbix@localhost identified by ‘zabbix@zzz123’; 创建用户,让用户可以本地访问zabbix表
flush privileges; 刷新权限
以上是在数据库中操作
导入数据结构
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -pzabbix@zzz123 zabbix
配置Zabbix Serve
vim /etc/zabbix/zabbix_server.conf
DBHost=localhost DBPassword=zabbix@zzz123
启动Zabbix Server
systemctl start zabbix-server.service
systemctl status zabbix-server.service
more /var/log/zabbix/zabbix_server.log 查看日志
配置Zabbix frontend
vim /etc/php.ini
max_execution_time = 300
memory_limit = 128M
post_max_size = 16M
upload_max_filesize = 2M
max_input_time = 300
max_input_vars = 10000
always_populate_raw_post_data = -1
date.timezone = Asia/Shanghai
启动httpd
systemctl start httpd.service
systemctl status httpd.service
http://192.168.100.201/zabbix/setup.php
Configure DB connection 和zabbix_server.conf文件对应
Database port 0 Database name zabbix User zabbix Password zabbix@findsec123
Zabbix server details Host localhost Port 10051 Name Zabbix Server ----和zabbix agent 的hostname 对应
Admin
zabbix
安装Zabbix Agent
yum install zabbix-agent
systemctl start zabbix-agent.service