首页 > 其他 > 详细

更改和配置本地yum源

时间:2019-08-22 17:25:14      阅读:92      评论:0      收藏:0      [点我收藏+]

查看yum 存放位置

[root@web01 yum.repos.d]# ll /etc/yum.repos.d/
total 28
-rw-r--r--. 1 root root 2523 Jun 16  2018 CentOS-Base.repo  网络源
-rw-r--r--. 1 root root  647 Mar 28  2017 CentOS-Debuginfo.repo
-rw-r--r--. 1 root root  289 Mar 28  2017 CentOS-fasttrack.repo
-rw-r--r--. 1 root root  630 Mar 28  2017 CentOS-Media.repo 本地源
-rw-r--r--. 1 root root 7989 Mar 28  2017 CentOS-Vault.repo
-rw-r--r--. 1 root root  664 May 11  2018 epel.repo

查看网络源详细的配置源信息

[root@web01 yum.repos.d]# cat CentOS-Base.repo 
# 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/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/os/$basearch/
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/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/updates/$basearch/
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/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/extras/$basearch/
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/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/centosplus/$basearch/
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/
        http://mirrors.cloud.aliyuncs.com/centos/$releasever/contrib/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6
[root@web01 yum.repos.d]#

只要修改baseurl gpgkey 为相应源地址即可。

查看本地源的详细信息

[root@web01 ~]# cat /etc/yum.repos.d/CentOS-Media.repo 
# CentOS-Media.repo
#
#  This repo can be used with mounted DVD media, verify the mount point for
#  CentOS-6.  You can use this repo and yum to install items directly off the
#  DVD ISO that we release.
#
# To use this repo, put in your DVD and use it with the other repos too:
#  yum --enablerepo=c6-media [command]
#  
# or for ONLY the media repo, do this:
#
#  yum --disablerepo=\* --enablerepo=c6-media [command]
 
[c6-media]
name=CentOS-$releasever - Media
baseurl=file:///media/CentOS/
        file:///media/cdrom/
        file:///media/cdrecorder/
gpgcheck=1
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6

修改为本地源地址 

 

以上配置结束之后,要清空yum 缓存,并重建yum缓存,执行以下命令:

yum clean all && yum clean metadata && yum clean dbcache && yum makecache && yum update
 

Linux升级命令有两个分别是yum upgrade和yum update, 这个两个命令是有区别的:

yum -y update

升级所有包同时也升级软件和系统内核

yum -y upgrade

只升级所有包,不升级软件和系统内核

实验分别测试 yum -y upgrade和yum -y update

升级前

系统版本: centos5.5 
内核版本: 2.6.18-194.el5 
升级前做过简单配置文件修改

yum -y upgrade 升级后

系统版本: centos5.7 
内核版本: 2.6.18-194.el5 
yum -y update 升级后

系统版本: centos5.7 
内核版本: 2.6.18-238.el5

更改和配置本地yum源

原文:https://www.cnblogs.com/imp-W/p/11393800.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!