一鍵安裝zabbix

2021-10-05 09:39:09 字數 2446 閱讀 4869

#!/bin/bash

read -ep "開始安裝zabbix是否上傳zabbix安裝包(yes/no):" zabbixif[

$zabbix

=="yes"];

then

echo

".....關閉防火牆...."

systemctl stop firewalld

setenforce 0

echo

"...同步時間..."

echo

'安裝同步時間軟體'

yum -y install ntpdate

if[$? -eq 0 ]

;then

echo

'安裝成功,開始同步時間.'

ntpdate pool.ntp.org

else

echo

'安裝失敗.請檢查..'

fiecho

"...安裝配置檔案mysql,httpd..."

"...建立資料庫,使用者..."

systemctl start mariadb.service

if[$? -eq 0 ]

;then

echo

"mysql已經啟動開始建立使用者....."

mysql -e "create database zabbix charset utf8;"

mysql -e "grant all on *.* to zabbix@'localhost' identified by 'zabbix';"

mysql -e "flush privileges;"

else

echo

"啟動失敗,請檢視...."

fiecho

"啟動httpd...."

"啟動成功..."

else

echo

"啟動失敗..."

fiecho

"開始安裝zabbix..."

rpm -ivh zabbix-release-3.4-2.el7.noarch.rpm

yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent &

> /dev/null

if[$? -eq 0 ]

;then

echo

"安裝成功zabbix...."

else

echo

"安裝zabbix配置包失敗正在開始重新安裝..."

yum -y install zabbix-server-mysql zabbix-web-mysql zabbix-agent &

>/dev/null

fiecho

"開始匯入資料庫....."

cd /usr/share/doc/zabbix-server-mysql-3.4.15/

zcat create.sql.gz | mysql -uzabbix -pzabbix zabbix

if[$? -eq 0 ]

;then

echo

"匯入成功..."

else

echo

"匯入失敗..."

fiecho

"配置zabbix檔案......."if[

$? -eq 0 ]

;then

sed -i "91s/#//" /etc/zabbix/zabbix_server.conf

sed -i "s/dbpassword=/dbpassword=zabbix/g" /etc/zabbix/zabbix_server.conf

else

echo

"沒有找到...."

fiecho

"啟動zabbix..."

systemctl start zabbix-server

echo

"配置php.ini檔案,修改時區"

echo

"date.timezone = asia/shanghai"

>> /etc/php.ini

echo

"重啟httpd...."

"開始測試......"

elif

[$zabbix

=="no"];

then

echo

"請上傳zabbix包..."

exit

fi

Zabbix一鍵安裝指令碼

以下指令碼僅適用於centos8 mysql httpd zabbix4.4 對於其他組合僅供參考,可根據zabbix官網提供資訊作相應修改 bin bash zabbix install.sh zabbix一鍵安裝指令碼 安裝前準備if f etc yum.repos.d zabbix.repo ...

shell指令碼一鍵安裝zabbix

bin bash zabbix 一鍵部署指令碼 echo 正在配置firewall防火牆 systemctl stop firewalld dev null systemctl disable firewalld dev null if eq 0 then echo firewall防火牆初始化完畢...

zabbix一鍵部署

bin bash 關閉防火牆,關閉selinux systemctl stop firewalld setenforce 0 配置yum源 rpm ivh if e etc yum.repos.d zabbix.repo then echo 已存在 安裝zabbix元件 yum y install ...