Apache 2.4及以上版本中,在使用心跳lbmethod时需要确保代理模块中启用了mod_proxy_heartbeat,在服务器模块中启用了mod_lbmethod_heartbeat。以下为代码示例:
在服务器级别的配置文件中添加以下行:
LoadModule lbmethod_heartbeat_module modules/mod_lbmethod_heartbeat.so
在代理级别的配置文件中添加以下行:
LoadModule proxy_heartbeat_module modules/mod_proxy_heartbeat.so
并在ProxyPass和ProxyPassReverse指令中添加“lbmethod=heartbeat”参数,示例代码如下:
ProxyPass "/" "balancer://mycluster/" lbmethod=heartbeat
ProxyPassReverse "/" "balancer://mycluster/" lbmethod=heartbeat
以上配置完成后,重启Apache即可使心跳lbmethod生效。