惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

酷 壳 – CoolShell
酷 壳 – CoolShell
H
Hacker News: Front Page
P
Palo Alto Networks Blog
T
ThreatConnect
Apple Machine Learning Research
Apple Machine Learning Research
博客园_首页
T
True Tiger Recordings
P
Privacy & Cybersecurity Law Blog
B
Blog
IT之家
IT之家
Last Week in AI
Last Week in AI
F
Full Disclosure
Hacker News: Ask HN
Hacker News: Ask HN
C
Comments on: Blog
Microsoft Azure Blog
Microsoft Azure Blog
C
Cybersecurity and Infrastructure Security Agency CISA
Microsoft Security Blog
Microsoft Security Blog
博客园 - 【当耐特】
N
News and Events Feed by Topic
NISL@THU
NISL@THU
腾讯CDC
雷峰网
雷峰网
Security Latest
Security Latest
李成银的技术随笔
M
Microsoft Research Blog - Microsoft Research
L
LangChain Blog
L
Lohrmann on Cybersecurity
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Check Point Blog
Y
Y Combinator Blog
Recent Announcements
Recent Announcements
博客园 - Franky
N
News | PayPal Newsroom
V
V2EX
A
About on SuperTechFans
The Register - Security
The Register - Security
月光博客
月光博客
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google Online Security Blog
Google Online Security Blog
MyScale Blog
MyScale Blog
Cisco Talos Blog
Cisco Talos Blog
Vercel News
Vercel News
WordPress大学
WordPress大学
C
Cyber Attacks, Cyber Crime and Cyber Security
The Hacker News
The Hacker News
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
IntelliJ IDEA : IntelliJ IDEA – the Leading IDE for Professional Development in Java and Kotlin | The JetBrains Blog
爱范儿
爱范儿
A
Arctic Wolf
L
LINUX DO - 最新话题
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More

博客园 - 三国梦回

spring boot 项目中oracle datasource设置schema spring cloud项目中,在bootstrap.yml中指定了active的profile,结果不生效 线上服务重启后,从nacos取不到配置了,怎么回事 nginx location没学好,把自己坑了一把 技术问题记录20260125 最近遇到的两个技术问题记录 linux服务器文件上传失败 线上遇到的redis和数据库数据未同步问题、redisson内部实现问题 复杂业务系统线上问题排查过程 nacos中配了一个数字,springboot取回来怎么变了 一个java空指针异常的解决过程 简单记录下最近2个月完成的线上系统迁移工作 centos停服,迁移centos7.3系统到新搭建的openEuler 端口telnet不通排查过程 https证书中的subject alternative name字段作用及如何生成含该字段的证书 对接服务升级后仅支持tls1.2,jdk1.7默认使用tls1.0,导致调用失败 网络抓包文件太大,如何切分 分页查询不加排序有问题,加了排序怎么还有问题 利用mybatis拦截器记录sql,辅助我们建立索引(二) 利用mybatis拦截器记录sql,辅助我们建立索引(一) sql server版本太老,java客户端连接失败问题定位
linux中如何判断一个rpm是手动安装还是通过yum安装的
三国梦回 · 2025-03-14 · via 博客园 - 三国梦回

现状

对于一个不熟悉的服务器或者是虽然是自己的服务器,但历史比较久远,对于上面安装了的一些软件包,我们记忆都慢慢模糊了。

我今天遇到一个情况,在安装一个工具x2openEuler时,安装失败,提示依赖冲突:

[root@VM-0-6-centos x2openeuler]# yum install x2openEuler-core-3.0.0-20250104.x86_64.rpm 
...

image-20250314142605547

image-20250314142629918

我在网上都没发现别人有遇到这个问题,后面咨询了下ai,说可能是因为系统里安装了mysql的原因,这个工具会在系统中安装mariadb-server,安装时检查依赖,就发现和系统中的mysql有冲突。

判断mysql是源码安装还是rpm

在linux中,一个软件可能有多种安装方式。

  • 源码编译安装
  • 网上下载rpm,上传到服务器上rpm -ivh安装
  • yum方式安装

如果要卸载这个冲突的mysql,首先还得知道,当初是怎么安装的。

我先通过rpm查询,判断是通过rpm安装的,还是源码编译安装的。

[root@VM-0-6-centos x2openeuler]# rpm -qa |grep mysql
mysql-community-common-5.7.36-1.el7.x86_64
mysql-community-libs-compat-5.7.36-1.el7.x86_64
zabbix-server-mysql-5.0.18-1.el7.x86_64
mysql-community-libs-5.7.36-1.el7.x86_64
mysql-community-server-5.7.36-1.el7.x86_64
rh-php72-php-mysqlnd-7.2.24-1.el7.x86_64
zabbix-web-mysql-scl-5.0.18-1.el7.noarch
mysql57-community-release-el7-9.noarch
mysql-community-client-5.7.36-1.el7.x86_64

