server服务端
关闭停用防火墙
systemctl stop firewalld.service
systemctl disable firewalld.service
停用selinux
vim /etc/selinux/config
SELINUX=disabled
重启reboot
添加清华源的zabbix仓库地址
sudo rpm -Uvh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
sudo yum install -y centos-release-scl
修改zabbix地址为清华源
sed -i 's/http:\/\/repo.zabbix.com/https:\/\/mirrors.aliyun.com\/zabbix/g' /etc/yum.repos.d/zabbix.repo
yum clean all
vim /etc/yum.repos.d/zabbix.repo
sudo yum install zabbix-server-mysql zabbix-agent zabbix-web-mysql-scl zabbix-apache-conf-scl
安装数据库
yum install -y mariadb-server
systemctl start mariadb #启动数据库
systemctl enable mariadb #设置开机自启
数据库配置
#进入数据库
mysql
创建存储数据的库,并支持中文(库名:zabbix)
MariaDB [(none)]> create database zabbix character set utf8 collate utf8_bin;
#授权连接数据库的用户,并设置密码(用户名:zabbix)
MariaDB [(none)]> create user zabbix@localhost identified by 'zabbix';
#数据库授权
MariaDB [(none)]> grant all privileges on zabbix.* to zabbix@localhost;
#在Zabbix服务器主机上,导入初始架构和数据。系统将提示您输入新创建的密码
zcat /usr/share/doc/zabbix-server- mysql*/create.sql.gz | mysql -uzabbix -p zabbix
#Zabbix服务器配置数据库
vim /etc/zabbix/zabbix_server.conf
100 DBName=zabbix #存储监控数据的库名
116 DBUser=zabbix #连接数据库的用户
124 DBPassword=zabbix #设置zabbix用户密码
#为Zabbix配置正确的时区
vim /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
php_value[date.timezone] = Asia/Shanghai #亚洲/上海
#启动所有服务
systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
#设置服务随机自启
systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm
netstat -nltp |grep
打开浏览器ip/zabbix登录
zabbix服务端部署
#!/bin/bash
#Zabbix-Server 5.0
#安装zabbix源、aliyun YUM源
cd /etc/yum.repos.d/
rpm -Uvh https://repo.zabbix.com/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
sed -i.bak 's#repo.zabbix.com#mirrors.aliyun.com/zabbix#' zabbix.repo
sed -i 's#enabled=0#enabled=1#' zabbix.repo
#安装zabbix
yum -y install zabbix-server-mysql zabbix-agent
yum -y install centos-release-scl
yum -y install zabbix-web-mysql-scl zabbix-apache-conf-scl
#安装启动 mariadb数据库
yum -y install mariadb mariadb-server httpd
systemctl start mariadb.service
#创建数据库
mysql -e 'create database zabbix character set utf8 collate utf8_bin;'
mysql -e 'grant all privileges on zabbix.* to zabbix@localhost identified by "zabbix";'
mysql -e 'flush privileges;'
#导入数据
zcat /usr/share/doc/zabbix-server-mysql-5.0.3/create.sql.gz|mysql -uzabbix -pzabbix -Dzabbix
#配置zabbixserver连接mysql
sed -i.bak '/^# DBPassword=*/i DBPassword=zabbix' /etc/zabbix/zabbix_server.conf
#添加时区
sed -i.bak '/^; php_value[date.timezone]*/i php_value[date.timezone] = Asia/Shanghai' /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
#解决中文乱码
yum -y install wqy-microhei-fonts
\cp /usr/share/fonts/wqy-microhei/wqy-microhei.ttc /usr/share/fonts/dejavu/DejaVuSans.ttf
#启动服务
systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
#开机自启动
systemctl enable mariadb.service
systemctl enable httpd
systemctl enable zabbix-server
#输出信息
echo "浏览器访问 http://`hostname -I|awk '{print $1}'`/zabbix"