RHEL/RedHat:替换yum阿里源为163源
学习自:Redhat7或Centos7自带Yum源卸载并安装国内Yum源_redhat 7 repo_KrityCat的博客-CSDN博客
起因
之前用阿里源的镜像下载时经常出现HTTP 404,然后就一直try other mirrors,估计是源出了问题,遂修改阿里源为163源,之后问题解决
流程
1、自带yum源卸载
①切换为root
su root
②检查当前服务器是否有yum源
rpm -qa | grep yum
③卸载这些yum源
rpm -qa|grep yum|xargs rpm -e --nodeps
2、下载163源
①先检查有没有联网
ping www.baidu.com
②去/etc/yum.repos.d目录下
cd /etc/yum.repos.d
③新建目录work,去往该目录
mkdir work
cd work
④下载163的yum源
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-168.el7.centos.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-utils-1.1.31-54.el7_8.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-10.el7.noarch.rpm
⑤安装下载的yum源
rpm -ivh yum-3.4.3-168.el7.centos.noarch.rpm --force --nodeps
rpm -ivh python-iniparse-0.4-9.el7.noarch.rpm --force --nodeps
rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm --force --nodeps
rpm -ivh yum-plugin-fastestmirror-1.1.31-54.el7_8.noarch.rpm --force --nodeps
rpm -ivh yum-utils-1.1.31-54.el7_8.noarch.rpm --force --nodeps
rpm -ivh python-urlgrabber-3.10-10.el7.noarch.rpm --force --nodeps
⑥检查yum源是否下载(共6个)
rpm -qa | grep yum
3、配置repo文件
①去往/etc/yum.repos.d
cd /etc/yum.repos.d
②下载国内repo文件
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo
③编辑该repo文件
vim CentOS7-Base-163.repo
如果没有vim可以用vi代替
④替换文件中的releasever,配置正确的版本
%s/$releasever/7/g
之后会发现里面文本的$releasever更换为7了,退出编辑
⑤清除之前的yum缓存并配置新的,完毕!
yum clean all
yum makecache
yum repolist all