解决yum安装问题

[root@base ~]# yum -y install yum-utils device-mapper-persistent-data lvm2
error: Unable to open /usr/lib/rpm/rpmrc for reading: No such file or directory.
There was a problem importing one of the Python modules
required to run yum. The error leading to this problem was:

   cannot import name ts

Please install a package which provides this module, or
verify that the module is installed correctly.

It's possible that the above module doesn't match the
current version of Python, which is:
2.7.5 (default, Nov 16 2020, 22:23:17) 
[GCC 4.8.5 20150623 (Red Hat 4.8.5-44)]

If you cannot solve this problem yourself, please go to 
the yum faq at:
  http://yum.baseurl.org/wiki/Faq
  
[root@base ~]# rpm -e –nodeps rpm
-bash: rpm: 未找到命令

解决

这是由于误操作导致rpm文件缺失导致
将另一台完好的服务器上RPM文件及缺失文件上传至异常服务器上即可修复

异常服务器A:192.168.182.139
完好服务器B: 任意

服务器B操作

[root@base ~]# scp /bin/rpm root@192.168.182.139:/bin/rpm
[root@base ~]# scp /usr/lib/rpm/rpmrc  root@192.168.182.139:/usr/lib/rpm/rpmrc
[root@base ~]# scp /usr/lib/rpm/macros  root@192.168.182.139:/usr/lib/rpm

如下

[root@base ~]# scp /bin/rpm root@192.168.182.139:/bin/rpm
The authenticity of host '192.168.182.139 (192.168.182.139)' can't be established.
ECDSA key fingerprint is f2:28:ad:25:c5:f0:98:ce:9d:7c:a9:6d:17:b7:6f:99.
Are you sure you want to continue connecting (yes/no)? y
Please type 'yes' or 'no': yes
Warning: Permanently added '192.168.182.139' (ECDSA) to the list of known hosts.
root@192.168.182.139's password: 
rpm                                100%   16KB  15.8KB/s   00:00    
[root@base ~]# scp /usr/lib/rpm/rpmrc  root@192.168.182.139:/usr/lib/rpm/rpmrc
root@192.168.182.139's password: 
Permission denied, please try again.
root@192.168.182.139's password: 
rpmrc                              100%   15KB  15.0KB/s   00:00    
[root@base ~]# scp /usr/lib/rpm/macros  root@192.168.182.139:/usr/lib/rpm
root@192.168.182.139's password: 
macros                             100%   37KB  37.3KB/s   00:00 

测试192.168.182.139

[root@base ~]# rpm -e –nodeps rpm
-bash: rpm: 未找到命令
[root@base ~]# ^C
[root@base ~]# yum -y install yum-utils device-mapper-persistent-data lvm2
已加载插件:fastestmirror, langpacks
Repository base is listed more than once in the configuration
Repository updates is listed more than once in the configuration
Repository extras is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
Loading mirror speeds from cached hostfile
 * base: mirrors.bupt.edu.cn
 * extras: mirrors.bfsu.edu.cn
 * updates: mirrors.bfsu.edu.cn
base                                          | 3.6 kB     00:00     
extras                                        | 2.9 kB     00:00     
updates                                       | 2.9 kB     00:00     
updates/7/x86_64/primary_db                     |  13 MB   00:03     
软件包 yum-utils-1.1.31-54.el7_8.noarch 已安装并且是最新版本
软件包 device-mapper-persistent-data-0.8.5-3.el7_9.2.x86_64 已安装并且是最新版本
软件包 7:lvm2-2.02.187-6.el7_9.5.x86_64 已安装并且是最新版本
无须任何处理
Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