现象
一套环境,MySQL有一年多没有重启,客户有事需要重启,运维人员操作:
#mysql.server restart
启动失败,报expr: syntax error语法错误
手动用mysqld_safe启动
#mysqld_safe --user=mysql &
也报expr: syntax error语法错误
最后手动用mysqld --user=mysql & 启动成功
分析
对比了生产环境脚本文件mysql.server、mysqld_safe和测试环境上这两个文件代码一致,排除脚本被修改。怀疑是环境某个时刻有变动,而mysql一直没有重启,在这次重启暴露问题出来。
准备调试脚本
在mysql.server 代码里面266行 datadir" --pid-file="$mysqld_pid_file_path" $other_args >/dev/null & ,前面添加上sh -X,
即 sh -X datadir" --pid-file="$mysqld_pid_file_path" $other_args >/dev/null &
开始调试
sh -X mysql.servver start 报expr: syntax error语法错误
摘录关键段
- args=’ --log-error=/opt/mysql/data/log/error/mysqld.log --pid-file=/opt/mysql/data/workdbs/PRMED1.pid --socket=/opt/mysql/app/mysql-files/mysql.sock --port=3310’
- test 0 -eq 0
- NOHUP_NICENESS=nohup
- nohup nice
++ nice - normal_niceness=0
++ nohup nice - nohup_niceness=
- numeric_nice_values=1
- for val in ‘nohup_niceness’
- case “$val” in
- test 1 -eq 1
++ expr - 0
expr: syntax error - nice_value_diff=
发现,nice_value_diff=,值为空,原代码中语句是nice_value_diff=expr $nohup_niceness - $normal_niceness
,往上查找,nohup_niceness值是null,normal_niceness值是0
对nohup_niceness的值有怀疑,输出环境nohup_niceness值:
#nohup_niceness=nohup nice 2>/dev/null
#echo $nohup_niceness
结果输出是空,正常环境输出是0,所以文件nohup是有问题的。
解决
#which nohup,找到位置是/usr/bin/nohup
列出文件详细信息:
#stat /usr/bin/nohup
Size:1
对比其他环境,这文件Size是31552
打开文件vi /usr/bin/nohup,发现是空文件。猜测被人误操作置空文件。
于是,从其他同版本环境服务器复制nohup文件过来替换。
重新启动mysql
mysql.server start
成功启动!
文章被以下合辑收录
评论
