第一步:检测原来是否安装yum包
[[email protected] ~]# rpm -qa |grep yum
第二步:卸载原来安装的yum包
[[email protected] ~]# rpm -qa|grep yum|xargs rpm -e --nodeps
检查是否卸载干净了:
[[email protected] ~]#rpm -qa |grep yum
这样就卸载干净了!
第三步:下载yum包
yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
yum-3.4.3-167.el7.centos.noarch.rpm
yum-updateonboot-1.1.31-53.el7.noarch.rpm
yum-utils-1.1.31-53.el7.noarch.rpm
yum-plugin-fastestmirror-1.1.31-53.el7.noarch.rpm
1)新建一个文件夹,把yum包下载到此文件下下面。
[[email protected] ~]# mkdir /home/yum
2)测试虚拟机是否可以联网。
可以用ping命令,也可以打开虚拟机里面任意浏览器查看其是否可以联网。
[[email protected] ~]# ping baidu.com
3)虚拟机联网下载:
[[email protected] ~]# wget -P /home/yum http://http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
这样就下载成功了,下面继续下载:
[[email protected] ~]# wget -P /home/yum http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-167.el7.centos.noarch.rpm
[[email protected] ~]# wget -P /home/yum http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-updateonboot-1.1.31-53.el7.noarch.rpm
[[email protected] ~]# wget -P /home/yum http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-utils-1.1.31-53.el7.noarch.rpm
[[email protected] ~]# wget -P /home/yum http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-53.el7.noarch.rpm
如果下载过程中出现以下这种情况,说明yum包已经更新了,此时需要打开网站(http://mirrors.163.com/centos/7/os/x86_64/Packages/)找到对应的yum包,稍微更改一下就行了。
如果您的虚拟机暂时不能联网不要着急哦,继续往下看啦!
4)虚拟机不联网下载:
进入网站http://mirrors.163.com/centos/7/os/x86_64/Packages/找到相应的yum包,下载到自己电脑上面。
然后把5个yum包拷贝到虚拟机 home/yum 这个文件夹下。
现在下载完毕了,可以打开home/yum文件夹查看一下。
第四步:安装yum包
[[email protected] ~]# cd /home/yum
[[email protected] yum]# rpm -ivh *.rpm --force –-nodeps
这里简单说明一下:
因为yum安装包之间存在相互依赖关系,所以在后面加上–nodeps --force
–nodeps是安装时不检查依赖关系,比如这个rpm需要A,但是我们没装A,这样我们的包就装不上,用了–nodeps我们就能装上了。
–force是强制安装,比如我们装过这个rpm的版本1,如果我们想装这个rpm的版本2,就需要用–force进行强制安装。
第五步:更改yum源
[[email protected] yum]# cd
[[email protected]localhost ~]# vim /etc/yum.repos.d/CentOS-Base.repo
输入内容如下:
#CentOS-Base.repo
#The mirror system uses the connecting IP address of the client and the
#update status of each mirror to pick mirrors that are updated to and
#geographically close to the client. You should use this for CentOS updates
#unless you are manually picking other mirrors.
#If the mirrorlist= does not work for you, as a fall back you can try the
#remarked out baseurl= line instead.
[base]
name=CentOS-7 - Base - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=KaTeX parse error: Expected 'EOF', got '&' at position 9: basearch&̲repo=os baseurl…basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7#released updates
[updates]
name=CentOS-7 - Updates - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=KaTeX parse error: Expected 'EOF', got '&' at position 9: basearch&̲repo=updates ba…basearch/
gpgcheck=1
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7#additional packages that may be useful
[extras]
name=CentOS-7 - Extras - 163.com
#mirrorlist=http://mirrorlist.centos.org/?release=7&arch=KaTeX parse error: Expected 'EOF', got '&' at position 9: basearch&̲repo=extras bas…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-7 - Plus - 163.com
baseurl=http://mirrors.163.com/centos/7/centosplus/$basearch/
gpgcheck=1
enabled=0
gpgkey=http://mirrors.163.com/centos/RPM-GPG-KEY-CentOS-7
如果原先配置好了,就不需要再配置啦~ 完成就是下面这样:
第六步:清除缓存
[[email protected] ~]# yum clean all
如果出现这种情况 :No module named urlgrabber,
大概是因为安装了多个版本的python。
解决办法:卸载原先urlgrabber的rpm包,重新安装。
1.查看是否安装:
[[email protected] ~]# rpm -qa | grep urlgrabber
2.卸载:
[[email protected] ~]# rpm python-urlgrabber-3.10-10.el7.noarch -e --nodeps
3.重新下载:
[[email protected] ~]# wget -P /home/yum http://mirrors.163.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-10.el7.noarch.rpm[/color]
4.安装:
[[email protected] ~]# cd /home/yum
[[email protected] yum] rpm -ivh python-urlgrabber-3.10-10.el7.noarch.rpm --rforce --nodeps
这样基本就能解决啦~
第七步:测试
[[email protected] ~]# yum install vim
这样yum就配置成功了。