Linux下更换为阿里yum源

 

1、yum源的工作原理

yum是为了解决安装包的依赖关系而生的,如果要源码安装一个软件,需要频繁下载各个包,并解决包的依赖关系。这就好比学门课程,要学会这门课程,就要读课程相关的书,初级——中级——高级,一层一层学上去。现在,如果要学习高级的课本,首先要找到并学习初级的课本,如果初级的课本还要有基础知识,还要一层一层的找下去。那现在有两个图书馆,你所要学习的书都在其中,一个图书馆中的书是一本本放置的,相互之间没有关系,你要什么书取什么书;一个图书馆,书与书之间是有索引连接的,当你要学习一门课程时,它会自动把相关书籍全部提供给你,前者好比官网,后者就是yum源;

2、yum的工作机制

服务器端:在服务器上面存放了所有的RPM软件包,包与包之间有索引链接
客户端:如果需要安装某个软件时,先下载服务器上面记录的依赖性关系文件(可通过WWW或FTP方式),通过对服务器端下载的纪录数据进行分析,然后取得所有相关的软件,一次全部下载下来进行安装。

3、配置阿里yum源

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

> [root@zabbix yum.repos.d]# vim 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-6.9 - Base - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/6.9/os/$basearch/
        http://mirrors.aliyuncs.com/centos/6.9/os/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6.9&arch=$basearch&repo=os
gpgcheck=1
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6
  
#released updates
[updates]
name=CentOS-6.9 - Updates - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/6.9/updates/$basearch/
        http://mirrors.aliyuncs.com/centos/6.9/updates/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6.9&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-6.9 - Extras - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/6.9/extras/$basearch/
        http://mirrors.aliyuncs.com/centos/6.9/extras/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6.9&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-6.9 - Plus - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/6.9/centosplus/$basearch/
        http://mirrors.aliyuncs.com/centos/6.9/centosplus/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6.9&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-6.9 - Contrib - mirrors.aliyun.com
failovermethod=priority
baseurl=http://mirrors.aliyun.com/centos/6.9/contrib/$basearch/
        http://mirrors.aliyuncs.com/centos/6.9/contrib/$basearch/
#mirrorlist=http://mirrorlist.centos.org/?release=6.9&arch=$basearch&repo=contrib
gpgcheck=1
enabled=0
gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-6</span>

>[root@zabbix yum.repos.d]# yum clean all  --清空yum缓存的软件包和header
>[root@zabbix yum.repos.d]## yum makecache  --把yum源中的包信息进行缓存

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值