Linux系列

由于国外的镜像源网速过慢,我们通常会配置国内镜像源。不得不说HW的镜像源还是很强大的,内容很全,maven、操作系统、容器应有尽有。

首先我们先备份一下原始镜像源

cp -a /etc/apt/sources.list /etc/apt/sources.list.bak

ubuntu系列 更新镜像源

sed -i "s@http://.*archive.ubuntu.com@http://mirrors.huaweicloud.com@g" /etc/apt/sources.list
sed -i "s@http://.*security.ubuntu.com@http://mirrors.huaweicloud.com@g" /etc/apt/sources.list

debian系列 更新镜像源

sed -i "s@http://ftp.debian.org@https://mirrors.huaweicloud.com@g" /etc/apt/sources.list
sed -i "s@http://security.debian.org@https://mirrors.huaweicloud.com@g" /etc/apt/sources.list

上面执行完毕后,我们需要更新一下索引

sudo apt-get --force-yes update

执行到这一步,ubuntu系列和debian系列更新镜像源已经完成了。

下面是Centos Yum仓库更新方法

#!/bin/sh
export LANG=UTF-8
export LANGUAGE=UTF-8
# 备份配置文件
cp -a /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak
# 下载新的CentOS-Base.repo文件到/etc/yum.repos.d/目录下
wget -O /etc/yum.repos.d/CentOS-Base.repo https://mirrors.huaweicloud.com/repository/conf/CentOS-AltArch-7.repo
# 清除原有yum缓存
yum clean all
# 刷新缓存
yum makecache

复制上面代码新建centos.sh文件放进去,执行 sh centos.sh 就可以了

原文地址:https://www.cnblogs.com/Python-XiaCaiP/p/12794382.html