shell編寫yum安裝監(jiān)控zabbix腳本

#!/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
 
#安裝啟動(dòng) mariadb數(shù)據(jù)庫
yum -y install mariadb mariadb-server httpd
systemctl start mariadb.service
 
#創(chuàng)建數(shù)據(jù)庫
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;"
 
#導(dǎo)入數(shù)據(jù)
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
 
#添加時(shí)區(qū)
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
 
#啟動(dòng)服務(wù)
systemctl restart zabbix-server zabbix-agent httpd rh-php72-php-fpm
 
#開機(jī)自啟動(dòng)
systemctl enable mariadb.service
systemctl enable httpd
systemctl enable zabbix-server
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容