Linux环境下安装yum
Posted 陈远波
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux环境下安装yum相关的知识,希望对你有一定的参考价值。
若出现以下错误则代表需要重新安装yum:
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. 没有已启用的源。 执行 "yum repolist all" 查看您拥有的源。 您可以用 yum-config-manager --enable <源名> 来启用源
1.检查是否安装yum包。查看RHEL是否安装了yum,若是安装了,那么又有哪些yum包:
#rpm -qa |grep yum
2 删除redhat自带的yum包
#rpm -qa|grep yum|xargs rpm -e --nodeps(不检查依赖,直接删除rpm包) #rpm -qa |grep yum (查询确认)
3、 去http://mirrors.163.com/centos/7/os/x86_64/Packages/下载如下文件
下载:
yum-3.4.3-163.el7.centos.noarch.rpm yum-metadata-parser-1.1.4-10.el7.x86_64.rpm yum-plugin-fastestmirror-1.1.31-52.el7.noarch.rpm python-inotify-0.9.4-4.el7.noarch.rpm
4、创建yumFile文件夹
mkdir yumFile
5、将下载的4个文件上传至yumFile文件夹下
rpm -ivh python-inotify-0.9.4-4.el7.noarch.rpm rpm -ivh yum-metadata-parser-1.1.4-10.el7.x86_64.rpm
6、安装是出现以下错误:
root@jxw-xmsb-web1 yumFile]# rpm -ivh yum-3.4.3-163.el7.centos.noarch.rpm yum-plugin-fastestmirror-1.1.31-52.el7.noarch.rpm
警告:yum-3.4.3-163.el7.centos.noarch.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
错误:依赖检测失败:
python-urlgrabber >= 3.10-8 被 yum-3.4.3-163.el7.centos.noarch 需要
rpm >= 0:4.11.3-22 被 yum-3.4.3-163.el7.centos.noarch 需要
7、则运行:
rpm -ivh yum-3.4.3-163.el7.centos.noarch.rpm --force --nodeps yum-plugin-fastestmirror-1.1.31-52.el7.noarch.rpm
8、修改来源文件
(1)进入到系统yum源的目录下:
#cd /etc/yum.repos.d
(2)下载yum源:
进入:http://mirrors.163.com/.help/centos.html里面有下载对应版本repo文件, 放入/etc/yum.repos.d/(操作前请做好相应备份)
(3)修改CentOS6-Base-163.repo文件
vi CentOS6-Base-163.repo
# 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=$releasever&arch=$basearch&repo=os 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-7 - Updates - 163.com #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=updates 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 may be useful [extras] name=CentOS-7 - Extras - 163.com #mirrorlist=http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=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-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 "CentOS7-Base-163.repo" 41L, 1491C
9、导入key
rpm --import RPM-GPG-KEY-CentOS-7
10、运行makecache 生成缓存
yum makecache
11、运行yum clean all(等同于 yum cleanheaders ; yum cleanpackages);
yum clean all
12、更新YUM文件
yum update
13、是否安装成功
yum install dhcp -y
提示安装,就说明可以了。
以上内容参考了博主:https://blog.csdn.net/chensongmol/article/details/84797453的文章,本人写这篇博客主要为了便于后期自己进行查看
以上是关于Linux环境下安装yum的主要内容,如果未能解决你的问题,请参考以下文章
Centos 7 下yum搭建lnmp环境(yum安装方式)