一分钟安装zabbix、脚本安装zabbix

1,一分钟安装zabbix、脚本安装zabbix

只需修改:ZBX_SERVER_NAME=本机IP

#!/bin/bash
#date:2023
#author:懒人p

#检查操作系统版本,该脚本只能运行在 Centos 7.x 系统上
cat /etc/redhat-release |grep -i centos |grep '7.[[:digit:]]' >/dev/null
if [[ $? != 0 ]] 
then
    echo -e "不支持的操作系统,该脚本只适用于CentOS 7.x  x86_64 操作系统"
    exit 1
fi
#配置无人值守的安装,定义安装过程中需要用到的一些信息
DBPassword=ap123
CacheSize=256M
ZBX_SERVER_NAME=192.168.67.135
#http_port=80

#配置 Zabbix 5.0 YUM 源
rpm -Uvh https://mirrors.aliyun.com/zabbix/zabbix/5.0/rhel/7/x86_64/zabbix-release-5.0-1.el7.noarch.rpm
sed -i 's/repo.zabbix.com/mirrors.aliyun.com\/zabbix/g' /etc/yum.repos.d/zabbix.repo
sed -i '11s/enabled=0/enabled=1/' /etc/yum.repos.d/zabbix.repo
yum clean all

#安装 Zabbix 5.0 Server、Agent
yum -y install zabbix-server-mysql zabbix-agent centos-release-scl
#yum -y install zabbix-server-mysql-5.0.23
#安装SCL储存库,zabbix web前端,监控web
yum -y install zabbix-web-mysql-scl zabbix-apache-conf-scl 

#下载配置 Zabbix Server
sed -i "/^# DBPassword=/a DBPassword=$DBPassword" /etc/zabbix/zabbix_server.conf
sed -i "/^# CacheSize=8M/a CacheSize=$CacheSize" /etc/zabbix/zabbix_server.conf
sed -i "/^# StartPingers=1/a StartPingers=10" /etc/zabbix/zabbix_server.conf
sed -i 's/; php_value\[date.timezone\] = Europe\/Riga/php_value\[date.timezone\] = Asia\/Shanghai/' /etc/opt/rh/rh-php72/php-fpm.d/zabbix.conf
#sed -i 's/Listen 80/Listen '$http_port'/' /etc/httpd/conf/httpd.conf


#下载配置Zabbix 数据库(创建账号,并导入zabbix库结构)
yum -y install mariadb mariadb-server
systemctl enable mariadb.service
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 '$DBPassword';"
mysql -e "flush privileges;"
zcat /usr/share/doc/zabbix-server-mysql*/create.sql.gz | mysql zabbix 

#启动 Zabbix 相关服务,并设置开机自启动
systemctl enable zabbix-server zabbix-agent httpd rh-php72-php-fpm
systemctl start zabbix-server zabbix-agent httpd rh-php72-php-fpm


#配置 Zabbix 防火墙
#firewall-cmd --permanent --zone=public --add-port=10051/tcp
#firewall-cmd --permanent --zone=public --add-port=162/udp
#firewall-cmd --permanent --zone=public --add-port=$http_port/tcp
#firewall-cmd --reload

#禁用服务器防火墙、SELinux
systemctl stop firewalld
systemctl disable firewalld
setenforce 0
sed -i 's/SELINUX=enforcing/SELINUX=permissive/' /etc/sysconfig/selinux

#安装成功,提示访问方式
echo -e  "\n您可以通过以下地址来访问 Zabbix Web Page\n"
for i in `ip a | grep 'inet ' | awk '{print $2}' | awk -F '/' '{print $1}'` ; do echo -e "\thttp://$i:$http_port/zabbix" ; done

2,yum快速安装zabbix监控

链接:快速安装zabbix监控

  • 1
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值