zabbix官方源替换为阿里云的zabbix源,一键脚本。(安装zabbix报错curl#18 - "transfer closed with 2988713 bytes remaining to read":15 ETA Trying other mirro)

最近突然安装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

 

posted @ 2020-01-23 11:02  峰哥ge  阅读(1701)  评论(0编辑  收藏  举报