问题描述:

  今天在做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的更多相关文章

  1. MySQL查询报错 ERROR: No query specified

    今天1网友,查询报错ERROR: No query specified,随后它发来截图. root case:查询语法错误 \G后面不能再加分号;,由于\G在功能上等同于;,假设加了分号,那么就是;; ...

  2. 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 ...

  3. 解决mysql登录报错ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)问题

    问题描述: 在ubuntu14.04上安装完MYSQL后,MYSQL默认给分配了一个默认密码,但当自己在终端上使用默认密码登录的时候,总会提示一个授权失败的错误. 报错信息:Access denied ...

  4. 编译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 ...

  5. Linux下rm -rf删除文件夹报错_ Device or resource busy

    1.错误信息 rm: cannot remove `speechd-centos_6.2-prtl-pred-mf34/modules/t2p/py/third/g2p/.nfs00000000039 ...

  6. mysql登录报错 ERROR 1045 (28000)

    1.现象: [root@localhost ~]# mysql -u root -p Enter password:  ERROR 1045 (28000): Access denied for us ...

  7. 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 ...

  8. 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 ...

  9. 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 ...

随机推荐

  1. 如何绘制UML图?

    首先推荐在线绘制UML的网址:https://www.processon.com/,很好用. 在软件开发过程中,开发人员往往需要通过绘制类图来理清业务的实现思路,从而方便代码实现,也便于后期的代码维护 ...

  2. 向json对象中添加数组

    // JSONArray jsonArray = new JSONArray();// for (int i = 0; i < list.size(); i++) {// JSONObject ...

  3. Nginx (安装+ 配置域名+ 访问认证 +发布文件)

    一.Nginx介绍: Nginx是一款高性能的HTTP和反向代理服务器,能够选择高效的epoll(linux2.6内核).kqueue(freebsd).eventport(solaris10)作为网 ...

  4. Dijskstra算法

    #include <iostream> #include <cstdio> #include <queue> #include <vector> usi ...

  5. C# Xamarin移动开发基础进修篇

    一.课程介绍 英文原文:C# is the best language for mobile app development. Anything you can do in Objective-C, ...

  6. 测试通过!为何线上还有很多BUG?实践中的质量控制

    质量控制 大多数测试人员认为测试工作是发现bug,虽然这是测试的主要任务,但其实测试最重要的任务是质量控制,而发现bug和验证bug只是质量控制的一个重要环节而已. 我想很多测试人员都经历过这样的场景 ...

  7. 国际化之Android设备支持的语种

    昨天发了关于iOS支持的语种,文章最后也补了安卓支持语种列表.但最后发现安卓设备支持跟它列的有出入,我重新完全手工整理了一遍. 我将对应的语种在安卓的语言列表里的显示,也全部逐一列出来了,方便大家到时 ...

  8. IIS安装、配置 发布网站 报错解决方案

    错误一:   HTTP 错误 500.19- Internal Server Error法请求该页面配置,因为页面的相关配置数据无效####   HTTP 错误 500.21 - Internal S ...

  9. Glide4 用法总结 MD

    Markdown版本笔记 我的GitHub首页 我的博客 我的微信 我的邮箱 MyAndroidBlogs baiqiantao baiqiantao bqt20094 baiqiantao@sina ...

  10. Python 3安装MySQLdb

    Python 2安装的是mysql-python,Python 3安装mysql-python以后,仍然不能import MySQLdb,原来Python 3应该安装mysqlclient,就可以im ...