MHA向send_report传递的参数

6 篇文章 1 订阅

何时被调用

failover最后调用

接收到的参数

这个比较好搞, 我们在配置文件中定义脚本

report_script=/etc/masterha/scripts/send_report

然后写一个shell脚本

[root@localhost 21:19:04 /etc/masterha/scripts]
#cat send_report
echo "1:$1" >> /etc/masterha/scripts/send_report.log 2>&1
echo "2:$2" >> /etc/masterha/scripts/send_report.log 2>&1
echo "3:$3" >> /etc/masterha/scripts/send_report.log 2>&1
echo "4:$4" >> /etc/masterha/scripts/send_report.log 2>&1
echo "5:$5" >> /etc/masterha/scripts/send_report.log 2>&1
echo "6:$6" >> /etc/masterha/scripts/send_report.log 2>&1
echo "---" >> /etc/masterha/scripts/send_report.log 2>&1
echo "all params:" >> /etc/masterha/scripts/send_report.log 2>&1
echo $@ >> /etc/masterha/scripts/send_report.log 2>&1
echo "---" >> /etc/masterha/scripts/send_report.log 2>&1
echo `date` >> /etc/masterha/scripts/send_report.log 2>&1
echo "---" >> /etc/masterha/scripts/send_report.log 2>&1

自己做一次正常的failove然后看log内容

[root@localhost 21:18:13 /etc/masterha/scripts]
#cat send_report.log 
1:--orig_master_host=192.168.98.11
2:--new_master_host=192.168.98.10
3:--new_slave_hosts=192.168.98.12
4:--conf=/etc/masterha/conf/cls_all.cnf
5:--subject=cls_all: MySQL Master failover 192.168.98.11(192.168.98.11:3306) to 192.168.98.10(192.168.98.10:3306) succeeded
6:--body=Master 192.168.98.11(192.168.98.11:3306) is down!

Check MHA Manager logs at localhost.localdomain:/masterha/cls_all/manager.log for details.

Started automated(non-interactive) failover.
Invalidated master IP address on 192.168.98.11(192.168.98.11:3306)
Selected 192.168.98.10(192.168.98.10:3306) as a new master.
192.168.98.10(192.168.98.10:3306): OK: Applying all logs succeeded.
192.168.98.10(192.168.98.10:3306): OK: Activated master IP address.
192.168.98.12(192.168.98.12:3306): OK: Slave started, replicating from 192.168.98.10(192.168.98.10:3306)
192.168.98.10(192.168.98.10:3306): Resetting slave info succeeded.
Master failover to 192.168.98.10(192.168.98.10:3306) completed successfully.

---
all params:
--orig_master_host=192.168.98.11 --new_master_host=192.168.98.10 --new_slave_hosts=192.168.98.12 --conf=/etc/masterha/conf/cls_all.cnf --subject=cls_all: MySQL Master failover 192.168.98.11(192.168.98.11:3306) to 192.168.98.10(192.168.98.10:3306) succeeded --body=Master 192.168.98.11(192.168.98.11:3306) is down! Check MHA Manager logs at localhost.localdomain:/masterha/cls_all/manager.log for details. Started automated(non-interactive) failover. Invalidated master IP address on 192.168.98.11(192.168.98.11:3306) Selected 192.168.98.10(192.168.98.10:3306) as a new master. 192.168.98.10(192.168.98.10:3306): OK: Applying all logs succeeded. 192.168.98.10(192.168.98.10:3306): OK: Activated master IP address. 192.168.98.12(192.168.98.12:3306): OK: Slave started, replicating from 192.168.98.10(192.168.98.10:3306) 192.168.98.10(192.168.98.10:3306): Resetting slave info succeeded. Master failover to 192.168.98.10(192.168.98.10:3306) completed successfully.
---
Fri Feb 28 21:18:38 CST 2020
---

6个参数, shell把他识别为位置参数.

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值