林中两路分,一路人迹稀。我独选此路,境遇乃相异。

0%

CentOS源更换,更新系统


CentOS的yum源在国内环境下基本是一个摆设,当我们要安装新程序和更新系统的时候相当吃力,目前国内的163源比较靠谱,所以记录一下修改系统的更新源的操作.

更新源修改

首先备份一下系统默认的yum配置文件CentOS-Base.repo:

1
[root@vm ~]# cp /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak

现在可以修改yum配置文件了:
把配置文件里的mirrorlist注释掉,把baseurl前注释去掉,这样系统会只根据配置的源来作yum更新安装.修改默认的源为http://mirrors.163.com

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
[root@vm ~]# vim /etc/yum.repos.d/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&infra=$infra
baseurl=http://mirrors.163.com/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7

#released updates
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates&infra=$infra
baseurl=http://mirrors.163.com/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/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&infra=$infra

修改好后,保存,退出!

系统更新

最后执行更新操作:

1
2
[root@vm ~]# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*
[root@vm ~]# yum update
-------------本文结束 感谢您的阅读-------------
觉得好,点这里 ^_^