Centos6
如何從 rpm 數據庫中刪除軟體包
我有一
Centos 6
台伺服器,我不小心RHEL 7
在它的 rpm 數據庫中添加了一個包。添加了錯誤的包
sudo rpm -ivh http://repo.zabbix.com/zabbix/3.0/rhel/7/x86_64/zabbix-release-3.0-1.el7.noarch.rpm
因此,當我嘗試添加正確的包時,我得到:
sudo rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/6/x86_64/zabbix-release-3.2-1.el6.noarch.rpm Retrieving http://repo.zabbix.com/zabbix/3.2/rhel/6/x86_64/zabbix-release-3.2-1.el6.noarch.rpm warning: /var/tmp/rpm-tmp.rzDcOd: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY Preparing... ########################################### [100%] file /etc/pki/rpm-gpg/RPM-GPG-KEY-ZABBIX from install of zabbix-release-3.2-1.el6.noarch conflicts with file from package zabbix-release-3.0-1.el7.noarch file /etc/yum.repos.d/zabbix.repo from install of zabbix-release-3.2-1.el6.noarch conflicts with file from package zabbix-release-3.0-1.el7.noarch
所以我執行了以下內容:
yum clean all rpm --rebuilddb
然後添加 RHEL 6 包:
sudo rpm -ivh http://repo.zabbix.com/zabbix/3.2/rhel/6/x86_64/zabbix-release-3.2-1.el6.noarch.rpm Retrieving http://repo.zabbix.com/zabbix/3.2/rhel/6/x86_64/zabbix-release-3.2-1.el6.noarch.rpm warning: /var/tmp/rpm-tmp.DgETOM: Header V4 RSA/SHA512 Signature, key ID a14fe591: NOKEY Preparing... ########################################### [100%] 1:zabbix-release ########################################### [100%]
但安裝仍然恢復到錯誤的包:
sudo yum install zabbix-agent Loaded plugins: fastestmirror, presto, refresh-packagekit Setting up Install Process Determining fastest mirrors epel/metalink | 18 kB 00:00 * base: repos-va.psychz.net * epel: mirror.vcu.edu * extras: centos.mirror.constant.com * fasttrack: mirror.fileplanet.com * updates: mirror.fileplanet.com base | 3.7 kB 00:00 base/primary_db | 4.7 MB 00:01 centos-sclo-rh | 2.9 kB 00:00 centos-sclo-rh/primary_db | 1.2 MB 00:00 centos-sclo-sclo | 2.9 kB 00:00 centos-sclo-sclo/primary_db | 154 kB 00:00 cr | 3.3 kB 00:00 cr/primary_db | 1.2 kB 00:00 epel | 4.7 kB 00:00 epel/primary_db | 6.0 MB 00:02 extras | 3.4 kB 00:00 extras/primary_db | 27 kB 00:00 fasttrack | 2.9 kB 00:00 fasttrack/primary_db | 9.9 kB 00:00 updates | 3.4 kB 00:00 updates/primary_db | 3.0 MB 00:00 Resolving Dependencies --> Running transaction check ---> Package zabbix-agent.x86_64 0:3.0.24-1.el7 will be installed --> Processing Dependency: libc.so.6(GLIBC_2.17)(64bit) for package: zabbix-agent-3.0.24-1.el7.x86_64 --> Processing Dependency: systemd for package: zabbix-agent-3.0.24-1.el7.x86_64 --> Processing Dependency: systemd for package: zabbix-agent-3.0.24-1.el7.x86_64 --> Finished Dependency Resolution Error: Package: zabbix-agent-3.0.24-1.el7.x86_64 (zabbix) Requires: libc.so.6(GLIBC_2.17)(64bit) Error: Package: zabbix-agent-3.0.24-1.el7.x86_64 (zabbix) Requires: systemd You could try using --skip-broken to work around the problem ** Found 1 pre-existing rpmdb problem(s), 'yum check' output follows: libmodule-10.0.1.274-b10_0_1_274.x86_64 has missing requires of libodbc.so.1()(64bit) [root@medherent ~]# sudo rpm -evh zabbix-release-3.0-1.el7.noarch rpm: --hash (-h) may only be specified during package installation [root@medherent ~]# sudo rpm -ev zabbix-release-3.0-1.el7.noarch error: package zabbix-release-3.0-1.el7.noarch is not installed
所以我試圖明確刪除包:
sudo rpm -ev zabbix-release-3.0-1.el7.noarch error: package zabbix-release-3.0-1.el7.noarch is not installed
如何執行 YUM install 以使用 RHEL 6 包或從 rpm db 中刪除 RHEL 7 包?
編輯
因此,我根據建議執行了以下操作:
rpm -e zabbix-release
似乎執行沒有錯誤。
我不知道哪些軟體包是我的發行版的一部分:
ls -all /etc/yum.repos.d total 68 drwxr-xr-x. 2 root root 4096 Jan 23 13:43 . drwxr-xr-x. 117 root root 12288 Jan 23 11:37 .. -rw-r--r--. 1 root root 1991 Jun 26 2018 CentOS-Base.repo -rw-r--r--. 1 root root 509 Sep 25 2011 CentOS-CR.repo -rw-r--r--. 1 root root 647 Jun 26 2018 CentOS-Debuginfo.repo -rw-r--r--. 1 root root 276 May 12 2014 CentOS-fasttrack.repo -rw-r--r--. 1 root root 289 Aug 3 2015 CentOS-fasttrack.repo.rpmnew -rw-r--r--. 1 root root 630 Jun 26 2018 CentOS-Media.repo -rw-r--r--. 1 root root 916 May 23 2016 CentOS-SCLo-scl.repo -rw-r--r--. 1 root root 892 Jun 16 2016 CentOS-SCLo-scl-rh.repo -rw-r--r--. 1 root root 8854 Jun 26 2018 CentOS-Vault.repo -rw-r--r--. 1 root root 954 Oct 3 2016 epel.repo -rw-r--r--. 1 root root 1056 Nov 4 2012 epel-testing.repo
編輯 2
Yum 仍在嘗試使用錯誤的包
sudo yum install zabbix-agent Loaded plugins: fastestmirror, presto, refresh-packagekit Setting up Install Process Determining fastest mirrors * base: mirror.vcu.edu * extras: mirrors.greenmountainaccess.net * fasttrack: packages.oit.ncsu.edu * updates: mirror.cisp.com base | 3.7 kB 00:00 base/primary_db | 4.7 MB 00:02 centos-sclo-rh | 2.9 kB 00:00 centos-sclo-rh/primary_db | 1.2 MB 00:02 centos-sclo-sclo | 2.9 kB 00:00 centos-sclo-sclo/primary_db | 154 kB 00:00 cr | 3.3 kB 00:00 cr/primary_db | 1.2 kB 00:00 extras | 3.4 kB 00:00 extras/primary_db | 27 kB 00:00 fasttrack | 2.9 kB 00:00 fasttrack/primary_db | 9.9 kB 00:00 updates | 3.4 kB 00:00 updates/primary_db | 3.0 MB 00:01 Resolving Dependencies --> Running transaction check ---> Package zabbix-agent.x86_64 0:3.0.24-1.el7 will be installed --> Processing Dependency: libc.so.6(GLIBC_2.17)(64bit) for package: zabbix-agent-3.0.24-1.el7.x86_64 --> Processing Dependency: systemd for package: zabbix-agent-3.0.24-1.el7.x86_64 --> Processing Dependency: systemd for package: zabbix-agent-3.0.24-1.el7.x86_64 --> Finished Dependency Resolution Error: Package: zabbix-agent-3.0.24-1.el7.x86_64 (zabbix) Requires: libc.so.6(GLIBC_2.17)(64bit) Error: Package: zabbix-agent-3.0.24-1.el7.x86_64 (zabbix) Requires: systemd You could try using --skip-broken to work around the problem ** Found 1 pre-existing rpmdb problem(s), 'yum check' output follows: libmodule-10.0.1.274-b10_0_1_274.x86_64 has missing requires of libodbc.so.1()(64bit)
尤其
---> Package zabbix-agent.x86_64 0:3.0.24-1.el7 will be installed
您需要解除安裝錯誤安裝的軟體包,即:
rpm -e zabbix-release
您按包名刪除包,而不是按文件名,因為已安裝的包沒有文件名。
當然,這可能無法解決問題,因為您在不需要這樣做的情況下破壞並重建了 RPM 數據庫,並且很可能有文件安裝了錯誤的軟體包而不再被跟踪。您將需要找到這些並手動刪除它們。查看
/etc/yum.repos.d
目錄並找到與您的發行版不對應的 repo 文件。或者你可能會很幸運,文件被清理乾淨了。完成後,您需要清理 yum 的記憶體,
yum clean all
然後重新安裝正確的 zabbix-release RPM。