最近突然安裝zabbix總是報錯,比如
(24/27): t1lib-5.1.2-14.el7.x86_64.rpm | 166 kB 00:00:00 zabbix-web-4.4.6-1.el7.noarch. FAILED ==================================- ] 347 kB/s | 11 MB 00:00:15 ETA http://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-web-4.4.6-1.el7.noarch.rpm: [Errno 14] curl#18 - "transfer closed with 2988713 bytes remaining to read":15 ETA Trying other mirror. warning: /var/cache/yum/x86_64/7/zabbix/packages/zabbix-web-mysql-4.4.6-1.el7.noarch.rpm: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY 11 MB 00:15:26 ETA Public key for zabbix-web-mysql-4.4.6-1.el7.noarch.rpm is not installed (25/27): zabbix-web-mysql-4.4.6-1.el7.noarch.rpm | 11 kB 00:00:01 zabbix-server-mysql-4.4.6-1.el FAILED ================================== ] 7.9 kB/s | 11 MB 00:11:28 ETA http://repo.zabbix.com/zabbix/4.4/rhel/7/x86_64/zabbix-server-mysql-4.4.6-1.el7.x86_64.rpm: [Errno 14] curl#18 - "transfer closed with 2488565 bytes remaining to read" Trying other mirror. Error downloading packages: zabbix-web-4.4.6-1.el7.noarch: [Errno 256] No more mirrors to try. zabbix-server-mysql-4.4.6-1.el7.x86_64: [Errno 256] No more mirrors to try.
這其實就是網絡上的問題,如果我連接vpn的話是可以的,但是一旦使用國內網,就報錯了,於是我只能研究一下,換成了阿里雲的zabbix源。非常厲害。
網上找到的需要幾個步驟安裝,我也沒有在阿里雲上找到方便的因此只能自己編寫了一個腳本,並分享出來。
#!/bin/bash echo -e "請給出要安裝的zabbix版本號,建議使用4.x的版本 \033[31musage:./zabbix_aliyun.sh 4.0|4.4|4.5 \033[0m" echo "例如要安裝4.4版本,在命令行寫上 ./zabbix_aliyun.sh 4.4" if [ -z $1 ];then exit fi VERSION=$1 if [ -f /etc/yum.repos.d/zabbix.repo ];then rm -rf /etc/repos.d/zabbix.repo fi rpm -qa | grep zabbix-release && rpm -e zabbix-release rpm -Uvh https://mirrors.aliyun.com/zabbix/zabbix/$VERSION/rhel/7/x86_64/zabbix-release-$VERSION-1.el7.noarch.rpm sed -i "s@zabbix/.*/rhel@zabbix/$VERSION/rhel@g" /etc/yum.repos.d/zabbix.repo sed -i 's@repo.zabbix.com@mirrors.aliyun.com/zabbix@g' /etc/yum.repos.d/zabbix.repo
sed -i 's/mirrors.cloud.aliyuncs.com/mirrors.aliyun.com/g' /etc/yum.repos.d/zabbix.repo [ $? -eq 0 ] && echo "阿里雲的zabbix源替換成功" || exit 1 yum clean all yum makecache fast