Centos 7 替换镜像源

1 备份原始源

[root@localhost ~]# mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.backup

2 下载新的镜像源

  • 方法1:wget直接下载
    执行命令:

    wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
    

    操作如下:

    [root@localhost yum.repos.d]# wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
    --2018-02-09 05:54:04-- http://mirrors.aliyun.com/repo/Centos-7.repo
    正在解析主机 mirrors.aliyun.com (mirrors.aliyun.com)... 180.101.150.31, 180.101.150.28, 180.101.150.26, ...
    正在连接 mirrors.aliyun.com (mirrors.aliyun.com)|180.101.150.31|:80... 已连接。
    已发出 HTTP 请求,正在等待回应... 200 OK
    长度:2573 (2.5K) [application/octet-stream]
    正在保存至: “/etc/yum.repos.d/CentOS-Base.repo”

    100%[==============================================================================>] 2,573 --.-K/s 用时 0s

    2018-02-09 05:54:05 (281 MB/s) - 已保存 “/etc/yum.repos.d/CentOS-Base.repo” [2573/2573])

  • 方法2:curl直接下载
    执行命令:

    curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo
    

    操作如下:

    [root@localhost yum.repos.d]# curl -o /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo% Total    % Received % Xferd  Average Speed   Time    Time     Time  Current                               Dload  Upload   Total   Spent    Left  Speed100  2573  100  2573    0     0   8533      0 --:--:-- --:--:-- --:--:--  8548
    
  • 方法3:在CentOS-Base.repo 写入地址

    [root@localhost yum.repos.d]# vi CentOS-Base.repo[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
    

3 更新缓存

[root@localhost yum.repos.d]# yum makecache已加载插件:fastestmirror, langpackshttp://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml: [Errno 12] Timeout on http://mirrors.aliyuncs.com/centos/7/os/x86_64/repodata/repomd.xml: (28, 'Connection timed out after 30000 milliseconds')正在尝试其它镜像。base                                                     | 3.6 kB  00:00:00extras                                                   | 3.4 kB  00:00:00updates                                                  | 3.4 kB  00:00:00(1/5): extras/7/x86_64/prestodelta                       | 102 kB  00:00:01(2/5): extras/7/x86_64/other_db                          | 108 kB  00:00:00(3/5): extras/7/x86_64/filelists_db                      | 636 kB  00:00:01(4/5): base/7/x86_64/other_db                            | 2.5 MB  00:00:02(5/5): base/7/x86_64/filelists_db                        | 6.7 MB  00:00:02Loading mirror speeds from cached hostfile * base: mirrors.aliyun.com * extras: mirrors.aliyun.com * updates: mirrors.aliyun.com元数据缓存已建立
点赞
收藏

评论区

加载中...

相关推荐

MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1

文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s

Oracle 分组与拼接字符串同时使用

SELECTT.,ROWNUMIDFROM(SELECTT.EMPLID,T.NAME,T.BU,T.REALDEPART,T.FORMATDATE,SUM(T.S0)S0,MAX(UPDATETIME)CREATETIME,LISTAGG(TOCHAR(

MySQL部分从库上面因为大量的临时表tmp_table造成慢查询

背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_

手写Java HashMap源码

HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程HashMap的使用教程22

2020年前端实用代码段,为你的工作保驾护航

有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )

30min搭建kubernetes

masterandnode操作如下yum源修改//备份本地yum源mv/etc/yum.repos.d/CentOSBase.repo/etc/yum.repos.d/CentOSBase.repo_bak//获取阿里yum源配置wgetO/etc/yum.repos.d/CentOSBase.repohttp: