redhat系统更换yum源

以redhat 6.5服务器为例:

1. 删除当前系统已安装的yum包

• 查询当前yum包
# rpm -qa | grep yum
PackageKit-yum-0.5.8-21.el6.x86_64
yum-metadata-parser-1.1.2-16.el6.x86_64
yum-plugin-security-1.1.30-14.el6.noarch
yum-utils-1.1.30-14.el6.noarch
yum-rhn-plugin-0.9.1-48.el6.noarch
yum-3.2.29-40.el6.noarch
PackageKit-yum-plugin-0.5.8-21.el6.x86_64

• 删除当前yum包
rpm -e --nodeps yum-3.2.29-40.el6.noarch
rpm -e --nodeps PackageKit-yum-plugin-0.5.8-21.el6.x86_64
rpm -e --nodeps yum-utils-1.1.30-14.el6.noarch
rpm -e --nodeps PackageKit-yum-0.5.8-21.el6.x86_64
rpm -e --nodeps yum-rhn-plugin-0.9.1-48.el6.noarch
rpm -e --nodeps yum-plugin-security-1.1.30-14.el6.noarch
rpm -e --nodeps yum-metadata-parser-1.1.2-16.el6.x86_64
或: 有风险
# rpm -qa|grep yum|xargs rpm -e --nodeps

2. 安装更新包

mkdir yum ; cd yum ;
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/python-urlgrabber-3.9.1-11.el6.noarch.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-41.el6.noarch.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-3.2.29-81.el6.centos.noarch.rpm
wget http://mirrors.163.com/centos/6/os/x86_64/Packages/yum-updateonboot-1.1.30-41.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-utils-1.1.30-41.el6.noarch.rpm

首先执行升级操作
rpm -Uvh python-urlgrabber-3.9.1-11.el6.noarch.rpm

再执行安装YUM-包的操作
rpm -ivh yum-*

3. 配置yum源
需要下载centos配置文件并对配置文件进行修改。
• 下载配置文件
cd /etc/yum.repos.d/ ; mkdir backup ; mv * backup ;
wget -O /etc/yum.repos.d/CentOS6-Base-163.repo http://mirrors.163.com/.help/CentOS6-Base-163.repo
wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-6.repo
sed -i 's/$releasever/6/g' /etc/yum.repos.d/CentOS6-Base-163.repo

4. 更新缓存
yum clean all
yum makecache

安装bash命令补全
yum install bash-completion.noarch