一、Linux更改yum源为阿里云源

  一、原yum源备份

cp -rp /etc/yum.repos.d/CentOS-Base.repo{,.bak}

  二、更改为阿里云源 

  下载新的CentOS-Base.repo 到/etc/yum.repos.d/

  http://mirrors.aliyun.com/repo

  1、CentOS5.x

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

或者

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

  2、CentOS6.x

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

或者

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

  3、CentOS7.x

wget http://mirrors.aliyun.com/repo/epel-7.repo

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

或者

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

  三、  配置完毕,运行yum makecache生成缓存

  清除旧缓存

yum clean all

  生成新的缓存

yum makecach

二、内网自建yum源

  一、自建yum仓库

 

  添加rpm包,更新yum仓库

createrepo --update .

  二、同步开源yum源到本地yum仓库

  参考链接地址:​​http://blog.51cto.com/270142877/2097066​

  三、yum下载RPM包及依赖包的两种方式

  downloadonly和yumdownloade

三、yum缓存包到本地

yum install --downloadonly --downloaddir=/root/mypackages/ vim

说明:

--downloadonly  只下载

--downloaddir  下载包存放的路径

/root/mypackages  下载包存放的位置

vim  下载的包

 

rpm -ivh ./*.rpm --nodeps --force

说明:

安装所有包,因为通过第一个命令下载后有很多rpm包,他们之前有依赖关系,一个一个安装不实际