zabbix架构图
zabbix-server部署配置:
第一步:更新yum源,替换为阿里 + epel 源 + zabbix源
[root@ROOT ~]# rm -rf /etc/yum.repos.d/*
[root@ROOT ~]# wget -O /etc/yum.repos.d/Centos-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
[root@ROOT ~]# wget -O /etc/yum.repos.d/epel-7 http://mirrors.aliyun.com/repo/Centos-7.repo
[root@ROOT ~]# rpm -ivh http://repo.zabbix.com/zabbix/3.4/rhel/7/x86_64/zabbix-release-3.4-2.el7.noarch.rpm
第二步:安装mysql (mariadb代替) + php + zabbix-server
[root@ROOT ~]# yum install -y mariadb mariadb-server
[root@ROOT ~]# yum install -y php php-mysql
[root@ROOT ~]# yum install -y zabbix-server-mysql zabbix-get zabbix-web zabbix-web-mysql zabbix-agent zabbix-sender
第三步:启动、开机自启mariadb + httpd + zabbix-server
ps:zabbix-web 默认为 apache
[root@ROOT ~]# systemctl start mariadb httpd zabbix-server
[root@ROOT ~]# systemctl enable mariadb httpd zabbix-server
// [root@ROOT ~]# systemctl status mariadb httpd zabbix-server
第四步:配置mysql:创建zabbix数据库 + zabbix用户
[root@ROOT ~]# mysql
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
Query OK, 1 row affected (0.00 sec)
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
Query OK, 0 rows affected (0.01 sec)
MariaDB [(none)]> quit
Bye
第五步:配置mysql:导入zabbix初始化的数据库文件
[root@ROOT ~]# zcat /usr/share/doc/zabbix-server-mysql-3.4.15/create.sql.gz | mysql zabbix -uzabbix -pzabbix
# ps:zcat = 不解压查看压缩包信息
第六步:配置zabbix:修改数据库信息
[root@ROOT ~]# vim /etc/zabbix/zabbix_server.conf
91:DBHost=localhost
100:DBName=zabbix
116:DBUser=zabbix
131:DBSocket=/var/lib/mysql/mysql.sock
# ps:显示行号 = :set nu 查找文本内容 = /字符
# ps:定位mysql.sock文件:
// [root@ROOT ~]# find / -name "*mysql.sock"
第七步:配置httpd:修改zabbix时区信息
[root@ROOT ~]# vim /etc/httpd/conf.d/zabbix.conf
php_vlue date.timezone Asia/Shanghai
第八步:关闭 防火墙 + selinux
[root@web01 ~]# systemctl stop firewalld
[root@web01 ~]# systemctl disable firewalld
[root@web01 ~]# setenforce 0
[root@web01 ~]# sed -i 's#enforcing#disable#g' /etc/selinux/config
第九步:重启相关服务,查看80端口
[root@ROOT ~]# systemctl restart mariadb httpd zabbix-server
[root@ROOT ~]# netstat -lnp|grep "80"
tcp6 0 0 :::80 :::* LISTEN 6868/httpd
unix 2 [ ACC ] STREAM LISTENING 19180 1055/master private/verify
// httpd启动失败:1.80端口被占用;2.配置文件有问题
// httpd更换80端口为8080:
// [root@ROOT ~]# sed -i "s#Listen 80#Listen 8080#g" /etc/httpd/conf.d/httpd.conf