输出有结果,那就是rpm方式安装的。

下面这个命令,还可以看到时间。

[root@VM-0-6-centos x2openeuler]# rpm -qa --last|grep mysql
zabbix-web-mysql-scl-5.0.18-1.el7.noarch      Sat 18 Dec 2021 04:16:33 PM CST
rh-php72-php-mysqlnd-7.2.24-1.el7.x86_64      Sat 18 Dec 2021 04:16:31 PM CST
zabbix-server-mysql-5.0.18-1.el7.x86_64       Sat 18 Dec 2021 04:11:05 PM CST
mysql-community-libs-compat-5.7.36-1.el7.x86_64 Sun 28 Nov 2021 02:15:46 PM CST
mysql-community-server-5.7.36-1.el7.x86_64    Sun 28 Nov 2021 02:15:45 PM CST
mysql-community-client-5.7.36-1.el7.x86_64    Sun 28 Nov 2021 02:15:24 PM CST
mysql-community-libs-5.7.36-1.el7.x86_64      Sun 28 Nov 2021 02:15:21 PM CST
mysql-community-common-5.7.36-1.el7.x86_64    Sun 28 Nov 2021 02:15:21 PM CST
mysql57-community-release-el7-9.noarch        Sun 28 Nov 2021 02:12:07 PM CST

接下来的问题是,这些rpm是直接通过从网上下载了rpm包并上传,然后执行rpm -ivh安装呢,还是通过yum install的方式安装的呢?

判断是rpm ivh还是yum安装

方法1

我在以前发现了如下命令:

yum history

image-20250314143302168

这个命令,可以看到最近的20条yum安装,但是20条之外的,就看不到了。

如果你想看到20条之外的,可以使用如下命令:

yum history list all

image-20250314143943305

这次,可以显示这个服务器的所有记录了。但是,你们可能发现了,第二列那里,竟然显示的是root啥的,不是具体的安装命令了。

不要着急,修改下如下配置:

https://serverfault.com/questions/851717/yum-how-to-show-command-line-column-in-yum-history-list-all-output

# edit file "/etc/yum.conf" ==>>> and add this line somewhere in it
# 修改 /etc/yum.conf,增加如下行
history_list_view=cmds

然后重新执行,就正常了。如果只是临时生效,可以:

sudo yum --setopt=history_list_view=commands history list all

我这边搜了下mysql相关的,果然找到了,应该是第二条,第一行是这个yum事务的id,为56:

[root@VM-0-6-centos x2openeuler]# yum history list all |grep mysql
    59 | install zabbix-web-mysql | 2021-12-18 16:16 | Install        |   33 > 
    56 | install mysql-server     | 2021-11-28 14:15 | I, O           |    6 ><

接下来,就看下这个56号事务的详情:

 yum history info 56

image-20250314144524246

现在就确定了,就是这个事务,安装了mysql。

方法2

我们也可以通过其他命令,来找到对应的事务id。

[root@VM-0-6-centos x2openeuler]# yum history package-list \*mysql\*

image-20250314144810158

这里看到一个数字为56,我们通过查看 yum history info 56,确定了就是这个事务id。

通过事务id,回滚对应的安装

yum history undo 事务id

结果我这里不知道为啥,卸载失败了:

[root@VM-0-6-centos x2openeuler]# yum history undo 56
Undoing transaction 56, from Sun Nov 28 14:15:20 2021
    Obsoleted   mariadb-libs-1:5.5.65-1.el7.x86_64              @os
    Dep-Install mysql-community-client-5.7.36-1.el7.x86_64      @mysql57-community
    Dep-Install mysql-community-common-5.7.36-1.el7.x86_64      @mysql57-community
    Obsoleting  mysql-community-libs-5.7.36-1.el7.x86_64        @mysql57-community
    Obsoleting  mysql-community-libs-compat-5.7.36-1.el7.x86_64 @mysql57-community
    Install     mysql-community-server-5.7.36-1.el7.x86_64      @mysql57-community
Error: No package(s) available to install

还是手动卸载吧:

rpm -e mysql-community-server-5.7.36-1.el7.x86_64
rpm -e mysql-community-client-5.7.36-1.el7.x86_64
rpm -e mysql-community-libs-compat-5.7.36-1.el7.x86_64
rpm -e mysql-community-libs-5.7.36-1.el7.x86_64
rpm -e mysql-community-common-5.7.36-1.el7.x86_64

可参考:https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/6/html/deployment_guide/sec2-yum-transaction_history-reverting#sec2-Yum-Transaction_History-Reverting

参考文档

https://docs.redhat.com/en/documentation/red_hat_enterprise_linux/6/html/deployment_guide/sec-yum-transaction_history#sec2-Yum-Transaction_History-Listing

https://serverfault.com/questions/851717/yum-how-to-show-command-line-column-in-yum-history-list-all-output