linux中yum源出现问题,修改Linux中的Yum源问题

修改YUM源为国内源

一、备份原有的源

在做任何对更改系统变量或者设置的时候都应该进行备份,对于Linux系统中的yum源我们换掉的是这个:/etc/yum.repos.d/CentOS-Base.repo,所以我们应该先把源文件给做个备份。使用mv命令即可。

二、找到你要换的源

华为、阿里、清华、南大这些源都是可以的(他们具体有啥区别,还没有深入去了解,这里做一个`todo`)。

这些源可以直接去他们官方的镜像源仓库中去寻找(这里给出他们的官方镜像源地址):

三、下载文件、重建缓存

华为和阿里源:

找到源之后,就是下载下来,然后放到系统的/etc/yum.repos.d/文件夹下。如果你是用win下载的,可以借助传输软件WinSCP上传到Linux中。

各大高校源:

找到高校源(高校源我们找的是RPM-GPG-KEY-CentOS-7这种格式的),这里我们可以选择不下载。高校源一般都是在文件中的地址路径配置gpgkey,下边是南大的centos7,yum源配置文件,可以参考着配置。

# CentOS-Base.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.

#

#

[base]

name=CentOS-$releasever - Base

#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os

baseurl=https://mirrors.nju.edu.cn/centos/$releasever/os/$basearch/

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#released updates

[updates]

name=CentOS-$releasever - Updates

# mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates

baseurl=https://mirrors.nju.edu.cn/centos/$releasever/updates/$basearch/

gpgcheck=1

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7

#additional packages that may be useful

[extras]

name=CentOS-$releasever - Extras

# mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras

baseurl=https://mirrors.nju.edu.cn/centos/$releasever/extras/$basearch/

gpgcheck=1

gpgkey=https://mirrors.nju.edu.cn/centos/RPM-GPG-KEY-CentOS-7

#additional packages that extend functionality of existing packages

[centosplus]

name=CentOS-$releasever - Plus

# mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus

baseurl=https://mirrors.nju.edu.cn/centos/$releasever/centosplus/$basearch/

gpgcheck=1

enabled=0

gpgkey=https://mirrors.nju.edu.cn/centos/RPM-GPG-KEY-CentOS-7

重建缓存

yum makecache

这样就大功告成了

注意事项:

yum修改阿里源重启之后本地挂载点可能会消失,然后报错[Errno 14] curl#37 - "Couldn't open file /mnt/cdrom/repodata/repomd.xml",这时需要我们重启挂载点,具体启动方法详见下方的参考资料。

参考资料:

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值