先看有没有安装wget         wget -V      如果没有执行   yum -y install wget     进行安装

  然后进行配置的备份

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

  

  然后执行(这个是centos7的配置安装)

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

  然后执行

  yum clean all

  yum makecache

  yum update  或者  yum -y upgrade

  yum需要安装需要的软件包, yum-util 提供yum-config-manager功能,另外两个是devicemapper驱动依赖的

  yum install -y yum-utils device-mapper-persistent-data lvm2

  更换yum源:

  yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo   (使用这个安装docker更快)

  yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo

  查看特定版本   yum list docker-ce --showduplicates | sort -r

  

yum -y update

升级所有包,改变软件设置和系统设置,系统版本内核都升级

yum -y upgrade

升级所有包,不改变软件设置和系统设置,系统版本升级,内核不改变

  创建多个数据源

方法二: 手动修改文件 
1、进入源目录: cd /etc/yum.repos.d 2、添加多个源文件,如:shlug.repo,ustc.repo,两个源的内容如下:
(可以创建独立的repo文件,也可以把以下的内容加到/etc/yum.repos.d/CentOS-Base.repo 后面) [shlug.repo] #mirrors-shlug-org.repo 

# rpm --import http://mirrors.shlug.org/centos/RPM-GPG-KEY-CentOS-6

# This file uses a new mirrorlist system developed by Lance Davis for CentOS. 
# 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=mirrors-shlug-org--CentOS-$releasever - Base 
baseurl=http://mirrors.shlug.org/centos/$releasever/os/$basearch/ 
gpgcheck=1 
gpgkey=http://mirrors.shlug.org/centos/RPM-GPG-KEY-CentOS-6 
#released updates 
[update] 
name=mirrors-shlug-org--CentOS-$releasever - Updates 
baseurl=http://mirrors.shlug.org/centos/$releasever/updates/$basearch/ 
gpgcheck=1 
gpgkey=http://mirrors.shlug.org/centos/RPM-GPG-KEY-CentOS-6
#packages used/produced in the build but not released 
#[addons] 网站上的源目录没有addon,故注释掉
#baseurl=http://mirrors.shlug.org/centos/$releasever/addons/$basearch/ 
#gpgcheck=1 
#gpgkey=http://mirrors.shlug.org/centos/RPM-GPG-KEY-CentOS-6 
#additional packages that may be useful 
[extras] 
name=mirrors-shlug-org--CentOS-$releasever - Extras 
baseurl=http://mirrors.shlug.org/centos/$releasever/extras/$basearch/ 
gpgcheck=1 
gpgkey=http://mirrors.shlug.org/centos/RPM-GPG-KEY-CentOS-6 
#additional packages that extend functionality of existing packages 
[centosplus] 
name=mirrors-shlug-org--CentOS-$releasever - Plus 
baseurl=http://mirror.centos.org/centos/$releasever/centosplus/$basearch/ 
gpgcheck=1 
gpgkey=http://mirrors.shlug.org/centos/RPM-GPG-KEY-CentOS-6 
#contrib - packages by Centos Users 
[contrib] 
name=mirrors-shlug-org--CentOS-$releasever - Contrib 
baseurl=http://mirror.centos.org/centos/$releasever/contrib/$basearch/ 
gpgcheck=1 
enabled=0 
gpgkey=http://mirrors.shlug.org/centos/RPM-GPG-KEY-CentOS-6 [ustc.repo] # CentOS-Base.repo
#
# This file uses a new mirrorlist system developed by Lance Davis for CentOS.
# 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
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=os
baseurl=http://centos.ustc.edu.cn/centos/$releasever/os/$basearch/
gpgcheck=1
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-6 #released updates
[updates]
name=CentOS-$releasever - Updates
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates
baseurl=http://centos.ustc.edu.cn/centos/$releasever/updates/$basearch/
gpgcheck=1
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-6 #packages used/produced in the build but not released
#[addons] 网站上的源目录没有addon,故注释掉
#name=CentOS-$releasever - Addons
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=addons
#baseurl=http://centos.ustc.edu.cn/centos/$releasever/addons/$basearch/
#gpgcheck=1
#gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-6 #additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=extras
baseurl=http://centos.ustc.edu.cn/centos/$releasever/extras/$basearch/
gpgcheck=1
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-6 #additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
#mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=centosplus
baseurl=http://centos.ustc.edu.cn/centos/$releasever/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-6 3、导入KEY rpm --import http://mirrors.shlug.org/centos/RPM-GPG-KEY-CentOS-6
rpm --import http://centos.ustc.edu.cn/centos/RPM-GPG-KEY-CentOS-6 4、安装自动源选择插件--自动选择最快的源 yum install yum-fastestmirror -y 5、如何确认正在使用的是哪个源? cd /var/cache/yum
cat timedhosts.txt

