指令碼安裝zabbix

2021-10-05 15:00:18 字數 3271 閱讀 8741

原始碼安裝zabbix 只需執行指令碼即可安裝

#!/bin/bash

echo

"關閉防火牆,selinux"

systemctl stop firewalld && setenforce 0 &

> /dev/null

echo

"同步系統時間"

ntpdate pool.ntp.org

echo

"寫入阿里yum源"

cat> /etc/yum.repos.d/zabbix_aliyun.repo<<\eof

[zabbix]

name=zabbix official repository - $basearch

baseurl=

enabled=1

gpgcheck=0

gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-zabbix-a14fe591

[zabbix-debuginfo]

name=zabbix official repository debuginfo - $basearch

baseurl=debuginfo/

enabled=0

gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-zabbix-a14fe591

gpgcheck=0

[zabbix-non-supported]

name=zabbix official repository non-supported - $basearch

baseurl=

enabled=1

gpgkey=file:///etc/pki/rpm-gpg/rpm-gpg-key-zabbix

gpgcheck=0

eofecho

""#安裝mysql,zabbix

echo

"正在安裝mysql和zabbix,請稍候......"

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

> /dev/null

rpm -qa|

grep mariadb-server &

> /dev/nullif[

$? -eq 0 ]

;then

echo

"mysql安裝成功"

else

echo

"請重新安裝mysql"

firpm -qa |

grep zabbix &

> /dev/nullif[

$? -eq 0 ]

;then

echo

"zabbix安裝成功"

else

echo

"請重新安裝zabbix"

fiecho

"啟動mysql,建立使用者並授權!"

systemctl start mariadbif[

$? -eq 0 ]

;then

echo

"mysql已啟動,請建立授權使用者"

mysql -e "create database zabbix character set utf8 collate utf8_bin"

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

mysql -e "flush privileges"

else

echo

"啟動失敗,請處理"

fiecho

"匯入資料"

zcat /usr/share/doc/zabbix-server-mysql-4.4.7/create.sql.gz |mysql -uzabbix -pzabbix zabbixif[

$? -eq 0 ]

;then

echo

"修改zabbix配置檔案"

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

sed -i '124c dbpassword=zabbix' /etc/zabbix/zabbix_server.conf

echo

"修改時區"

"導庫失敗,請處理"

fiecho

"啟動zabbix服務,和httpd"

"httpd已啟動"

else

echo

"請重啟httpd"

fiss -ntl |

grep 10051 &

> /dev/nullif[

$? -eq 0 ]

;then

echo

"zabbix-server已啟動"

else

echo

"請重啟zabbix-server"

fiss -ntl |

grep 10050 &

> /dev/nullif[

$? -eq 0 ]

;then

echo

"zabbix-agent已啟動"

else

echo

"請重啟zabbix-agent"

fiecho

"zabbix-server部署成功,請在瀏覽器測試"

#字型漢化 (注意字型漢化要把上面先執行完成出現介面後再進入編輯)

#rm -rf /usr/share/zabbix/assets/fonts/graphfont.tt

f

#cp /root/graphfont.ttf /usr/share/zabbix/assets/fonts/

#echo 「zabbix-server漢化ok」

Zabbix一鍵安裝指令碼

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

zabbix通過shell指令碼安裝異常問題定位

htxk 106主機資訊現象如下 通過zabbix get命令 zabbix get 7189 check access restrictions in zabbix agent configuration 解決方法 通過檢視zabbix相關的檔案,發現在usr local sbin目錄下存在zab...

shell指令碼一鍵安裝zabbix

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