一鍵搭建zabbix指令碼

2021-10-06 01:39:09 字數 2568 閱讀 3040

#!/bin/bash

#1.配置防火牆和selinux

echo

"正在配置firewall防火牆……"

systemctl stop firewalld >> /dev/null

systemctl disable firewalld >>/dev/null

if[ $? -eq 0 ]

;then

echo

"firewall防火牆初始化完畢!"

fiecho

"正在關閉selinux……"

setenforce 0 > /dev/null 2>&1

sed -i '/^selinux=/s/=.*/=disabled/'

/etc/selinux/config

if[ $? -eq 0 ]

;then

echo

"selinux初始化完畢!"

fi#2.安裝lamp環境

echo

"安裝lamp"

"lamp 安裝成功"

else

echo

"lamp 安裝失敗"

fi#3.啟動資料庫

mysql -e "create database zabbix charset utf8;grant all on zabbix.* to zabbix@'localhost' identified by 'zabbix';flush privileges;"

if[ $? -eq 0 ]

;then

echo

"資料庫初始化完成"

else

echo

"資料庫初始化失"

fi#4.啟動httpd服務並設定為開機自啟

"apache 啟動成功"

else

echo

"apache 啟動失敗"

fi#5.安裝zabbix服務

rpm -ivh zabbix-release-3.4-2.el7.noarch.rpm &>/dev/null &>/dev/null

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

if[ $? -eq 0 ]

;then

echo

"zabbix-server安裝完成"

else

echo

"zabbix-server安裝失敗"

fi#6.匯入資料庫

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

"資料匯入失敗"

fi#7.配置zabbix配置檔案並啟動

sed -i '/# dbpassword=/a\dbpassword=zabbix'

/etc/zabbix/zabbix_server.conf

if[ $? -eq 0 ]

;then

echo

"zabbix配置完成"

else

echo

"zabbix配置失敗"

fisystemctl start zabbix-server && systemctl enable zabbix-server &>/dev/null

if[ $? -eq 0 ]

;then

echo

"zabbix-server 服務啟動成功"

else

echo

"zabbix-server 服務啟動失敗"

fised -i '/^;date.timezone/a\date.timezone = asia/shanghai'

/etc/php.ini

#8。重啟httpd服務

"apache 啟動成功"

else

echo

"apache 啟動失敗"

fi#9。修改zabbix亂碼

sed -i s/graphfont/simkai/g /usr/share/zabbix/include/defines.inc.php

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 ...