一、环境初始化
设置主机名称
hostnamectl set-hostname zabbix-server && bash
hostnamectl set-hostname zabbix-agent && bash
hostnamectl set-hostname zabbix-proxy && bash
关闭防火墙、关闭SELinux
systemctl stop firewalld && systemctl disable firewalld
sed -i ‘s/enforcing/disabled/’ /etc/selinux/config && setenforce 0
设置hosts文件
cat >> /etc/hosts <<EOF
192.168.180.210 zabbix-server
192.168.180.200 zabbix-agent
192.168.180.190 zabbix-proxy
EOF
yum install -y vim lrzsz unzip net-tools
开启时间同步服务
zabbix-server:
yum install chrony -y
vim /etc/chrony.conf
server ntp6.aliyun.com iburst
allow 192.168.0.0/16
systemctl enable chronyd.service && systemctl restart chronyd.service
chronyc sources && chronyc -a makestep
zabbix-agent/zabbix-proxy:
yum install chrony -y
vim /etc/chrony.conf
server zabbix-server iburst
systemctl enable chronyd.service && systemctl restart chronyd.service && chronyc sources
所有主机执行
YUM源安装
rpm -Uvh http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
在Zabbix Server主机上安装数据库
yum install -y mariadb-server
systemctl start mariadb
systemctl enable mariadb
#安装完成后,可使用命令对数据库进行初始化
mysql_secure_installation
设置权限
mysql
CREATE DATABASE zabbix character set utf8 collate utf8_bin;
CREATE DATABASE zabbix_proxy character set utf8 collate utf8_bin;
USE mysql;
UPDATE mysql.user SET password = PASSWORD(‘zabbix’) WHERE user = ‘root’;
GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@‘localhost’ IDENTIFIED BY ‘zabbix’;
GRANT ALL PRIVILEGES ON zabbix.* TO zabbix@‘%’ IDENTIFIED BY ‘zabbix’;
GRANT ALL PRIVILEGES ON zabbix_proxy.* TO ‘zabbix’@‘localhost’ IDENTIFIED BY ‘zabbix’;
GRANT ALL PRIVILEGES ON zabbix_proxy.* TO ‘zabbix’@‘%’ IDENTIFIED BY ‘zabbix’;
FLUSH PRIVILEGES;
quit;
在Server主机上部署LNMP+Zabbix Server
yum install -y nginx php-fpm php dejavu-sans-fonts php-bcmath php-gd php-ldap php-mbstring php-xml php-mysql vlgothic-p-fonts
yum install -y zabbix-server-mysql-3.2.11
yum install -y zabbix-web-mysql
zcat /usr/share/doc/zabbix-server-mysql-3.2.11/create.sql.gz | mysql -uzabbix -pzabbix zabbix
vim /etc/zabbix/zabbix_server.conf
DBHost=zabbix-server
DBName=zabbix
DBUser=zabbix
DBPassword=zabbix
systemctl start zabbix-server
systemctl enable zabbix-server
修改NGINX的配置文件
vim /etc/nginx/nginx.conf
index index.html index.php;
location ~ .php$ {
fastcgi_buffer_size 128k;
fastcgi_buffers 32 32k;
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME
d
o
c
u
m
e
n
t
r
o
o
t
document_root
documentr?ootfastcgi_script_name;
}
编辑php.ini文件
vim /etc/php.ini
post_max_size = 16M —最大的POST数据限制
max_execution_time = 300 —最长执行时间
max_input_time = 300 —接收数据时间
memory_limit = 128M —内存的使用
upload_max_filesize = 2M —文件上传的大小
date.timezone = Asia/Shanghai —时区
复制web目录
安装zabbix-web-3.2.11-1.el7.noarch.rpm
cp -rp /usr/share/zabbix /usr/share/nginx/html/
systemctl start nginx php-fpm
systemctl enable nginx php-fpm
客户端:Agent
部署Agent
rpm -Uvh http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
yum install -y zabbix-agent
编辑Zabbix Agent配置文件
vim /etc/zabbix/zabbix_agentd.conf
Server=192.168.180.210
ServerActive=192.168.180.210 —服务器IP
Hostname=zabbix-agent —主机名和hostname匹配
启动Zabbix Agent
systemctl start zabbix-agent.service
systemctl enable zabbix-agent.service
第三台服务器:部署Zabbix Proxy
在安装基于MySQL的Zabbix Proxy
rpm -Uvh http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh http://repo.zabbix.com/zabbix/3.2/rhel/7/x86_64/zabbix-release-3.2-1.el7.noarch.rpm
yum install -y zabbix-proxy-mysql
yum install -y mysql
zcat /usr/share/doc/zabbix-proxy-mysql-3.2.*/schema.sql.gz | mysql -h192.168.180.210 -uzabbix zabbix_proxy -pzabbix
编辑Zabbix Proxy的配置文件
vim /etc/zabbix/zabbix_proxy.conf
Server=192.168.180.210
Hostname=Zabbix Proxy #Proxy 本地的名称, 此名称需要与将来在 server 端的 Web 页面上的代理程序名称一致, 名称自定义
DBHost=192.168.180.210
DBName=zabbix_proxy
DBUser=zabbix
DBPassword= //输入实际的密码, 本实验中为 zabbix
DBPort=3306
systemctl start zabbix-proxy
systemctl enable zabbix-proxy
安装Zabbix Agent
yum install -y zabbix-agent
vim /etc/zabbix/zabbix_agentd.conf
Server=192.168.180.190 #指向 Proxy 地址
ServerActive=192.168.180.190 #指向 Proxy 地址
Hostname=Zabbix Agent on Proxy #Agent 本地的名称, 需要与将来在 Server 端的 Web 页面上的主机名称一致, 名称自定义
systemctl start zabbix-agent.service
systemctl enable zabbix-agent.service