Centos的阿里源-yellowcong

来源:互联网 发布:吉首大学教务网络系统 编辑:程序博客网 时间:2024/06/06 19:18

Centos的源配置,都在目录/etc/yum.repos.d,给大家看一下阿里云的源文件,然后需要更新源 sudo yum makecache

这里写图片描述

直接从阿里下载

#直接将阿里的repo下载到本机的源目录wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo 

阿里源文件-CentOS-Base-Aliyun.repo

#新建repo文件vim CentOS-Base-Aliyun.repo#将下面的源配置,复制到文件,然后保存退出就可以了
#CentOS-Base-Aliyun.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.comfailovermethod=prioritybaseurl=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=osgpgcheck=1gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7#released updates[updates]name=CentOS-$releasever - Updates - mirrors.aliyun.comfailovermethod=prioritybaseurl=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=updatesgpgcheck=1gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7#additional packages that may be useful[extras]name=CentOS-$releasever - Extras - mirrors.aliyun.comfailovermethod=prioritybaseurl=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=extrasgpgcheck=1gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7#additional packages that extend functionality of existing packages[centosplus]name=CentOS-$releasever - Plus - mirrors.aliyun.comfailovermethod=prioritybaseurl=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=centosplusgpgcheck=1enabled=0gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7#contrib - packages by Centos Users[contrib]name=CentOS-$releasever - Contrib - mirrors.aliyun.comfailovermethod=prioritybaseurl=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=contribgpgcheck=1enabled=0gpgkey=http://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-7

修改为默认源

CentOS-Base.repo 为系统的默认源,我们覆盖一下就可以了

#更改阿里的源为默认的系统yum源,即:mv /etc/yum.repos.d/CentOS-Base-Aliyun.repo  /etc/yum.repos.d/CentOS-Base.repo 

配置生成缓存

#通过生成配置缓存,这样软件安装的效率会高一点yum makecache

此时可能会出现HTTP ERORR 404-Not Found Trying othermirror,原因可能是yum查找软件包
使用的过时的缓存(此时可能需要去cd/etc/yum.repos.d目录,找到过时的缓存,把它去掉),
清空更新之后,再次安装软件,问题消失,具体见如下指令:
yum clean all(等同于 yum cleanheaders ; yum cleanpackages);
yum update;这之后,重新运行 yum makecache生成缓存,yummakecache主要目的是将服 务器上的软件包信息在本地缓存,以提高搜索安装软件的速度。(第五步很重要哈,我也是弄了好一会 儿的)

原创粉丝点击