yum源使用的几个报错小总结

简介:

废话不多说,下面记录了centos下更换系统默认yum源为网易yum源的操作过程:
1)备份原有的默认yum源
[root@bastion-IDC ~]# cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak

2)修改CentOS-Base.repo文件。将文件中的baseurl地址修改为网易163的yum源地址即可!
[root@bastion-IDC ~]# vim /etc/yum.repos.d/CentOS-Base.repo

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# 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=http: //mirrors .163.com /centos/ $releasever /os/ $basearch/
gpgcheck=1
gpgkey=http: //mirrors .163.com /centos/RPM-GPG-KEY-CentOS-6
  
#released updates
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
baseurl=http: //mirrors .163.com /centos/ $releasever /updates/ $basearch/
gpgcheck=1
gpgkey=http: //mirrors .163.com /centos/RPM-GPG-KEY-CentOS-6
  
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
baseurl=http: //mirrors .163.com /centos/ $releasever /extras/ $basearch/
gpgcheck=1
gpgkey=http: //mirrors .163.com /centos/RPM-GPG-KEY-CentOS-6
  
#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=http: //mirrors .163.com /centos/ $releasever /centosplus/ $basearch/
gpgcheck=1
enabled=0
gpgkey=http: //mirrors .163.com /centos/RPM-GPG-KEY-CentOS-6
  
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
baseurl=http: //mirrors .163.com /centos/ $releasever /contrib/ $basearch/
gpgcheck=1
enabled=0
gpgkey=http: //mirrors .163.com /centos/RPM-GPG-KEY-CentOS-6

[root@bastion-IDC ~]# yum clean all
[root@bastion-IDC ~]# yum makecache          //将服务器上的软件包信息缓存到本地,以提高搜索安装软件的速度
[root@bastion-IDC ~]# yum update              //更新系统

依照上面操作后,yum源就更换成网易的了,并能正常使用。

要特别注意的是:如果要想CentOS使用yum update更新时不升级内核,方法如下:
[root@bastion-IDC ~]# cp /etc/yum.conf /etc/yum.confbak
方法一)修改yum的配置文件
[root@bastion-IDC ~]# vim /etc/yum.conf 
在[main]的最后添加 exclude=kernel*

方法二)直接在yum的命令后面加上如下的参数:
[root@bastion-IDC ~]# yum --exclude=kernel* update

---------------------------------------------------------------------------------------------------------------------
如果要更换成阿里云的yum源,只需要将/etc/yum.repos.d/CentOS-Base.repo内容替换成下面内容即可,然后yum clean all、yum makecache、yum update

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# 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 - mirrors.aliyun.com
failovermethod=priority
baseurl=http: //mirrors .aliyun.com /centos/ $releasever /os/ $basearch/
         http: //mirrors .aliyuncs.com /centos/ $releasever /os/ $basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
gpgcheck=1
gpgkey=http: //mirrors .aliyun.com /centos/RPM-GPG-KEY-CentOS-6
  
#released updates
[updates]
name=CentOS-$releasever - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http: //mirrors .aliyun.com /centos/ $releasever /updates/ $basearch/
         http: //mirrors .aliyuncs.com /centos/ $releasever /updates/ $basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
gpgcheck=1
gpgkey=http: //mirrors .aliyun.com /centos/RPM-GPG-KEY-CentOS-6
  
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http: //mirrors .aliyun.com /centos/ $releasever /extras/ $basearch/
         http: //mirrors .aliyuncs.com /centos/ $releasever /extras/ $basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
gpgcheck=1
gpgkey=http: //mirrors .aliyun.com /centos/RPM-GPG-KEY-CentOS-6
  
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http: //mirrors .aliyun.com /centos/ $releasever /centosplus/ $basearch/
         http: //mirrors .aliyuncs.com /centos/ $releasever /centosplus/ $basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
gpgcheck=1
enabled=0
gpgkey=http: //mirrors .aliyun.com /centos/RPM-GPG-KEY-CentOS-6
  
#contrib - packages by Centos Users
[contrib]
name=CentOS-$releasever - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http: //mirrors .aliyun.com /centos/ $releasever /contrib/ $basearch/
         http: //mirrors .aliyuncs.com /centos/ $releasever /contrib/ $basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=contrib
gpgcheck=1
enabled=0
gpgkey=http: //mirrors .aliyun.com /centos/RPM-GPG-KEY-CentOS-6

[root@bastion-IDC ~]# yum clean all
[root@bastion-IDC ~]# yum makecache 
如果出现下面报错:
https://mirrors.aliyun.com/centos/$releasever/os/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"

原因分析:
$releasever这个变量在CentOS-Base.repo文件中没有被识别出来。可以去aliyun的镜像官网上查看下正确地址:

即正确地址是:https://mirrors.aliyun.com/centos/6.9/os/x86_64/repodata/repomd.xml
解决办法:将$releasever换成6.9
[root@bastion-IDC ~]# sed -i 's/$releasever/6.9/g' CentOS-Base.repo

***************当你发现自己的才华撑不起野心时,就请安静下来学习吧***************
本文转自散尽浮华博客园博客,原文链接:http://www.cnblogs.com/kevingrace/p/6252795.html ,如需转载请自行联系原作者
相关文章
|
缓存 Linux
yum安装ansible报错如何解决
本篇内容记录了yum安装ansible报错的解决方案。
1025 0
yum安装ansible报错如何解决
|
Linux
Linux - Centos 8 执行 yum makecache fast 报错:yum makecache: error: argument timer: invalid choice: 'fast' (choose from 'timer')
Linux - Centos 8 执行 yum makecache fast 报错:yum makecache: error: argument timer: invalid choice: 'fast' (choose from 'timer')
628 0
|
3月前
yum 报错:Another app is currently holding the yum lock; waiting for it to exit
开发过程中需要用到 yum 命令 有时候执行 yum 会报错如下
18 0
|
5月前
Cannot download repomd.xml解决CentOS8 yum安装AppStream报错
Cannot download repomd.xml解决CentOS8 yum安装AppStream报错
|
5月前
|
Linux
Centos yum报错: BDB1507 Thread died in Berkeley DB library
Centos yum报错: BDB1507 Thread died in Berkeley DB library
|
10月前
|
缓存
Centos8使用yum报错 Couldn‘t resolve host name for http://mirrorlist.centos.org/?releas
Centos8使用yum报错 Couldn‘t resolve host name for http://mirrorlist.centos.org/?releas
250 0
|
10月前
|
Linux Docker 容器
yum install docker报错:Another app is currently holding the yum lock
今天在centos7安装docker的时候yum报错。 在进程里查看下:ps -ef | grep update 把后台占用的更新进程杀掉。
82 0
|
11月前
[There are unfinished transactions remaining.]【使用本地YUM源安装服务报错解决方法】
[There are unfinished transactions remaining.]【使用本地YUM源安装服务报错解决方法】
|
11月前
使用本地YUM源安装服务报错以及解决办法
使用本地YUM源安装服务报错以及解决办法
|
缓存 Shell
yum clean all 后导致yum报错排查解决方案
yum clean all 后导致yum报错排查解决方案
yum clean all 后导致yum报错排查解决方案