MHA向send_report传递的参数

何时被调用

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把他识别为位置参数.

### 多头注意力机制中的形状校验 多头自注意力(MHA, Multi-Head Attention)作为转换器架构的核心组件,在实现过程中经常遇到输入张量维度不匹配的问题。为了确保模型能够正常工作,`_mha_shape_check`函数用于验证输入张量的尺寸是否符合预期。 具体来说,该检查会确认查询(query)、键(key) 和 值(value) 的批次大小(batch size),序列长度(sequence length),以及嵌入维度(embedding dimension) 是否一致[^1]: ```python def _mha_shape_check(query, key, value): # Check that all inputs are of the same type. if not (query.dtype == key.dtype == value.dtype): raise ValueError( "All inputs to multi-head attention must be of the same dtype." ) # Ensure query/key/value have matching leading dimensions. target_size = query.size()[:-1] if key.size()[:-1] != target_size or value.size()[:-1] != target_size: raise RuntimeError(f"Mismatched leading dimensions; expected {target_size}") ``` 当这些条件未能满足时,则抛出异常来阻止进一步执行并提示开发者修正错误的数据结构[^2]。 此外,对于扩展到多个头部的情况,还需额外检验head数量与特征维数之间的关系,即确保每个单独注意头上分配到了足够的信息容量[^3]: ```python num_heads = num_heads if num_heads is not None else 1 embed_dim_per_head = embed_dim // num_heads if embed_dim % num_heads != 0: raise ValueError( f"Embedding dimension ({embed_dim}) should be divisible by number " f"of heads ({num_heads})" ) ``` 通过上述措施可以有效预防因数据格式不当而导致训练失败或性能下降等问题的发生。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值