我有一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 数据库,并且很可能有文件安装了错误的软件包而不再被跟踪。您将需要找到这些并手动删除它们。查看
/etc/yum.repos.d
目录并找到与您的发行版不对应的 repo 文件。或者你可能会很幸运,文件被清理干净了。完成后,您需要清理 yum 的缓存,
yum clean all
然后重新安装正确的 zabbix-release RPM。请按照以下步骤操作,希望能解决问题 -
现在,安装您要安装的软件包并按照以下步骤操作。
这也会从您的 yum 缓存中清除。