shell编写yum安装监控zabbix脚本

本文介绍如何利用Shell脚本自动化完成YUM安装Zabbix监控软件的过程,包括下载配置文件、安装依赖、配置服务及启动检查等步骤,帮助提升系统监控部署效率。
摘要由CSDN通过智能技术生成
#!/bin/bash
#zabbix  5.0 
#安装zabbix源、修改为aliyun源
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;grant all privileges on zabbix.* to zabbix@'%' identified by 'zabbix';grant all privileges on zabbix.* to zabbix@localhost identified by 'zabbix';flush privileges;"
 
#导入数据
zcat /usr/share/doc/zabbix-server-mysql-5.0.7/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

https://www.jianshu.com/p/28ed7cd069f3

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值