keepalived报错image.png

与内网内其他keepalived群id一致导致

shell脚本错误

bash: ./a.sh: /bin/bash^M: bad interpreter: No such file or directory
image.png
编辑脚本 vim shell_name
输入 :set ff 然后回车,如果输出 fileformat=dos,说明脚本应该是在win系统编辑过,导致文件格式有变动,这时候输入 :set fileformat=unix
image.png
image.png

mysql创建函数报错

函数创建,必须先 use 数据库
image.png
DELIMITER 临时切换分隔符号,切换后;不在作为输入的完结标识
原因及解决办法
image.png

计划任务脚本失效

脚本直接shell执行正常,计划任务是执行报错
原因:mysql是编译安装的,执行文件路径是在/usr/local/mysql/bin/下,不在/etc/crontab 的path路径中。
解决办法:在执行backup函数前,执行 source /etc/profile ,重新获取系统的path路径
可以把该命令写入脚本中,也可以在计划任务中
1 0 * source /etc/profile && /脚本路径
image.png
image.png