- 安装EPEL repo
sudo yum -y install epel-release
- 安装zabbix-release
sudo rpm --import http://repo.zabbix.com/RPM-GPG-KEY-ZABBIX
sudo rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
- 安装zabbix
sudo yum -y zabbix-server-mysql zabbix-web-mysql zabbix-agent zabbix-java-gateway
- 数据库创建
创建数据库
mysql -u root -p
-----
MariaDB [(none)]> create database zabbixdb character set utf8;
MariaDB [(none)]> grant all privileges on zabbixdb.* to 'zabbixuser'@'localhost' identified by 'password';
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> exit;
导入数据
$ cd /usr/share/doc/zabbix-server-mysql-3.2.4/
$ zcat create.sql.gz | mysql -u zabbixuser -p zabbixdb
- zabbix设置
时间设置
sudo vim /etc/httpd/conf.d/zabbix.conf
------
php_value date.timezone Asia/Shanghai
设置zabbix_server.conf
sudo vim /etc/zabbix/zabbix_server.conf
-------
DBName=zabbixdb
DBUser=zabbixuser
DBPassword=password
设置zabbix_agentd.conf
sudo vim /etc/zabbix/zabbix_agentd.conf
----------
Server=127.0.0.1
ServerActive=127.0.0.1
Hostname=server1.unixmen.local
设置php.ini
sudo vim /etc/php.ini
-----------
max_execution_time = 600
max_input_time = 600
memory_limit = 256M
post_max_size = 32M
upload_max_filesize = 16M
date.timezone = Asia/Shanghai
- 访问IP限制
sudo vim /etc/httpd/conf.d/zabbix.conf
----------
Alias /zabbix /usr/share/zabbix
<Directory "/usr/share/zabbix">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from 192.168.1.0/24
</Directory>
- 防火墙设置
firewall-cmd --permanent --add-port=10050/tcp
firewall-cmd --permanent --add-port=10051/tcp
systemctl restart firewalld
- Selinux策略
服务启动错误,错误提示如下
26720:20170307:122516.516 using configuration file: /etc/zabbix/zabbix_server.conf
26720:20170307:122516.516 cannot set resource limit: [13] Permission denied
26720:20170307:122516.516 cannot disable core dump, exiting...
上网搜索到了相应解决办法,绝对不是关闭Selinux! 具体如下:
getsebool -a | grep zabbix
httpd_can_connect_zabbix --> off
zabbix_can_network --> off
-----------
setsebool -P httpd_can_connect_zabbix=1
setsebool -P zabbix_can_network=1
安装audit2allow命令
sudo yum -y install policycoreutils-python
zabbix-agent
cat /var/log/audit/audit.log | grep zabbix_agentd | grep denied | audit2allow -M zabbix_agent_setrlimit > zabbix_agent_setrlimit.te
semodule -i zabbix_agent_setrlimit.pp
systemctl start zabbix-agent
zabbix-server
cat /var/log/audit/audit.log | grep zabbix_server | grep denied | audit2allow -M zabbix_server_setrlimit > zabbix_server_setrlimit.te
semodule -i zabbix_server_setrlimit.pp
service zabbix-server start
- 设置开机启动服务
systemctl enable zabbix-server
systemctl enable zabbix-agent
systemctl start zabbix-server
systemctl start zabbix-agent
- 登录web设置
在浏览器中输入http://ip/zabbix进入设置。 设置好后,登录系统的初始用户名/密码:admin/azbbix。