redhat7.5 替换yum源

一,使用网易163开源镜像站  http://mirrors.163.com/ 
#1,查看原有yum包
rpm -qa|gerp yum

#2,卸载yum包
rpm -qa|grep yum|xargs rpm -e --nodeps
rpm -qa|grep yum

#3,创建下载路径,下载centos7.5 yum包
mkdir /tmp/pkg && cd /tmp/pkg
wget http://mirrors.163.com/centos/7.5.1804/os/x86_64/Packages/yum-3.4.3-158.el7.centos.noarch.rpm

wget http://mirrors.163.com/centos/7.5.1804/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm

wget http://mirrors.163.com/centos/7.5.1804/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-45.el7.noarch.rpm

#4,安装下载好的rpm包
rpm -ivh yum-*
rpm -qa|grep yum

#5,替换原有源
cd /etc/yum.repos.d/ && rm -rfv *

#6,下载163源

2.2 切换至/etc/目录下,并下载163镜像站内的镜像源文件 wget http://mirrors.163.com/.help/CentOS7-Base-163.repo

同样的 网址可能会变动,可以手动进入 http://mirrors.163.com/.help/centos.html,确认一下文件和版本
wget http://mirrors.163.com/.help/CentOS7-Base-163.repo

 将下载的CentOS7-Base-163.repo文件中的 $releasever 全部修改为目标版本 7.5.1804。修改完成后 如图:

#7,将下载好的文件中的 $releasever 全部修改为目标版本 7.5.1804
#为防止出错,以下为改好版本
[base]
name=CentOS-7.5.1804 - Base - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=7.5.1804&arch=$basearch&repo=os
baseurl=http://mirrors.163.com/centos/7.5.1804/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-7.5.1804 - Updates - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=7.5.1804&arch=$basearch&repo=updates
baseurl=http://mirrors.163.com/centos/7.5.1804/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful
[extras]
name=CentOS-7.5.1804 - Extras - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=7.5.1804&arch=$basearch&repo=extras
baseurl=http://mirrors.163.com/centos/7.5.1804/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-7.5.1804 - Plus - 163.com
baseurl=http://mirrors.163.com/centos/7.5.1804/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#8,更新
yum clean all && yum makecache

#9,查看是否更新成功
yum repolist all

 

 

 

 

你可能感兴趣的:(Linux)