1.删除redhat原有yum
rpm -aq|grep yum|xargs rpm -e --nodeps
2.下载yum安装文件
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-118.el7.centos.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-24.el7.noarch.rpm
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-iniparse-0.4-9.el7.noarch.rpm
3.安装yum
rpm -ivh python-iniparse-0.4-9.el7.noarch.rpm
rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
rpm -ivh yum-plugin-fastestmirror-1.1.31-24.el7.noarch.rpm
rpm -ivh yum-3.4.3-118.el7.centos.noarch.rpm
注意:最后两个必须同时安装,否则相互依赖
4.更新repo文件
mv /etc/yum.repos.d/rhel-debuginfo.repo /etc/yum.repos.d/rhel-debuginfo.repo.repo.bak
vi /etc/yum.repos.d/rhel-debuginfo.repo
内容:
[base]
name=CentOS-$releasever - Base
baseurl=http://mirrors.163.com/centos/7/os/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#released updates
[updates]
name=CentOS-$releasever - Updates
baseurl=http://mirrors.163.com/centos/7/updates/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#packages used/produced in the build but not released
#[addons]
#name=CentOS-$releasever - Addons
#baseurl=http://mirrors.163.com/centos/$releasever/addons/$basearch/
#gpgcheck=1
#gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that may be useful
[extras]
name=CentOS-$releasever - Extras
baseurl=http://mirrors.163.com/centos/7/extras/$basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
#additional packages that extend functionality of existing packages
[centosplus]
name=CentOS-$releasever - Plus
baseurl=http://mirrors.163.com/centos/7/centosplus/$basearch/
gpgcheck=1
enabled=0
5.yum clean all
6.yum install vim #测试,看是否能用
【设置本地镜像作为yum源】
1、mkdir /mnt/cdrom
2 mount /dev/cdrom /mnt/cdrom #挂着镜像,光盘
3 mkdir /home/redhat-iso
4 cp -Rf /mnt/cdrom/* /home/redhat-iso #将光盘内的内容copy到某个路径下
5 vi /etc/yum.repos.d/rhel-debuginfo.repo #编辑repo文件
添加一下内容:
[rhel_7_iso]
name=local iso
baseurl=file:///home/redhat-iso/
gpgcheck=1
gpgkey=file:///home/redhat-iso/RPM-GPG-KEY-CentOS-7 #该处的gpgkey文件应该改成iso镜像中的文件名