centos 更换yum源 (解决下载慢的问题)

  先看有没有安装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
上一篇:利用css3动画和border来实现圆形进度条


下一篇:Ubuntu一路填坑...