[CentOS8]yum阿里源

一键脚本

cat > 01.yumrepo.sh << 'EOF'
# 创建备份路径
mkdir -p /etc/yum.repos.d/repo.bak/
# 备份源
mv /etc/yum.repos.d/CentOS-* /etc/yum.repos.d/repo.bak/
# 导入镜像内容到yum文件中
cat > /etc/yum.repos.d/CentOS-AppStream.repo <<'EOO'
# CentOS-AppStream.repo
#
# The mirror system uses the connecting IP address of the client and the
# update status of each mirror to pick mirrors that are updated to and
# geographically close to the client.  You should use this for CentOS updates
# unless you are manually picking other mirrors.
#
# If the mirrorlist= does not work for you, as a fall back you can try the
# remarked out baseurl= line instead.
#
#

[AppStream]
name=CentOS-$releasever - AppStream
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=AppStream&infra=$infra
#baseurl=http://mirror.centos.org/$contentdir/$releasever/AppStream/$basearch/os/
baseurl=https://mirrors.aliyun.com/centos/$releasever/AppStream/$basearch/os/
gpgcheck=1
enabled=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
EOO
#清除yum缓存
yum clean all
#重新做yum 缓存
yum makecache
# 下载阿里源
curl -O http://mirrors.aliyun.com/repo/Centos-8.repo
mv Centos-8.repo /etc/yum.repos.d/
# 安装 epel
dnf -y install epel-release
EOF
# 执行该脚本
bash 01.yumrepo.sh

END

posted @ 2020-03-16 10:31  LeoShi2020  阅读(1457)  评论(2编辑  收藏  举报