#!/bin/bash

#


#1、删除redhat原有的yum源

rpm -qa | grep yum | xargs rpm -e --nodeps


#2、下载新的yum安装包

wget http://mirrors.163.com/centos/6/os/x86_64/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm

wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm

wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-3.2.29-60.el6.centos.noarch.rpm

wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-30.el6.noarch.rpm


#3、安装新的yum软件包(最后两个安装包要放在一起同时安装,但要注意先后顺序,不要搞错了,否则会提示相互依赖,安装失败。)

rpm -ivh python-iniparse-0.3.1-2.1.el6.noarch.rpm

rpm -ivh yum-metadata-parser-1.1.2-16.el6.x86_64.rpm

rpm -ivh yum-3.2.29-60.el6.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-30.el6.noarch.rpm


#4、更改yum源

cd /etc/yum.repo.d/

wget http://mirrors.163.com/.help/CentOS6-Base-163.repo

sed -i 's@$releasever@6@g' /etc/yum.repo.d/CentOS6-Base-163.repo


#6、清除yum缓存,并将服务器上的软件包信息缓存到本地

yum clean all #清除yum缓存

yum makecache #将服务器上的软件包信息缓存到本地,以提高搜索安装软件的速度