下载CentOS6.5系统源

http://mirror.nsc.liu.se/centos-store/6.5/isos/x86_64/CentOS-6.5-x86_64-bin-DVD1.iso

下载CentOS6.5系统的yum组件

http://mirror.nsc.liu.se/centos-store/6.5/os/x86_64/Packages/yum-3.2.29-40.el6.centos.noarch.rpm
http://mirror.nsc.liu.se/centos-store/6.5/os/x86_64/Packages/yum-metadata-parser-1.1.2-16.el6.x86_64.rpm
http://mirror.nsc.liu.se/centos-store/6.5/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.30-14.el6.noarch.rpm
http://mirror.nsc.liu.se/centos-store/6.5/os/x86_64/Packages/yum-plugin-upgrade-helper-1.1.30-14.el6.noarch.rpm
http://mirror.nsc.liu.se/centos-store/6.5/os/x86_64/Packages/yum-utils-1.1.30-14.el6.noarch.rpm

下载CentOS6.5系统rpm备用

http://mirror.nsc.liu.se/centos-store/6.5/os/x86_64/RPM-GPG-KEY-CentOS-6
http://mirror.nsc.liu.se/centos-store/6.5/os/x86_64/RPM-GPG-KEY-CentOS-Debug-6
http://mirror.nsc.liu.se/centos-store/6.5/os/x86_64/RPM-GPG-KEY-CentOS-Security-6
http://mirror.nsc.liu.se/centos-store/6.5/os/x86_64/RPM-GPG-KEY-CentOS-Testing-6

将下载的全部传到需替换的服务器上

替换原redhat源1. 查看系统自身安装的yum软件包

rpm -qa | grep yum

2. 卸载所有自带yum软件包

rpm -e 软件包名称 --nodeps

3. 删除所有repo相关文件

rm -rf /etc/yum.confrm -rf /etc/yum.repos.d/rm -rf /var/cache/yum

4.安装下载的所有yum相关组件

rpm -ivh yum-*

5.准备配置本地源配置本地源1. 创建文件夹

mkdir /mnt/cdrom

2. 挂载iso镜像文件到/mnt/cdrom节点下

mount -o loop /usr/local/CentOS-6.5-x86_64-bin-DVD1.iso /mnt/cdrom

3. 编辑.repo文件

# 进入到/etc/yum.repos.d/ 文件夹cd /etc/yum.repos.d/# 移除该文件夹下的所有后缀为.repo的文件mv *.repo /tmp# 创建自己的.repo文件,内容如下,保存退出!# vim local.repo '''[local_server]   #库名称name=Thisis a local repo  #名称描述 baseurl=file:///mnt/cdrom  #yum源目录,源地址enabled=1     #是否启用该yum源,0为禁用gpgcheck=1    #检查GPG-KEY,0为不检查,1为检查 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-6  #gpgcheck=0时无需配置'''

4. 清除缓存

yum clean all '''Loaded plugins: fastestmirror, refresh-packagekit, securityCleaning repos: local_serverCleaning up EverythingCleaning up list of fastest mirrors'''

5. 建立新缓存

yum makecache'''Loaded plugins: fastestmirror, refresh-packagekit, securityDetermining fastest mirrorslocal_server                                             |4.0 kB     00:00 ...local_server/group_gz                                    | 209kB     00:00 ...local_server/filelists_db                                | 4.8 MB     00:00 ...local_server/primary_db                                  | 3.5 MB     00:00 ...local_server/other_db                                    | 2.0MB     00:00 ...Metadata Cache Created'''

6. yum本地源安装完成

yum list

更换系统1. 卸载系统镜像

rpm -e redhat-release-server-6.5-18.el7.x86_64 --nodeps

2. 更新yum

yum update -y

3. 重启操作系统

reboot

4. 验证

cat /etc/redhat-release# 若找不到此文件,查找是否有/etc/centos-release文件# 若有,则执行ln -s centos-release redhat-release# 若无,创建centos-releasevi centos-release'''写入当前系统版本号'''# 保存退出,并执行ln -s centos-release redhat-release