centos 更换yum源 (解决下载慢的问题)的更多相关文章

  1. Centos更换yum源

    Centos更换yum源 步骤如下: 备份原始源 cd /etc/yum.repos.d/ mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/ ...

  2. Centos更换yum源,安装ssh server

    先连上网,然后更换yum源 1. 新建的用户没有sudo权限,所以首先切换到root用户su -输入密码 2. 备份之前的yum源mv /etc/yum.repos.d/CentOS-Base.rep ...

  3. CentOS 更换yum源为aliyun yum源

    CentOS自带的yum源为官方的源,由于墙的原因,经常无法访问,国内也有不错的源,这里讲一下使用aliyun的源替换原yam源. 第一种方法 1.安装base reop源 cd /etc/yum.r ...

  4. centos更换yum源为aliyun源

    国外的yum源由于众所周知的GFW原因,有的被墙,有的很慢,阿里云依靠强大的技术优势建立了国内的开源镜像.阿里云Linux安装镜像源地址:http://mirrors.aliyun.com/ 第一步: ...

  5. centos 更换 yum源

    阿里云Linux安装镜像源地址:http://mirrors.aliyun.com/ CentOS系统更换软件安装源第一步:备份你的原镜像文件,以免出错后可以恢复. mv /etc/yum.repos ...

  6. maven更换下载镜像源-解决下载慢问题(转)

    转自:http://www.cnblogs.com/duking1991/p/6110192.html maven更换下载镜像源-解决下载慢问题   Maven是当前流行的项目管理工具,但官方的库在国 ...

  7. .net core 更换yum源 / “No package libgdiplus-devel available.” 错误解决方法

    安装 libgdiplus-devel yum install libgdiplus-devel 如果出现错误 No package libgdiplus-devel available. 原因可能是 ...

  8. linux更换yum源

    由于 redhat的yum在线更新是收费的,如果没有注册的话不能使用,如果要使用,需将redhat的yum卸载后,重启安装,再配置其他源,以下为详细过程: 1.删除redhat原有的yum rpm - ...

  9. redhat6.5 配置使用centos的yum源

    新安装了redhat6.5安装后,登录系统,使用yum update 更新系统.提示: This system is not registered to Red Hat Subscription Ma ...

随机推荐

  1. bootstrap-Glyphicons 字体图标

    使用的方法: 1 引入 font-awesome.css文件 2 fonts文件夹  Bootstrap 假定所有的图标字体文件全部位于 ../fonts/ 目录内(可以在font-awesome.c ...

  2. Hibernate 4.3 配置文件实现

    1.建立web项目 2.复制相关的jar文件到 项目的lib目录下antlr-2.7.7.jardom4j-1.6.1.jarhibernate-commons-annotations-4.0.5.F ...

  3. 洛谷 - P1355 - 神秘大三角 - 简单计算几何

    https://www.luogu.org/problemnew/show/P1355 判断一个点和三角形的位置关系,最简单的思路就是用向量. 首先排除掉和三角形顶点重合的情况. 把三角形设计成一个首 ...

  4. Mr.Jin系统发布报告——WIN7 WIN8双系统下的学习模式系统

    Mr.Jin系统发布报告           本文由Mr.Jin原创发表于博客园.CSDN论坛 http://www.cnblogs.com/CHPowerljp-IT/p/3463850.html ...

  5. java 强大的反射机制

    这段时间,在对接一个开源的版本时,发现由于依赖的开源版本api老是随着版本的变化而变化,导致代码经常需要修改,异常痛苦. 终于,在一个风和日丽的下午(五月末的广州异常暴晒),楼主下定决心要修掉这个大篓 ...

  6. robotframework自动化系列:操作mysql数据库

    随着项目自动化深入和不断完善,大部分功能都已经能完成了自动化的操作:但是在设备添加的时候,遇到了难题.添加设备的时候mac必须是服务器设备管理中已经存在的mac地址,且是没有关联或绑定用户的设备信息. ...

  7. C#批量插入Sybase数据库,Anywhere 8

    数据库版本是Adaptive Server Anywhere 8 1.添加引用,程序集 iAnywhere.Data.AsaClient.这个和SQLServer的System.Data.SqlCli ...

  8. 用sublime text3 直接编译C/C++,java

    首先你得下载好 这是我之前安装codeblocks时留下的里面有cpp,c++,gcc,g++. 第二步就是建立环境变量 这三个配置完成就ok 了 然后进入sublime text 3中,找到工具(t ...

  9. Java | 技术应用 | 利用Jsoup处理页面

    根据微信公众号的推文链接地址,对文章内容进行爬取,利用jsoup解析文章源代码,加上结合xpth提取文文章信息, 利用正则表达式读取文章发表时间. Jsoup <!-- jsoup HTML p ...

  10. 模板——扩展欧几里得算法(求ax+by=gcd的解)

    Bryce1010模板 /**** *扩展欧几里得算法 *返回d=gcd(a,b),和对应等式ax+by=d中的x,y */ long long extend_gcd(long long a,long ...