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 ...
随机推荐
- 道路 [NOIP模拟]
Description 我们看见了一个由 m 行 n 列的 1*1 的格子组成的矩阵,每个格子(I,j)有对应的高度 h[i][j]和初始的一个非负权值 v[i][j].我们可以随便选择一个格子作为起 ...
- yii2 getter
GridView 表格多余内容显示 ... 1.直接在 GridView 中使用匿名函数书写,这种适合单个使用 <?= GridView::widget([ 'dataProvider' =&g ...
- openjdk for window
https://developers.redhat.com/products/openjdk/download/ https://github.com/dmlloyd/openjdk
- C#保存文件为无BOM的utf8格式
如图所示,发现用C#的 File.WriteAllLines 方法,无论怎么设置,最终生成的文件都是 PC utf8,也就是CRLF,用SVN进行提交的时候,显示左侧为utf8,右侧为utf8 BOM ...
- 利用Caffe训练模型(solver、deploy、train_val) + python如何使用已训练模型
版权声明:博主原创文章,微信公众号:素质云笔记,转载请注明来源“素质云博客”,谢谢合作!! https://blog.csdn.net/sinat_26917383/article/details/5 ...
- MySQL监控全部执行过的sql语句
MySQL监控全部执行过的sql语句 查看是否开启日志记录show variables like “general_log%” ; +——————+———-+|Variable_name|Value| ...
- windows10创建ftp服务器
1.创建用户 2.创建FTP服务 3.开通防火墙服务 建立端口21,20入站规则 4.访问测试
- Android必学之数据适配器BaseAdapter
什么是数据适配器? 下图展示了数据源.适配器.ListView等数据展示控件之间的关系.我们知道,数据源是各种各样的,而ListView所展示数据的格式则是有一定的要求的.数据适配器正是建立了数据源与 ...
- 如何禁用package-lock
因为 package-lock.json是自动生成的,可以配置 npm 来避免经常需要手动删除这个文件. 在当前项目禁用 package-lock.json 控制台下输入 echo 'package- ...
- linux服务器挂掉自动重启脚本(转)
实现原理主要是使用linux提供的crontab机制,定时查询服务器进程是否存在,如果宕机则执行我们预设的重启脚本. 首先我们要向crontab加入一个新任务 sudo crontab -e #进入编 ...