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 ...
随机推荐
- JS 数组方法
1.栈方法 ECMAScript 提供了一些让数组行为类似其他数据结构的方法 栈是一种后进先出(LIFO)的数据结构,也就是最新添加的项最早被移除:而栈中数据的添加和删除只发生在栈的顶部 数组可以对其 ...
- Java 多线程 ReadWriteLock
ReadWriteLock是JDK 1.5提供的读写分离锁,可以减少锁竞争.例如,线程A1.A2和A3进行写操作,线程B1.B2和B3进行读操作,如果使用重入锁或者内部锁,那么理论上所有读之间.读与写 ...
- 初学JDBC的一些总结(二)
一.简单介绍PreparedStatement 和Statement的区别: PreparedStatement是用来执行SQL查询语句的API之一,Java提供了 Statement.Prepare ...
- oracle 解决锁表问题
--首先查看有哪些锁 select /*+ rule */ s.username, decode(l.type,'TM','TABLE LOCK','TX','ROW LOCK',nu ...
- poj3617 Best Cow Line(贪心,字典序问题)
https://vjudge.net/problem/POJ-3617 这类字符串处理字典序问题经常用到贪心, 每决定输出一个字符之前,都要前后i++,j--逐个比大小,直至比出为止. #includ ...
- reduce方法简单实现数组中对象去重
js数组的reduce方法,接收一个函数(必须)和指定的初始值(非必须)作为参数,函数有三个参数,分别为初始值,当前项,当前数组,进行累加或者累积操作,初始值为每次累加或者累计后的结果 注意:在ie9 ...
- Linux配置防火墙,开启80端口、3306端口
Linux配置防火墙,开启80端口.3306端口 起因是因为想使用Navicat连接一下数据库,发现连接不上 通过查阅许多资料和多次测试发现是因为防火墙没有配置3306端口 话不多说,开整,同理, ...
- 已安装nginx动态添加模块
说明:已经安装好的nginx,需要添加一个未被编译安装的模块,需要怎么弄呢? 具体:这里以安装第三方ngx_http_google_filter_module模块为例nginx的模块是需要重新编译ng ...
- Linux脚本程序
#!/bin/bash # array-ops.sh: 数组更多有趣的用法. array=( zero one two three four five ) # 元素 ]} # zero } # zer ...
- Eclipse中jsp和html格式化自动排版问题
删除inline Elements 中所有的元素 http://m.codes51.com/article/detail_197472.html