RedHat7配置YUM使用阿里Repo源

一键配置脚本:

#!/bin/bash
#仅兼容RedHat7

uname -a
cat /etc/redhat-release
rpm -qa|grep yum

rpm -aq | grep yum | xargs rpm -e --nodeps
whereis yum && rm -rf /etc/yum   # 可提前打包备份目录

#下载安装CentOS7版YUM
mkdir ~/install-yum
wget https://www.itca.cc/file/install-yum.tar
tar -xvf install-yum.tar -C ~/install-yum

cd ~/install-yum
rpm -ivh python-urlgrabber*
rpm -ivh python-iniparse*
rpm -ivh yum*

#配置Repo源
wget -O /etc/yum.repos.d/CentOS-7.repo http://mirrors.aliyun.com/repo/Centos-7.repo
wget -O /etc/yum.repos.d/epel-7.repo http://mirrors.aliyun.com/repo/epel-7.repo
sed -i 's/$releasever/7/g' /etc/yum.repos.d/CentOS-7.repo
sed -i 's/$releasever/7/g' /etc/yum.repos.d/epel-7.repo
yum clean all && yum makecache

#安装必备YUM插件
yum -y install yum-utils yum-langpacks yum-rhn-plugin PackageKit-yum

你可能感兴趣的:(RedHat7配置YUM使用阿里Repo源)