server端(ip 192.168.200.15)
proxy端(ip 192.168.200.22)
agent端(ip 192.168.200.12)
server端:
#安装数据库
[mariadb] name=MariaDB baseurl=http://mirrors.ustc.edu.cn/mariadb/yum/10.3/centos7-amd64/ gpgkey=http://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB gpgcheck=1 yum -y install MariaDB systemctl restart mysql systemctl enable mariadb
#安装zabbix
https://www.zabbix.com/download?zabbix=4.2&os_distribution=centos&os_version=7&db=mysql
rpm -Uvh https://repo.zabbix.com/zabbix/4.0/rhel/7/x86_64/zabbix-release-4.0-2.el7.noarch.rpm
yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent
#创建数据库
mysql -uroot -proot
mysql> create database zabbix ;
mysql> grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';
mysql> quit;
#导入zabbix服务器所需要的表和数据
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql -uzabbix -pzabbix zabbix
#编辑文件
vim /etc/zabbix/zabbix_server.conf
DBPassword=zabbix
#编辑文件设置时区
vim /etc/httpd/conf.d/zabbix.conf
php_value date.timezone Asia/Shanghai(打开注释)
#启动服务和开机自启
systemctl restart zabbix-server zabbix-agent httpd
systemctl enable zabbix-server zabbix-agent httpd
firewall-cmd --add-port=10051/tcp --permanent
firewall-cmd --add-port=10050/tcp --permanent
#浏览器访问
192.168.200.15/zabbix
proxy端:
#安装数据库
[mariadb] name=MariaDB baseurl=http://mirrors.ustc.edu.cn/mariadb/yum/10.3/centos7-amd64/ gpgkey=http://mirrors.ustc.edu.cn/mariadb/yum/RPM-GPG-KEY-MariaDB gpgcheck=1 systemctl restart mysql systemtl enable mariadb
#安装zabbix组件
yum -y install zabbix-proxy
#编辑文件
vim /etc/zabbix/zabbix_proxy.conf
Server=192.168.254.15
Hostname=Zabbix proxy
DBName=zabbix_proxy
DBUser=zabbix
DBPassword=zabbix
#重启服务
service zabbix-proxy restart
firewall-cmd --add-port=10051/tcp --permanent
firewall-cmd --add-port=10050/tcp --permanent
#创建数据库和用户
create database zabbix_proxy ;
grant all privileges on zabbix_proxy.* to zabbix@localhost identified by 'zabbix';
#解压缩文件到数据库中
zcat /usr/share/doc/zabbix-proxy-mysql-*/schema.sql.gz | mysql -uzabbix -pzabbix zabbix_proxy
agent端:
#修改agent端配置文件
vim /etc/zabbix/zabbix-agent.conf
Server=192.168.254.22
ServerActive=192.168.254.22
Hostname=class
#重启客户端
systemctl restart zabbix-agent
firewall-cmd --add-port=10050/tcp --permanent