linux环境,通过rpm删除mysql包,报错:error reading information on service mysqld: Invalid argument
问题描述:
今天在做saltstack的练习,想要通过sls的方式,在远程进行mysql数据库的安装,发现无法通过service的方式启动数据库,然后就想给删除了重新进行安装,在通过rpm -e进行删除rpm包时,报下面的错误:
[root@testvm03 ~]# rpm -e mysql-server-5.1.-.el6_8.x86_64
error reading information on service mysqld: Invalid argument
error: %preun(mysql-server-5.1.-.el6_8.x86_64) scriptlet failed, exit status
问题分析:
开始对于这个报错,以为是rpm本身在删除软件的时候的报错,所以呢,就把错误贴到各种地方去搜索,搜索了很久也没有得到答案。后来想想,不对,我得仔细看看报错信息想要说明什么内容,然后看到第1行,明显是在读mysqld这个服务的信息报错,在思考,rpm -e的过程,首先应该是读取这个服务的状态,如果在运行,先将服务停掉,然后再进行删除各种相关文件的操作。
问题解决:
1.看看mysqld这个脚本是否存在,或者有问题
[root@testvm03 init.d]# ls -ltr
total
-rwxr-xr-x. root root Mar rhnsd
-rwxr-xr-x root root Oct rpcbind
-rwxr-xr-x. root root Aug rsyslog
-rwxr-xr-x. root root Sep crond
-rwxr-xr-x. root root Sep rdisc
-rwxr-xr-x. root root Feb postfix
-rwxr-xr-x. root root Jun saslauthd
-rwxr-xr-x. root root Jul single
-rwxr-xr-x. root root Jul network
-rwxr-xr-x. root root Jul netfs
-rwxr-xr-x. root root Jul netconsole
-rwxr-xr-x. root root Jul killall
-rwxr-xr-x. root root Jul halt
-rw-r--r--. root root Jul functions
-rwxr-xr-x. root root Jul udev-post
-rwxr-xr-x. root root Aug sandbox
-rwxr-xr-x. root root Aug restorecond
-rwxr-xr-x. root root Aug auditd
-rwxr-xr-x. root root Aug kdump
-rwxr-xr-x. root root Aug sshd
-rwxr-xr-x. root root Aug iptables
-rwxr-xr-x. root root Aug ip6tables
-rwxr-xr-x. root root Aug snmptrapd
-rwxr-xr-x. root root Aug snmpd
-r-xr-xr-x. root root Sep blk-availability
-r-xr-xr-x. root root Sep lvm2-monitor
-r-xr-xr-x. root root Sep lvm2-lvmetad
-rwxr-xr-x root root Sep rpcsvcgssd
-rwxr-xr-x root root Sep rpcidmapd
-rwxr-xr-x root root Sep rpcgssd
-rwxr-xr-x root root Sep nfslock
-rwxr-xr-x root root Sep nfs
-rwxr-xr-x. root root Sep mdmonitor
-rwxr-xr-x. root root Sep rhsmcertd
-rwxr-xr-x root root Jan mysqld #经过检查,发现mysqld中的脚本是空字节的,就是没有任何的内容,如果要查mysqld的状态,传参自然是不可用的
-rwxr-xr-x root root Jun httpd
-rwxr-xr-x root root Jun htcacheclean
-rwxr-xr-x. root root Jul nrpe
-rwxr-xr-x root root Feb : salt-minion
备注:这个也就能够解释执行service mysqld start为啥没有任何反应,脚本中啥都没有,mysqld根本不知道做什么。
2.考虑将其他机器上的mysqld脚本拷贝到/etc/init.d/目录下
[root@testvm03 init.d]# rm mysqld #删除空字节的mysqld脚本文件
rm: remove regular empty file `mysqld'? y
[root@testvm03 init.d]# rz #通过rz命令,将其他主机上可用的脚本上传到此 [root@testvm03 init.d]#
[root@testvm03 init.d]# ls -ltr
total
-rwxr-xr-x. root root Mar rhnsd
-rwxr-xr-x root root Oct rpcbind
-rwxr-xr-x. root root Aug rsyslog
-rwxr-xr-x. root root Sep crond
-rwxr-xr-x. root root Sep rdisc
-rwxr-xr-x. root root Feb postfix
-rwxr-xr-x. root root Jun saslauthd
-rwxr-xr-x. root root Jul single
-rwxr-xr-x. root root Jul network
-rwxr-xr-x. root root Jul netfs
-rwxr-xr-x. root root Jul netconsole
-rwxr-xr-x. root root Jul killall
-rwxr-xr-x. root root Jul halt
-rw-r--r--. root root Jul functions
-rwxr-xr-x. root root Jul udev-post
-rwxr-xr-x. root root Aug sandbox
-rwxr-xr-x. root root Aug restorecond
-rwxr-xr-x. root root Aug auditd
-rwxr-xr-x. root root Aug kdump
-rwxr-xr-x. root root Aug sshd
-rwxr-xr-x. root root Aug iptables
-rwxr-xr-x. root root Aug ip6tables
-rwxr-xr-x. root root Aug snmptrapd
-rwxr-xr-x. root root Aug snmpd
-r-xr-xr-x. root root Sep blk-availability
-r-xr-xr-x. root root Sep lvm2-monitor
-r-xr-xr-x. root root Sep lvm2-lvmetad
-rwxr-xr-x root root Sep rpcsvcgssd
-rwxr-xr-x root root Sep rpcidmapd
-rwxr-xr-x root root Sep rpcgssd
-rwxr-xr-x root root Sep nfslock
-rwxr-xr-x root root Sep nfs
-rwxr-xr-x. root root Sep mdmonitor
-rwxr-xr-x. root root Sep rhsmcertd
-rw-r--r-- root root Jan mysqld #有内容,没有执行权限
-rwxr-xr-x root root Jun httpd
-rwxr-xr-x root root Jun htcacheclean
-rwxr-xr-x. root root Jul nrpe
-rwxr-xr-x root root Feb : salt-minion
[root@testvm03 init.d]# chmod +x mysqld #增加该脚本的可执行权限
[root@testvm03 init.d]# ls -ltr
total 232
-rwxr-xr-x. 1 root root 2898 Mar 20 2010 rhnsd
-rwxr-xr-x 1 root root 2073 Oct 23 2012 rpcbind
-rwxr-xr-x. 1 root root 2011 Aug 15 2013 rsyslog
-rwxr-xr-x. 1 root root 2826 Sep 12 2013 crond
-rwxr-xr-x. 1 root root 1513 Sep 17 2013 rdisc
-rwxr-xr-x. 1 root root 3912 Feb 14 2014 postfix
-rwxr-xr-x. 1 root root 2056 Jun 23 2014 saslauthd
-rwxr-xr-x. 1 root root 647 Jul 22 2014 single
-rwxr-xr-x. 1 root root 6334 Jul 22 2014 network
-rwxr-xr-x. 1 root root 6064 Jul 22 2014 netfs
-rwxr-xr-x. 1 root root 2989 Jul 22 2014 netconsole
-rwxr-xr-x. 1 root root 652 Jul 22 2014 killall
-rwxr-xr-x. 1 root root 5866 Jul 22 2014 halt
-rw-r--r--. 1 root root 19295 Jul 22 2014 functions
-rwxr-xr-x. 1 root root 2294 Jul 24 2014 udev-post
-rwxr-xr-x. 1 root root 1698 Aug 9 2014 sandbox
-rwxr-xr-x. 1 root root 1822 Aug 9 2014 restorecond
-rwxr-xr-x. 1 root root 3580 Aug 10 2014 auditd
-rwxr-xr-x. 1 root root 19476 Aug 27 2014 kdump
-rwxr-xr-x. 1 root root 4621 Aug 27 2014 sshd
-rwxr-xr-x. 1 root root 10688 Aug 28 2014 iptables
-rwxr-xr-x. 1 root root 10804 Aug 28 2014 ip6tables
-rwxr-xr-x. 1 root root 1738 Aug 29 2014 snmptrapd
-rwxr-xr-x. 1 root root 2162 Aug 29 2014 snmpd
-r-xr-xr-x. 1 root root 1340 Sep 1 2014 blk-availability
-r-xr-xr-x. 1 root root 2757 Sep 1 2014 lvm2-monitor
-r-xr-xr-x. 1 root root 2134 Sep 1 2014 lvm2-lvmetad
-rwxr-xr-x 1 root root 2464 Sep 5 2014 rpcsvcgssd
-rwxr-xr-x 1 root root 2305 Sep 5 2014 rpcidmapd
-rwxr-xr-x 1 root root 2518 Sep 5 2014 rpcgssd
-rwxr-xr-x 1 root root 3526 Sep 5 2014 nfslock
-rwxr-xr-x 1 root root 6878 Sep 5 2014 nfs
-rwxr-xr-x. 1 root root 2571 Sep 5 2014 mdmonitor
-rwxr-xr-x. 1 root root 1215 Sep 16 2014 rhsmcertd
-rwxr-xr-x 1 root root 7026 Jan 27 2017 mysqld
-rwxr-xr-x 1 root root 3488 Jun 19 2018 httpd
-rwxr-xr-x 1 root root 2001 Jun 19 2018 htcacheclean
-rwxr-xr-x. 1 root root 1193 Jul 31 2018 nrpe
-rwxr-xr-x 1 root root 7752 Feb 21 06:06 salt-minion
3.尝试启动服务,或者删除软件包
[root@testvm03 init.d]# service mysqld start #尝试启动mysql,发现有内容,虽然报错了。
Initializing MySQL database: [ OK ]
MySQL Daemon failed to start.
Starting mysqld: [FAILED]
[root@testvm03 init.d]# ps -ef | grep mysql #没有启动成功,但是不是关注的焦点,焦点在于删除这个组件包
root : pts/ :: grep mysql
[root@testvm03 init.d]# tail -f /var/log/mysqld.log
^C
[root@testvm03 init.d]# rpm -qa | grep mysql
mysql-server-5.1.-.el6_8.x86_64
mysql-5.1.-.el6_8.x86_64
mysql-libs-5.1.-.el6_8.x86_64
[root@testvm03 init.d]# rpm -e mysql-server-5.1.-.el6_8.x86_64 #再次执行删除包操作,发现是能够删除掉的。
warning: /etc/logrotate.d/mysqld saved as /etc/logrotate.d/mysqld.rpmsave
[root@testvm03 init.d]# rpm -qa | grep mysql
mysql-5.1.-.el6_8.x86_64
mysql-libs-5.1.-.el6_8.x86_64
[root@testvm03 init.d]#
备注:该问题得到解决,mysql-server的软件包,已经成功删除。
小结:在这个问题解决之后,我思考了这么一个问题,当执行rpm -e来卸载一个软件包的时候,都做了些什么事情,找了好久,找到了如下的一些信息。
链接地址:http://ftp.rpm.org/max-rpm/ch-rpm-erase.html#S1-RPM-ERASE-WHAT-DOES-IT-DO
rpm -e — What Does it Do?
The rpm -e command (--erase is equivalent) removes, or erases, one or more packages from the system. RPM performs a series of steps whenever it erases a package:
It checks the RPM database to make sure that no other packages depend on the package being erased.
It executes a pre-uninstall script (if one exists). #执行一个预先卸载脚本,比如,检查软件是否在运行,运行就将其停掉等等。%preun 就是预卸载脚本的意思。
It checks to see if any of the package's config files have been modified. If so, it saves copies of them.
It reviews the RPM database to find every file listed as being part of the package, and if they do not belong to another package, deletes them.
It executes a post-uninstall script (if one exists).
It removes all traces of the package (and the files belonging to it) from the RPM database.
另外,我也对自己解决问题的思路进行了一个调整,当你在解决一个问题的时候,如果想要更好的解决问题,那么最好的方式,就是对于你要操作的东西,有个基本工作原理的理解。看似很慢的理解工作原理,花费时间来思考,实则在解决问题时,却变得更加的容易,而不仅仅是搜索,搜索,搜索。
文档创建时间:2019年3月8日14:39:04
linux环境,通过rpm删除mysql包,报错:error reading information on service mysqld: Invalid argument的更多相关文章
- MySQL查询报错 ERROR: No query specified
今天1网友,查询报错ERROR: No query specified,随后它发来截图. root case:查询语法错误 \G后面不能再加分号;,由于\G在功能上等同于;,假设加了分号,那么就是;; ...
- mysql安装报错error: Header V3 DSA signature: BAD, key ID
CentOS安装rpm安装MySQL时爆出警告: warning: mysql-community-server-5.7.18-1.el6.x86_64.rpm: Header V3 DSA/SHA1 ...
- 解决mysql登录报错ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)问题
问题描述: 在ubuntu14.04上安装完MYSQL后,MYSQL默认给分配了一个默认密码,但当自己在终端上使用默认密码登录的时候,总会提示一个授权失败的错误. 报错信息:Access denied ...
- 编译binutil包报错 error: array type has incomplete element type extern const struct relax_type md_relax_table[];
安装lfs时编译binutils出错: ../../sources/binutils-2.15.91.0.2/gas/config/tc-i386.h:457:32: error: array typ ...
- Linux下rm -rf删除文件夹报错_ Device or resource busy
1.错误信息 rm: cannot remove `speechd-centos_6.2-prtl-pred-mf34/modules/t2p/py/third/g2p/.nfs00000000039 ...
- mysql登录报错 ERROR 1045 (28000)
1.现象: [root@localhost ~]# mysql -u root -p Enter password: ERROR 1045 (28000): Access denied for us ...
- MySQL登录报错ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
[root@pisphkdcbsql01 mysql3307]# /opt/mysql3307/bin/mysql -upisp -ppisp@ mysql: [Warning] Using a pa ...
- mysql授权报错 ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
授权用户时报错,ERROR 1819 (HY000): Your password does not satisfy the current policy requirements 原因为其实与val ...
- Zabbix导入MySQL数据库报错ERROR 1046 (3D000) at line 1: No database selected
使用如下命令导入Zabbix数据库时报错 解决办法: 1.先把原始的数据库压缩包备份 cd /usr/share/doc/zabbix-server-mysql-4.0.7/ cp create.sq ...
随机推荐
- BZOJ4543[POI2014]Hotel加强版——长链剖分+树形DP
题意参见BZOJ3522 n<=100000 数据范围增强了,显然之前的转移方程不行了,那么不妨换一种. 因为不能枚举根来换根DP,那么我们描述的DP方程每个点要计算三个点都在这个点的子树内的方 ...
- Spring Boot集成JPA的Column注解命名字段无效的问题
偶然发现,Spring Boot集成jpa编写实体类的时候,默认使用的命名策略是下划线分隔的字段命名. Spring Boot版本:1.5.4.release 数据表: id int, userNam ...
- 认证鉴权与API权限控制在微服务架构中的设计与实现(四)
引言: 本文系<认证鉴权与API权限控制在微服务架构中的设计与实现>系列的完结篇,前面三篇已经将认证鉴权与API权限控制的流程和主要细节讲解完.本文比较长,对这个系列进行收尾,主要内容包括 ...
- web的几种轮播
我们在开发当中经常用到轮播.我在这里总结了一下几种,仅供参考: 第一种: 1.jQuery:用display :none/block控制的一种轮播: // CSS部分 #igs { margin: 3 ...
- JSP(6)—JavaBean及案例
基础: 一.JavaBean ①用作JavaBean的类必须是具有一个公共的无参数的构造方法 ②JavaBean的属性是以方法定义的形式出现的. ③JavaBean的属性名是根据Setter和gett ...
- 100本Python精品书籍(附pdf电子书下载)
51本Python精品书籍(附下载)链接: https://pan.baidu.com/s/19ydAKCFxM0plkepXMlqQLg 提取码: nnpe 400集python视频教程下载:链接: ...
- Python3 与 C# 并发编程之~ Net篇
NetCore并发编程 示例代码:https://github.com/lotapp/BaseCode/tree/master/netcore/4_Concurrency 先简单说下概念(其实之前也有 ...
- jPlayer获取播放时间
关于jPlayer的用法,可以参考:jPlayer 2.6.0开发者手册 http://www.jplayer.cn/developer-guide.html 视频播放例子: //视频播放 var v ...
- C# System.IO.StreamReader
实现一个 TextReader,使其以一种特定的编码从字节流中读取字符. using System; using System.IO; class Test { public static void ...
- InfluxDB源码阅读之httpd服务
操作系统 : CentOS7.3.1611_x64 go语言版本:1.8.3 linux/amd64 InfluxDB版本:1.1.0 服务模块介绍 源码路径: github.com/influxda ...