#!/bin/bash
#首先关闭防火墙以及SElinux
systemctl stop firewalld
setenforce 0
#拉取官方源
rpm -ivh http://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-release-4.4-1.el7.noarch.rpm
#下载相关组件(重复执行数次以防网络问题自动断开)
yum -y install zabbix-server-mysql zabbix-web-mysql mariadb mariadb-server zabbix-server zabbix-agent
yum -y install zabbix-server-mysql zabbix-web-mysql mariadb mariadb-server zabbix-server zabbix-agent
yum -y install zabbix-server-mysql zabbix-web-mysql mariadb mariadb-server zabbix-server zabbix-agent
#启动数据库创建库并授权用户
systemctl start mariadb
mysql -e "create database zabbix;"
mysql -e "grant all on zabbix.* to 'tom'@'localhost' identified by '123';"
mysql -e "flush privileges;"
#导入初始数据
cd /usr/share/doc/zabbix-server-mysql-4.4.1/ && zcat create.sql.gz | mysql -utom -p123 zabbix
#修改zabbix-server配置文件
sed -i 's/# DBPassword=/DBPassword=123/g' /etc/zabbix/zabbix_server.conf
sed -i 's/DBUser=zabbix/DBUser=tom/g' /etc/zabbix/zabbix_server.conf
#修改时区
sed -i 's/# php_value date.timezone Europe/Riga/php_value date.timezone Asia/Shanghai/g' /etc/httpd/conf.d/zabbix.conf
#启动所有服务
yum -y install httpd
systemctl restart zabbix-server zabbix-agent httpd
可通过本机IP/zabbix 来进行web页面的安装展示