pt-heartbeat --update --daemonize 只执行一次秒退的问题

使用pt-heartbeat帮助测试MySQL从库delay时长-

第一次运行测试成功,运行顺畅。

过几天再次用--update测试时,发现pt-heartbeat只update一次就自己退出了,--daemonize参数似乎不起作用。

而且程序退出的exitcode还是0.

排查半天未发现问题。

后在从库上测试,发现出现同样问题,但这次注意到--stop的时候有提示:

[root@localhost mysql3306]# /usr/bin/pt-heartbeat --stop --database=pt --defaults-file=/data/mysql/mysql3306/conf/my3306.cnf --socket=/data/mysql/mysql3306/3306.sock --ask-pass
Successfully created file /tmp/pt-heartbeat-sentinel

查看pt-heartbeat代码发现该文件存在pt-heartbeat就会自动退出。

删除掉该文件后,主库上终于可以运行pt了。

 

重新仔细阅读pt-heartbeat的man手册才发现,手册里早已经进行了说明。

       --sentinel
           type: string; default: /tmp/pt-heartbeat-sentinel
           Exit if this file exists.

       --stop
           Stop running instances by creating the sentinel file.
           This should have the effect of stopping all running instances which are watching the same sentinel file.  If none of "--update", "--monitor" or "--check" is specified, "pt-heartbeat" will exit
           after creating the file.  If one of these is specified, "pt-heartbeat" will wait the interval given by "--interval", then remove the file and continue working.
           You might find this handy to stop cron jobs gracefully if necessary, or to replace one running instance with another.  For example, if you want to stop and restart "pt-heartbeat" every hour
           (just to make sure that it is restarted every hour, in case of a server crash or some other problem), you could use a "crontab" line like this:
            0 * * * * pt-heartbeat --update -D test --stop \
              --sentinel /tmp/pt-heartbeat-hourly
           The non-default "--sentinel" will make sure the hourly "cron" job stops only instances previously started with the same options (that is, from the same "cron" job).
           See also "--sentinel".

[root@localhost mysql3306]# cat /tmp/pt-heartbeat-sentinel
Remove this file to permit pt-heartbeat to run
 
 

转载于:https://www.cnblogs.com/DataArt/p/10080626.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值