1、首先查看redhat 7.0系统本身所安装的那些yum 软件包:
[root@linuxprobe ~]# rpm -qa | grep yum yum-utils-1.1.31-24.el7.noarch yum-langpacks-0.4.2-3.el7.noarch yum-metadata-parser-1.1.4-10.el7.x86_64 yum-rhn-plugin-2.0.1-4.el7.noarch PackageKit-yum-0.8.9-11.el7.x86_64 yum-3.4.3-118.el7.noarch
2、卸载这些软件包;
[root@linuxprobe ~]# rpm -e yum-3.4.3-118.el7.noarch --nodeps [root@linuxprobe ~]# rpm -e yum-utils-1.1.31-24.el7.noarch --nodeps [root@linuxprobe ~]# rpm -e yum-rhn-plugin-2.0.1-4.el7.noarch --nodeps [root@linuxprobe ~]# rpm -e yum-metadata-parser-1.1.4-10.el7.x86_64 --nodeps [root@linuxprobe ~]# rpm -e yum-langpacks-0.4.2-3.el7.noarch --nodeps [root@linuxprobe ~]# rpm -e PackageKit-yum-0.8.9-11.el7.x86_64 --nodeps
3、保证本机电脑能上网;
[root@linuxprobe ~]# ping www.baidu.co PING www.a.shifen.com (61.135.169.121) 56(84) bytes of data. 64 bytes from 61.135.169.121: icmp_seq=1 ttl=53 time=31.8 ms 64 bytes from 61.135.169.121: icmp_seq=2 ttl=53 time=31.9 ms 64 bytes from 61.135.169.121: icmp_seq=3 ttl=53 time=32.0 ms
4、进入以下网站上面查看软件包的版本是否升级或者找到自己系统所对应的文件包版本更新;
网易163网络源地址:http://mirrors.163.com/ CentOS网络源地址:http://centos.ustc.edu.cn/centos/
5、找到自己所需要的版本下载:
[root@Linuxprobe ~]# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-118.el7.centos.noarch.rpm --2016-01-17 20:43:15-- http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-118.el7.centos.noarch.rpm Resolving mirrors.163.com (mirrors.163.com)... 123.58.173.185, 123.58.173.186 Connecting to mirrors.163.com (mirrors.163.com)|123.58.173.185|:80... connected. HTTP request sent, awaiting response... 404 Not Found 2016-01-17 20:43:15 ERROR 404: Not Found. //如果找不到,是安装包更新了,你可以到这个网站http://mirrors.163.com/centos/7/os/x86_64/Packages/复制下载链接,然后再下载下来; 已更新到 wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-3.4.3-161.el7.centos.noarch.rpm [root@linuxprobe ~]# [root@linuxprobe ~]# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-metadata-parser-1.1.4-10.el7.x86_64.rpm [root@linuxprobe ~]# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-utils-1.1.31-50.el7.noarch.rpm [root@linuxprobe ~]# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-updateonboot-1.1.31-50.el7.noarch.rpm [root@linuxprobe ~]# wget http://mirrors.163.com/centos/7/os/x86_64/Packages/yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm
6、查看下载完成结果;
[root@linuxprobe ~]# ls 3.安装软件包。 rpm -ivh python-iniparse-0.3.1-2.1.el7.noarch.rpm rpm -ivh python-urlgrabber-3.9.1-11.el7.noarch.rpm rpm -ivh yum-metadata-parser-1.1.2-17.el7.x87_74.rpm rpm -ivh yum-plugin-fastestmirror-1.1.30-37.el7.noarch.rpm yum-3.2.29-73.el7.centos.noarch.rpm *注释yum-plugin-fastestmirror和yum-3.2.29要一起安装。
7、安装软件包:
[root@Linuxprobe ~]# rpm -ivh yum-3.4.3-161.el7.centos.noarch.rpm
安装 yum-3.4.3-161.el7.centos.noarch.rpm 必须先安装 python-urlgrabber (版本>=3.10-8) | rpm(版本>=4.11.3-22) | yum-plugin-fastestmirror(对版本无要求) 这三个。
如果按照遇到问题:发现错误,python-urlgrabber版本必须大于等于3.9.1-10
# rpm -ivh yum-3.2.29-73.el7.centos.noarch.rpm yum-plugin-fastestmirror-1.1.30-37.el7.noarch.rpm
warning: yum-3.2.29-73.el7.centos.noarch.rpm: Header V3 RSA/SHA1 Signature, key ID c105b9de: NOKEY
error: Failed dependencies:
python-urlgrabber >= 3.9.1-10 is needed by yum-3.2.29-73.el7.centos.noarch
查看系统的python信息
# rpm -qa|grep python
我找到自己的版本
rpm -e python-urlgrabber-3.10-4.el7.noarch --nodeps
安装7的软件包 wget http://mirrors.163.com/centos/7/os/x86_64/Packages/python-urlgrabber-3.10-9.el7.noarch.rpm
发现python-urlgrabber-3.9.1-9.el7.noarch 版本低于3.9.1-10
卸载:python-urlgrabber-3.9.1-9.el7.noarch
rpm -e python-urlgrabber-3.9.1-9.el7.noarch
安装:rpm -ivh python-urlgrabber-3.9.1-11.el7.noarch.rpm
---------------------
作者:zhaosenoo
来源:CSDN
原文:https://blog.csdn.net/zhaosenoo/article/details/70919881
那么我们就按照提示来做吧,现在安装 python-urlgrabber-3.10-9.el7.noarch.rpm (别忘了先去下载安装包)
[root@localhost home]# rpm -ivh python-urlgrabber-3.10-9.el7.noarch.rpm
警告:python-urlgrabber-3.10-9.el7.noarch.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:python-urlgrabber-3.10-9.el7 ################################# [100%]
1
2
3
4
5
6
现在我们再安装 yum-3.4.3-161.el7.centos.noarch.rpm
[root@localhost home]# rpm -ivh yum-3.4.3-161.el7.centos.noarch.rpm
警告:yum-3.4.3-161.el7.centos.noarch.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
错误:依赖检测失败:
rpm >= 0:4.11.3-22 被 yum-3.4.3-161.el7.centos.noarch 需要
yum-plugin-fastestmirror 被 yum-3.4.3-161.el7.centos.noarch 需要
1
2
3
4
5
6
发现 python-urlgrabber 已经安装成功,不再报需要 python-urlgrabber
4、安装rpm(版本>=4.11.3-22)
首先我们现有的 rpm
[root@localhost home]# rpm -qa | grep rpm
rpm-libs-4.11.1-16.el7.x86_64
rpm-python-4.11.1-16.el7.x86_64
rpm-4.11.1-16.el7.x86_64
rpm-build-libs-4.11.1-16.el7.x86_64
1
2
3
4
5
6
发现 rpm 已经有了 rpm-4.11.1-16.el7.x86_64 版本,但是不满足 rpm(版本>=4.11.3-22) 的要求。
[root@localhost home]# rpm -ivh rpm-4.11.3-35.el7.x86_64.rpm
警告:rpm-4.11.3-35.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
准备中... ################################# [100%]
file /bin/rpm from install of rpm-4.11.3-35.el7.x86_64 conflicts with file from package rpm-4.11.1-16.el7.x86_64
file /usr/bin/rpm2cpio from install of rpm-4.11.3-35.el7.x86_64 conflicts with file from package rpm-4.11.1-16.el7.x86_64
file /usr/bin/rpmdb from install of rpm-4.11.3-35.el7.x86_64 conflicts with file from package rpm-4.11.1-16.el7.x86_64
file /usr/bin/rpmkeys from install of rpm-4.11.3-35.el7.x86_64 conflicts with file from package rpm-4.11.1-16.el7.x86_64
file /usr/lib/rpm/macros from install of rpm-4.11.3-35.el7.x86_64 conflicts with file from package rpm-4.11.1-16.el7.x86_64
file /usr/lib/rpm/platform/aarch64-linux/macros from install of rpm-4.11.3-35.el7.x86_64 conflicts with file from package rpm-4.11.1-16.el7.x86_64
...... 自处省略
1
2
3
4
5
6
7
8
9
10
11
[root@localhost home]# rpm -ivh yum-3.4.3-161.el7.centos.noarch.rpm
警告:yum-3.4.3-161.el7.centos.noarch.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
错误:依赖检测失败:
rpm >= 0:4.11.3-22 被 yum-3.4.3-161.el7.centos.noarch 需要
yum-plugin-fastestmirror 被 yum-3.4.3-161.el7.centos.noarch 需要
1
2
3
4
5
6
现在我们再安装 yum-3.4.3-161.el7.centos.noarch.rpm
[root@localhost home]# rpm -ivh yum-3.4.3-161.el7.centos.noarch.rpm
警告:yum-3.4.3-161.el7.centos.noarch.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
错误:依赖检测失败:
rpm >= 0:4.11.3-22 被 yum-3.4.3-161.el7.centos.noarch 需要
yum-plugin-fastestmirror 被 yum-3.4.3-161.el7.centos.noarch 需要
1
2
3
4
5
6
第一个坑:发现还是报 rpm >= 0:4.11.3-22 被 yum-3.4.3-161.el7.centos.noarch 需要
搜了一些资料发现是我们的命令写错了:
之前我们已经有了 rpm-4.11.1-16.el7.x86_64 版本,所以我们要升级 rpm 即可,命令这样写:
[root@localhost home]# rpm -Uvh rpm-4.11.3-35.el7.x86_64.rpm --nodeps
警告:rpm-4.11.3-35.el7.x86_64.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:rpm-4.11.3-35.el7 ################################# [ 50%]
正在清理/删除...
2:rpm-4.11.1-16.el7 ################################# [100%]
1
2
3
4
5
6
7
8
就是把
[root@localhost home]# rpm -ivh yum-3.4.3-161.el7.centos.noarch.rpm
1
改为
[root@localhost home]# rpm -Uvh rpm-4.11.3-35.el7.x86_64.rpm --nodeps
1
现在我们再安装 yum-3.4.3-161.el7.centos.noarch.rpm 发现只需要安装 yum-plugin-fastestmirror 就可以了
[root@localhost home]# rpm -ivh yum-3.4.3-161.el7.centos.noarch.rpm
警告:yum-3.4.3-161.el7.centos.noarch.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
错误:依赖检测失败:
yum-plugin-fastestmirror 被 yum-3.4.3-161.el7.centos.noarch 需要
1
2
3
4
5
5、安装yum-plugin-fastestmirror
[root@localhost home]# rpm -ivh yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm
警告:yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
错误:依赖检测失败:
yum >= 3.0 被 yum-plugin-fastestmirror-1.1.31-50.el7.noarch 需要
1
2
3
4
5
第二个坑:蛋疼的事情出现了安装 yum-plugin-fastestmirror 依赖 yum(版本>=3.0),安装yum-3.4.3-161又依赖yum-plugin-fastestmirror。互相依赖了怎么搞?
这段蛋疼的互相需要
[root@localhost home]# rpm -ivh yum-3.4.3-161.el7.centos.noarch.rpm
警告:yum-3.4.3-161.el7.centos.noarch.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
错误:依赖检测失败:
yum-plugin-fastestmirror 被 yum-3.4.3-161.el7.centos.noarch 需要
[root@localhost home]# rpm -ivh yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm
警告:yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm: 头V3 RSA/SHA256
Signature, 密钥 ID f4a80eb5: NOKEY 错误:依赖检测失败:
yum >= 3.0 被 yum-plugin-fastestmirror-1.1.31-50.el7.noarch 需要
解决办法:
不怎么搞,那就一起安装呗。
[root@localhost home]# rpm -ivh yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm yum-3.4.3-161.el7.centos.noarch.rpm
警告:yum-plugin-fastestmirror-1.1.31-50.el7.noarch.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:yum-3.4.3-161.el7.centos ################################# [ 50%]
2:yum-plugin-fastestmirror-1.1.31-5################################# [100%]
1
2
3
4
5
6
7
搞定了。
6、安装yum-updateonboot和yum-utils
[root@localhost home]# rpm -ivh yum-updateonboot-1.1.31-50.el7.noarch.rpm
警告:yum-updateonboot-1.1.31-50.el7.noarch.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
准备中... ################################# [100%]
正在升级/安装...
1:yum-updateonboot-1.1.31-50.el7 ################################# [100%]
[root@localhost home]# rpm -ivh yum-utils-1.1.31-50.el7.noarch.rpm
警告:yum-utils-1.1.31-50.el7.noarch.rpm: 头V3 RSA/SHA256 Signature, 密钥 ID f4a80eb5: NOKEY
准备中... ################################# [100%]
---------------------
三、配置yum源
在阿里云开源软件镜像站点下载资源文件 http://mirrors.aliyun.com/repo/Centos-7.repo添加链接描述
把下载的文件放在 /etc/yum.repos.d/ 文件夹下面并重命名为 CentOS-Base.repo
编辑 CentOS-Base.repo
把文件中所有的 $releasever替换为 7。注意,是所有的 $releasever 替换为7
运行以下命令生成缓存
yum clean all
yum makecache
1
2
若出现:
/var/run/yum.pid 已被锁定,PID 为 2703 的另一个程序正在运行。
Another app is currently holding the yum lock; waiting for it to exit...
另一个应用程序是:yum
内存: 28 M RSS (980 MB VSZ)
已启动: Fri Dec 21 06:11:05 2018 - 07:18之前
状态 :跟踪/停止,进程ID:2703
Another app is currently holding the yum lock; waiting for it to exit...
1
2
3
4
5
6
7
则执行一次:
rm -f /var/run/yum.pid
1
测试
[root@localhost home]# yum install net-tools
已加载插件:fastestmirror, product-id, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
正在解决依赖关系
--> 正在检查事务
---> 软件包 net-tools.x86_64.0.2.0-0.24.20131004git.el7 将被 安装
--> 解决依赖关系完成
依赖关系解决
=========================================================================================================================================================================================================================================
Package 架构 版本 源 大小
=========================================================================================================================================================================================================================================
正在安装:
net-tools x86_64 2.0-0.24.20131004git.el7 base 306 k
事务概要
=========================================================================================================================================================================================================================================
安装 1 软件包
总下载量:306 k
安装大小:918 k
---------------------
作者:子非鱼yy
来源:CSDN
原文:https://blog.csdn.net/ztx114/article/details/85149629
8、新建repo 配置文件;
[root@linuxprobe ~]# 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=$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=$7&arch=$basearch&repo=updates baseurl=http://mirrors.163.com/centos/7/updates/$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=$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
9、至此YUM 网络源已经安装完成;
[root@linuxprobe ~]# yum clean all
10、测试安装是否正常;
[root@Linuxprobe ~]# yum -y install lftp Loaded plugins: fastestmirror, product-id, subscription-manager This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. Loading mirror speeds from cached hostfile Resolving Dependencies --> Running transaction check ---> Package lftp.x86_64 0:4.4.8-7.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================================ Package Arch Version Repository Size ================================================================================================ Installing: lftp x86_64 4.4.8-7.el7 base 750 k Transaction Summary ================================================================================================ Install 1 Package ………………省略部分安装过程……………… Installed: lftp.x86_64 0:4.4.8-7.el7 Complete!
到这里安装完成,以后安装所需包,可以不用本地yum源了,直接使用网络yum源。