yum update -y
# 临时关闭
setenforce 0
# 永久关闭
sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
# 开放端口
iptables -I INPUT -p tcp --dport 80 -j ACCEPT
iptables -I INPUT -p tcp --dport 10051 -j ACCEPT
iptables -I INPUT -p tcp --dport 10050 -j ACCEPT
# 保存防火墙规则
service iptables save
service iptables restart
# 添加 MySQL 5.6 仓库
rpm -Uvh http://dev.mysql.com/get/mysql-community-release-el6-5.noarch.rpm
# 安装 MySQL
yum install mysql-server mysql -y
# 启动 MySQL
service mysqld start
chkconfig mysqld on
# 运行安全配置脚本
mysql_secure_installation
# 按提示操作:
# 1. 输入当前 root 密码(初始为空,直接回车)
# 2. 设置 root 密码
# 3. 移除匿名用户
# 4. 禁止 root 远程登录
# 5. 移除 test 数据库
# 6. 重新加载权限表
mysql -uroot -p
# 在 MySQL 命令行中执行:
CREATE DATABASE zabbix CHARACTER SET utf8 COLLATE utf8_bin;
GRANT ALL PRIVILEGES ON zabbix.* TO 'zabbix'@'localhost' IDENTIFIED BY 'zabbix_password';
FLUSH PRIVILEGES;
EXIT;
rpm -Uvh https://repo.zabbix.com/zabbix/3.0/rhel/6/x86_64/zabbix-release-3.0-1.el6.noarch.rpm
yum install zabbix-server-mysql zabbix-web-mysql zabbix-agent -y
# 导入基础架构
cd /usr/share/doc/zabbix-server-mysql-3.0.*/create/
mysql -uzabbix -pzabbix_password zabbix < schema.sql
mysql -uzabbix -pzabbix_password zabbix < images.sql
mysql -uzabbix -pzabbix_password zabbix < data.sql
vi /etc/zabbix/zabbix_server.conf
# 修改以下参数:
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix_password
vi /etc/httpd/conf.d/zabbix.conf
# 修改时区(找到以下行并取消注释):
php_value date.timezone Asia/Shanghai
vi /etc/zabbix/zabbix_agentd.conf
# 修改以下参数:
Server=127.0.0.1
ServerActive=127.0.0.1
Hostname=Zabbix server
# 启动服务
service httpd start
service zabbix-server start
service zabbix-agent start
# 设置开机自启
chkconfig httpd on
chkconfig zabbix-server on
chkconfig zabbix-agent on
service zabbix-server status
service zabbix-agent status
service httpd status
http://服务器IP/zabbix
# 将下载的 zabbix.conf.php 上传到:
/usr/share/zabbix/conf/
如果遇到PHP版本不兼容:
# 安装 PHP 5.6
yum install http://rpms.remirepo.net/enterprise/remi-release-6.rpm
yum install yum-utils
yum-config-manager --enable remi-php56
yum update php*
# 检查 MySQL 服务
service mysqld status
# 检查防火墙
iptables -L -n
# 检查 Apache 配置
tail -f /var/log/httpd/error_log
# 调整 MySQL 配置
vi /etc/my.cnf
# 添加或修改:
[mysqld]
innodb_buffer_pool_size = 256M
max_connections = 200
这样就完成了 Zabbix 3.0 在 CentOS 6.9 上的安装。安装后建议立即修改默认密码并配置适当的监控项。