RHEL7 更改了CentOS的yum源后,出现的这个问题,安装initscripts出现冲突。
解决思路是将redhat-release-server-7.0-1.el7.x86_64删除,安装centos-release.x86_64 的某个版本,再升级initscripts就行了。网上很多人只给出删除redhat-release-server的建议,但是实际操作时很有可能一重启就进入紧急模式,得不偿失。
首先,大家应该查一下本机的initscripts的版本,有没有更适合自己系统的。
[root@bogon ~]# yum list initscripts
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
Installed Packages
initscripts.x86_64 9.49.17-1.el7 @anaconda/7.0
Available Packages
initscripts.x86_64 9.49.49-1.el7 base
[root@bogon ~]#
说明当前版本是initscripts.x86_64 9.49.17-1.el7 @anaconda/7.
可以用更适合系统的initscripts.x86_64 9.49.49-1.el7 base 版本来替换。
从网易镜像站下载 initscripts-9.49.49
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/initscripts-9.49.49-1.el7.x86_64.rpm
[root@bogon package]# rpm -Uvh initscripts-9.49.49-1.el7.x86_64.rpm
error: Failed dependencies:
redhat-release < 7.5-0.11 conflicts with initscripts-9.49.49-1.el7.x86_64
[root@bogon package]#
下载好该版本并尝试升级,得到的反馈是与redhat-release冲突,后者起码是7.5-0.11版本的。我们可以把它删除掉(注意备份),然后换一个centos-release的合适版本,那么哪个版本合适呢?
[root@bogon package]# yum list centos-release
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
Available Packages
centos-release.x86_64 7-8.2003.0.el7.centos base
[root@bogon package]#
通过以上命令知道最合适的版本是 centos-release.x86_64 7-8.2003.0.el7.centos base
从网易镜像站下载centos-release.x86_64 7-8.2003.0.el7.centos
wget http://mirrors.163.com/centos/7/os/x86_64/Packages/centos-release-7-8.2003.0.el7.centos.x86_64.rpm
直接安装会有如下问题:
[root@bogon package]# rpm -Uvh centos-release-7-8.2003.0.el7.centos.x86_64.rpm
Preparing... ################################# [100%]
file /etc/os-release from install of centos-release-7-8.2003.0.el7.centos.x86_64 conflicts with file from package redhat-release-server-7.0-1.el7.x86_64
file /etc/redhat-release from install of centos-release-7-8.2003.0.el7.centos.x86_64 conflicts with file from package redhat-release-server-7.0-1.el7.x86_64
file /etc/rpm/macros.dist from install of centos-release-7-8.2003.0.el7.centos.x86_64 conflicts with file from package redhat-release-server-7.0-1.el7.x86_64
file /etc/system-release from install of centos-release-7-8.2003.0.el7.centos.x86_64 conflicts with file from package redhat-release-server-7.0-1.el7.x86_64
file /etc/system-release-cpe from install of centos-release-7-8.2003.0.el7.centos.x86_64 conflicts with file from package redhat-release-server-7.0-1.el7.x86_64
file /usr/lib/systemd/system-preset/90-default.preset from install of centos-release-7-8.2003.0.el7.centos.x86_64 conflicts with file from package redhat-release-server-7.0-1.el7.x86_64
全部与redhat-release-server-7.0.1.el7.x86_64有冲突,卸载掉 redhat-release-server-7.0.1.el7.x86_64
[root@bogon package]# rpm -e redhat-release-server-7.0-1.el7.x86_64 --nodeps
但是,还是有问题:好几个东西与redhat-release-server-7.0-1.el7.x86_64冲突,没办法删掉(注意备份)。
所以我们要先去网易镜像站下载好,删除redhat-release以后,不重启机器,马上安装centos-release
[root@bogon package]# rpm -Uvh centos-release-7-8.2003.0.el7.centos.x86_64.rpm
Preparing... ################################# [100%]
Updating / installing...
1:centos-release-7-8.2003.0.el7.cen################################# [100%]
error: unpacking of archive failed on file /usr/share/doc/redhat-release: cpio: rename failed - Is a directory
error: centos-release-7-8.2003.0.el7.centos.x86_64: install failed
安装时出错!提示“ /usr/share/doc/redhat-release 失败:cpio: rename 失败 – 是一个目录 ”
推测:安装centos-release时,这个redhat-release目录碍事了,所以我们手动把它改个名字。
[root@bogon package]# mv /usr/share/doc/redhat-release /usr/share/doc/redhat-release-bak
继续安装centos-release 依然有别的目录报错
[root@bogon package]# rpm -Uvh centos-release-7-8.2003.0.el7.centos.x86_64.rpm
Preparing... ################################# [100%]
Updating / installing...
1:centos-release-7-8.2003.0.el7.cen################################# [100%]
error: unpacking of archive failed on file /usr/share/redhat-release: cpio: rename failed - Is a directory
error: centos-release-7-8.2003.0.el7.centos.x86_64: install failed
依然把有冲突的目录更改名字
[root@bogon package]# mv /usr/share/redhat-release /usr/share/redhat-release-bak
再次尝试安装centos-release ,可以安装上了
[root@bogon package]# rpm -Uvh centos-release-7-8.2003.0.el7.centos.x86_64.rpm
Preparing... ################################# [100%]
Updating / installing...
1:centos-release-7-8.2003.0.el7.cen################################# [100%]
[root@bogon package]#
这样centos-release 安装完成,尝试安装下载好的 initscripts
[root@bogon package]# rpm -Uvh initscripts-9.49.49-1.el7.x86_64.rpm
Preparing... ################################# [100%]
Updating / installing...
1:initscripts-9.49.49-1.el7 ################################# [ 50%]
UPGRADE: Automatically re-enabling default systemd units:
brandbot.path
rhel-autorelabel.service
rhel-autorelabel-mark.service
rhel-configure.service
rhel-dmesg.service
rhel-domainname.service
rhel-import-state.service
rhel-loadmodules.service
rhel-readonly.service
Cleaning up / removing...
2:initscripts-9.49.17-1.el7 ################################# [100%]
[root@bogon package]#
成功安装~~