1. yum安装zabbix方式
1.1 环境准备
setenforce 0
sed -i "s/SELINUX=enforcing/SELINUX=disabled/g" /etc/selinux/config
1.2 LAMP安装
yum install -y httpd mariadb mariadb-server mariadb-client php php-mysql
启动服务
systemctl start mariadb.service
1.3 Zabbix安装
yum install -y http://mirrors.aliyun.com/zabbix/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX
yum install zabbix-server-mysql zabbix-web-mysql zabbix-get zabbix-agent
1.4 创建数据库
mysqladmin -u root password '111111'
mysql -uroot -p
MariaDB [(none)]> CREATE DATABASE zabbix DEFAULT CHARACTER SET utf8 COLLATE utf8_bin;
MariaDB [(none)]> GRANT ALL ON zabbix.* TO 'zabbix'@'%' IDENTIFIED BY 'zabbix';
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> quit
1.5 导入数据
cd /usr/share/doc/zabbix-server-mysql-3.2.1
zcat create.sql.gz | mysql -uroot zabbix -p
1.6 修改配置
修改数据库连接信息
vim /etc/zabbix/zabbix_server.conf
DBHost=localhost
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
修改时区
vim /etc/httpd/conf.d/zabbix.conf
php_value date.timezone Asia/Chongqing
1.7 启动
systemctl start httpd
systemctl start zabbix-server
systemctl start zabbix-agent
通过 http://ip/zabbix
访问默认用户名/密码:Admin/zabbix,注意用户名也区分大小写
1.8常见问题
默认mysql服务是监听所有网卡,不安全
在/etc/my.cnf中[mysqld]下添加bind-address = 127.0.0.1
然后重启服务
apache只监听ip v6上的80端口
修改/etc/httpd/conf/httpd.conf中的
Listen 80为Listen 0.0.0.0:80
然后重启服务
默认centos7开启了防火墙,关闭并禁用防火墙
systemctl stop firewalld.service
systemctl disable firewalld.service