-->

架构资讯

您的当前位置:首页 > 资讯 > Linux

linux切换yum源

2020-04-19 19:32:22  来源:admin 点击:719

1、进入yum镜像源配置文件夹

[root@localhost /]# cd /etc/yum.repos.d/

 

2、备份系统原来的镜像文件

[root@localhost yum.repos.d]# mv CentOs-Base.repo CentOs-Base.repo.bak

 

3、下载镜像源

163 yum镜像源:http://mirrors.163.com/.help/CentOS7-Base-163.repo

阿里云yum镜像源:http://mirrors.aliyun.com/repo/Centos-7.repo

[root@localhost yum.repos.d]

# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

或者

[root@localhost yum.repos.d]
# wget http://mirrors.aliyun.com/repo/Centos-7.repo[root@localhost yum.repos.d]
# mv Centos-7.repo CentOs-Base.repo  #重命名镜像文件

CentOS 5

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo

 

CentOS 6

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

 

CentOS 7

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

 

4、清除缓存

[root@localhost yum.repos.d]# yum clean all

 

5、生成缓存

[root@localhost yum.repos.d]# yum makecache

 

6、升级更新

[root@localhost yum.repos.d]# yum -y update   #升级所有包同时也升级软件和系统内核

[root@localhost yum.repos.d]# yum -y upgrade  #只升级所有包,不升级软件和系统内核

 有一些服务商的系统给默认YUM源设置的是国外的,这样就会导致下载速度缓慢。国内几家

比较热门的镜像点,下面的镜像全部支持Linux的任何一个发行版的系统。


(1).阿里云Linux安装镜像源地址:http://mirrors.aliyun.com/


CentOS系统更换软件安装源

第一步:备份原镜像文件,以免出错后可以恢复。

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup


第二步:下载新的CentOS-Base.repo 到/etc/yum.repos.d/

CentOS 5

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo


CentOS 6

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo


第三步:运行yum makecache生成缓存

yum makecache


(2).163安装软件镜像源


163开源镜像站是国内比较老的一个网站,很多人都在使用。

网易开源镜像站:http://mirrors.163.com/


CentOS系统更换软件安装源 

第一步:备份原镜像文件,以免出错后可以恢复。

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup


第二步:下载新的CentOS-Base.repo 到/etc/yum.repos.d/

CentOS 5

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS5-Base-163.repo


CentOS 6

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS6-Base-163.repo


CentOS 7

wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.163.com/.help/CentOS7-Base-163.repo


最后统一执行:cp -rp CentOS7-Base-163.repo CentOS-Base.repo


第三步:运行以下命令生成缓存 

yum clean all

yum makecache


切换163

国内 yum 源

网易(163)yum源是国内最好的yum源之一 ,无论是速度还是软件版本,都非常的不错。

将yum源设置为163 yum,可以提升软件包安装和更新的速度,同时避免一些常见软件版本无法找到。

安装步骤

首先备份/etc/yum.repos.d/CentOS-Base.repo

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

下载对应版本 repo 文件, 放入 /etc/yum.repos.d/ (操作前请做好相应备份)

  • CentOS5 :http://mirrors.163.com/.help/CentOS5-Base-163.repo

  • CentOS6 :http://mirrors.163.com/.help/CentOS6-Base-163.repo

  • CentOS7 :http://mirrors.163.com/.help/CentOS7-Base-163.repo

wget  
mv CentOS6-Base-163.repo CentOS-Base.repo

运行以下命令生成缓存

yum clean all
yum makecache

如果报错

Could not retrieve mirrorlist http://mirrorlist.repoforge.org/el6/mirrors-rpmforge error was14: PYCURL ERROR 7 - "couldn't connect to host"http://apt.sw.be/redhat/el6/en/x86_64/rpmforge/repodata/repomd.xml: [Errno 14] PYCURL ERROR 7 - "couldn't connect to host"Trying other mirror.Error: Cannot retrieve repository metadata (repomd.xml) for repository: rpmforge. Please verify its path and try again

解决办法:


1、下载新的CentOS-Base.repo 到/etc/yum.repos.d/【版本是5.*的下载5、6.*下载6、7.*下载7】


5.*的下载连接:


[root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-5.repo

6.*的下载连接:


[root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

7.*的下载连接:


[root@localhost ~]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo

2、然后执行以下命令:


[root@localhost ~]# rpm -e rpmforge-release --nodeps [root@localhost ~]# yum clean all  [root@localhost ~]# yum update

相关文章更多 >

© 2024版权所有 水水网

电话:171780793