CentOS 6.7使用阿里云CentOS的yum源

原创 2017年10月31日 11:47:28
This directory CentOS 6.7使用阿里云CentOS的yum源


1、备份原有repo文件

#cd /etc/yum.repos.d

#mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

## ll
total 16
-rw-r--r--. 1 root root 2572 Jul  2  2014 CentOS-Base.repo
-rw-r--r--. 1 root root  529 Jun 12  2015 CentOS-Base.repo.backup
-rw-r--r--. 1 root root  358 Oct 24 23:23 redhat.repo
-rw-r--r--. 1 root root 3749 Mar 29  2017 repomd.xml


2.下载repo文件

# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-6.repo
--2017-10-31 19:14:33--  http://mirrors.aliyun.com/repo/Centos-6.repo
Resolving mirrors.aliyun.com... 223.111.244.145, 223.111.244.152, 223.111.244.147, ...
Connecting to mirrors.aliyun.com|223.111.244.145|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2572 (2.5K) [application/octet-stream]
Saving to: “/etc/yum.repos.d/CentOS-Base.repo”

100%[=============================================================================================================================>] 2,572       --.-K/s   in 0s      

2017-10-31 19:14:33 (204 MB/s) - “/etc/yum.repos.d/CentOS-Base.repo” saved [2572/2572]


3.但在yum makecahe 时候报错

# yum makecache
Loaded plugins: aliases, changelog, kabi, presto, product-id, refresh-packagekit, security, subscription-manager, tmprepo, verify, versionlock
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Loading support for Red Hat kernel ABI
http://mirrors.aliyun.com/centos/6Server/os/x86_64/repodata/repomd.xml: [Errno 14] PYCURL ERROR 22 - "The requested URL returned error: 404 Not Found"
Trying other mirror.
http://mirrors.aliyuncs.com/centos/6Server/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/6Server/os/x86_64/repodata/repomd.xml: (28, 'connect() timed out!')
Trying other mirror.
Error: Cannot retrieve repository metadata (repomd.xml) for repository: base. Please verify its path and try again


4.查看repo文件

## vi 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/
#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
# 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/# cd /etc/yum.repos.d/



5.查看6.7的readmew文件,还是有些表变化发现小版本不再进行更新
This directory (and version of CentOS) is deprecated.  For normal users,
you should use /6/ and not /6.7/ in your path. Please see this FAQ
concerning the CentOS release scheme:
If you know what you are doing, and absolutely want to remain at the 6.7
level, go to http://vault.centos.org/ for packages. 

Please keep in mind that 6.0, 6.1, 6.2, 6.3, 6.4 , 6.5, 6.6 and 6.7 no longer gets any updates, norany security fix's..

根据repo文件变量的变化,可以修改repo文件把所有$releasever替换成6 

 执行替换操作

#sed -i 's/\$releasever/6/' CentOS-Base.repo



6.清理并重新生成yum缓存

# yum clean all
Loaded plugins: aliases, changelog, kabi, presto, product-id, refresh-packagekit, security, subscription-manager, tmprepo, verify, versionlock
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Loading support for Red Hat kernel ABI
Cleaning repos: base extras updates
Cleaning up Everything
0 delta-package files removed, by presto


7.重新yum makecache

# yum makecache
Loaded plugins: aliases, changelog, kabi, presto, product-id, refresh-packagekit, security, subscription-manager, tmprepo, verify, versionlock
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Loading support for Red Hat kernel ABI
base                                           | 3.7 kB     00:00     
base/group_gz                                  | 226 kB     00:00     
base/filelists_db                              | 6.4 MB     00:01     
base/primary_db                                | 4.7 MB     00:00     
base/other_db                                  | 2.8 MB     00:00     
extras                                         | 3.4 kB     00:00     
extras/filelists_db                            |  25 kB     00:00     
extras/prestodelta                             | 1.3 kB     00:00     
extras/primary_db                              |  29 kB     00:00     
extras/other_db                                |  30 kB     00:00     
updates                                        | 3.4 kB     00:00     
updates/filelists_db                           | 3.0 MB     00:00     
updates/prestodelta                            | 145 kB     00:00     
updates/primary_db                             | 4.7 MB     00:01     
updates/other_db                               |  66 MB     00:26     
Metadata Cache Created
网上还有一个据说完善的方法,不过没有进行测试,有兴趣的同学可以测试一下
在所有mirrorlist前面加上#,并所有$releasever替换成6

sed -i '/mirrorlist/d' CentOS-Base.repo


sed -i 's/\$releasever/6/' CentOS-Base.repo


sed -i  '/\ [addons\]/,/^$/d' CentOS-Base.repo


sed-i 's/RPM-GPG-KEY-CentOS-5/RPM-GPG-KEY-CentOS-6/' CentOS-Base.repo
版权声明:本文为博主原创文章,未经博主允许不得转载。

CentOS 7 使用阿里云的yum源

1. 备份原来的yum源 sudo mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bak 2.设置ali...
  • skykingf
  • skykingf
  • 2016年07月19日 10:47
  • 8525

centos6更新yum源为阿里云

[1] 首先备份/etc/yum.repos.d/CentOS-Base.repo mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/Ce...
  • Lv_Victor
  • Lv_Victor
  • 2017年05月11日 22:54
  • 5170

CentOS配置本地yum源/阿里云yum源/163yuan源,并配置yum源的优先级

一、用Centos镜像搭建本地yum源 二、把默认的CentOS yum源修改成国内的aliyun yum源 三、把默认的CentOS yum源修改成国内的163源 四、修改yum源的优先级...
  • kangvcar
  • kangvcar
  • 2017年06月19日 22:21
  • 14643

centos6.7更换yum源

1. 备份源文件# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup 2. 下载新的CentO...
  • Cryhelyxx
  • Cryhelyxx
  • 2015年09月25日 21:58
  • 2389

超简单将Centos的yum源更换为国内的阿里云源

自己的yum源不知道什么时候给改毁了……搜到了个超简单的方法将yum源更换为阿里的源 完全参考 http://mirrors.aliyun.com/help/centos?spm=5176...
  • chavo0
  • chavo0
  • 2016年07月18日 09:47
  • 95610

Centos7更新阿里云yum源

1)下载repo文件 wget http://mirrors.aliyun.com/repo/Centos-7.repo2)备份并替换系统的repo文件 cp Centos-7.repo /etc...
  • lwwl12
  • lwwl12
  • 2017年10月16日 10:46
  • 511

centos 6.5添加阿里云yum源

mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup cd /etc/yum.repos.d cu...
  • yizhixiaocaiji26
  • yizhixiaocaiji26
  • 2017年10月29日 22:02
  • 176

centos7配置aliyun的yum源和epel源

一centos7配置阿里云yum源 1切换到etcyumreposd目录下 2将CentOS-Baserepo 改为CentOS-Baserepobackup 3下载阿里云yum源到etcyumrep...
  • aiming66
  • aiming66
  • 2017年12月23日 15:02
  • 364

超简单CentOS7 配置阿里云yum源

1、打开centos的yum文件夹 输入命令cd  /etc/yum.repos.d/ 2、用wget下载repo文件 输入命令wget  http://mirrors.aliyun.c...
  • ltx06
  • ltx06
  • 2017年09月19日 14:55
  • 2092

CentOS 7 使用阿里云的yum源、PIP源

一、yum源1.设置aliyun的base源# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Cen...
  • yjk13703623757
  • yjk13703623757
  • 2017年01月02日 19:46
  • 1287
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:CentOS 6.7使用阿里云CentOS的yum源
举报原因:
原因补充:

(最多只允许输入30个字)