![ActiveMQ Artemis:无法使用 JGroups 和 KUBE_PING 加入两个以上的代理](https://linux22.com/image/753913/ActiveMQ%20Artemis%EF%BC%9A%E6%97%A0%E6%B3%95%E4%BD%BF%E7%94%A8%20JGroups%20%E5%92%8C%20KUBE_PING%20%E5%8A%A0%E5%85%A5%E4%B8%A4%E4%B8%AA%E4%BB%A5%E4%B8%8A%E7%9A%84%E4%BB%A3%E7%90%86.png)
在使用 JGroups 和KUBE_PING 插件在 Kubernetes 上,我注意到最多只有两个 Broker 组成一个集群。任何其他 Broker 都将被忽略,无论它们是同时启动还是稍后启动。
一旦代理 1 和 2 建立了桥梁,我就会看到以下消息:
2020-06-17 13:11:51,416 INFO [org.apache.activemq.artemis.core.server] AMQ221027: Bridge ClusterConnectionBridge@320cdb5b [name=$.artemis.internal.sf.artemis-cluster.19db4aef-b09c-11ea-924c-02276c4ed44d, queue=QueueImpl[name=$.artemis.internal.sf.artemis-cluster.19db4aef-b09c-11ea-924c-02276c4ed44d, postOffice=PostOfficeImpl [server=ActiveMQServerImpl::serverUUID=094f73d3-b09c-11ea-842e-b65403ac65ce], temp=false]@1a62eadd targetConnector=ServerLocatorImpl (identity=(Cluster-connection-bridge::ClusterConnectionBridge@320cdb5b [name=$.artemis.internal.sf.artemis-cluster.19db4aef-b09c-11ea-924c-02276c4ed44d, queue=QueueImpl[name=$.artemis.internal.sf.artemis-cluster.19db4aef-b09c-11ea-924c-02276c4ed44d, postOffice=PostOfficeImpl [server=ActiveMQServerImpl::serverUUID=094f73d3-b09c-11ea-842e-b65403ac65ce], temp=false]@1a62eadd targetConnector=ServerLocatorImpl [initialConnectors=[TransportConfiguration(name=netty-connector, factory=org-apache-activemq-artemis-core-remoting-impl-netty-NettyConnectorFactory) ?port=61618&host=0-0-0-0], discoveryGroupConfiguration=null]]::ClusterConnectionImpl@1466558382[nodeUUID=094f73d3-b09c-11ea-842e-b65403ac65ce, connector=TransportConfiguration(name=netty-connector, factory=org-apache-activemq-artemis-core-remoting-impl-netty-NettyConnectorFactory) ?port=61618&host=0-0-0-0, address=, server=ActiveMQServerImpl::serverUUID=094f73d3-b09c-11ea-842e-b65403ac65ce])) [initialConnectors=[TransportConfiguration(name=netty-connector, factory=org-apache-activemq-artemis-core-remoting-impl-netty-NettyConnectorFactory) ?port=61618&host=0-0-0-0], discoveryGroupConfiguration=null]] is connected
2020-06-17 13:12:31,127 WARNING [org.jgroups.protocols.pbcast.FLUSH] asa-activemq-artemis-primary-0-51182: waiting for UNBLOCK timed out after 2000 ms
任何其他启动的代理都不会加入集群。但是,当添加<TRACE/>
到jgroups.xml
文件时,我可以看到所有节点都在通信。因此,看起来新代理的发现过程在第二个代理加入后就停止了。另外值得一提的是,看起来代理 3 和 4 构建了自己的集群。
配置 (broker.xml
):
<connectors>
<connector name="netty-connector">tcp://0.0.0.0:61618</connector>
</connectors>
<acceptors>
<acceptor name="netty-acceptor">tcp://0.0.0.0:61618</acceptor>
</acceptors>
<broadcast-groups>
<broadcast-group name="cluster-broadcast-group">
<broadcast-period>5000</broadcast-period>
<jgroups-file>jgroups.xml</jgroups-file>
<jgroups-channel>active_broadcast_channel</jgroups-channel>
<connector-ref>netty-connector</connector-ref>
</broadcast-group>
</broadcast-groups>
<discovery-groups>
<discovery-group name="cluster-discovery-group">
<jgroups-file>jgroups.xml</jgroups-file>
<jgroups-channel>active_broadcast_channel</jgroups-channel>
<refresh-timeout>10000</refresh-timeout>
</discovery-group>
</discovery-groups>
<cluster-connections>
<cluster-connection name="artemis-cluster">
<connector-ref>netty-connector</connector-ref>
<retry-interval>500</retry-interval>
<use-duplicate-detection>true</use-duplicate-detection>
<message-load-balancing>STRICT</message-load-balancing>
<!-- <address>jms</address> -->
<max-hops>1</max-hops>
<discovery-group-ref discovery-group-name="cluster-discovery-group"/>
<!-- <forward-when-no-consumers>true</forward-when-no-consumers> -->
</cluster-connection>
</cluster-connections>
请注意,我使用的是 Docker 镜像vromero/activemq-artemis:2.13.0
将上面显示的配置合并到主配置中broker.xml
。
jgroups.xml
:
<config xmlns="urn:org:jgroups"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:org:jgroups http://www.jgroups.org/schema/JGroups-3.0.xsd">
<TCP
enable_diagnostics="true"
bind_addr="match-interface:eth0,lo"
bind_port="7800"
recv_buf_size="20000000"
send_buf_size="640000"
max_bundle_size="64000"
max_bundle_timeout="30"
sock_conn_timeout="300"
thread_pool.enabled="true"
thread_pool.min_threads="1"
thread_pool.max_threads="10"
thread_pool.keep_alive_time="5000"
thread_pool.queue_enabled="false"
thread_pool.queue_max_size="100"
thread_pool.rejection_policy="run"
oob_thread_pool.enabled="true"
oob_thread_pool.min_threads="1"
oob_thread_pool.max_threads="8"
oob_thread_pool.keep_alive_time="5000"
oob_thread_pool.queue_enabled="true"
oob_thread_pool.queue_max_size="100"
oob_thread_pool.rejection_policy="run"
/>
<!-- <TRACE/> -->
<org.jgroups.protocols.kubernetes.KUBE_PING
namespace="${KUBERNETES_NAMESPACE:default}"
labels="${KUBERNETES_LABELS:cluster=activemq-artemis-asa}"
/>
<MERGE3 min_interval="10000" max_interval="30000"/>
<FD_SOCK/>
<FD timeout="10000" max_tries="5" />
<VERIFY_SUSPECT timeout="1500" />
<BARRIER />
<pbcast.NAKACK use_mcast_xmit="false" retransmit_timeout="300,600,1200,2400,4800" discard_delivered_msgs="true"/>
<UNICAST3
xmit_table_num_rows="100"
xmit_table_msgs_per_row="1000"
xmit_table_max_compaction_time="30000"
/>
<pbcast.STABLE stability_delay="1000" desired_avg_gossip="50000" max_bytes="400000"/>
<pbcast.GMS print_local_addr="true" join_timeout="3000" view_bundling="true"/>
<FC max_credits="2000000" min_threshold="0.10"/>
<FRAG2 frag_size="60000" />
<pbcast.STATE_TRANSFER/>
<pbcast.FLUSH timeout="0"/>
</config>
动态发现两个以上节点缺少什么?是否有任何参数可以阻止停止发现/加入过程?
答案1
好的,connector
配置是成功的关键:
<connectors>
<connector name="netty-connector">tcp://0.0.0.0:61618</connector>
</connectors>
其他节点无法连接到0.0.0.0
。一旦更改为可访问的内容,集群就会形成。在 Kubernetes 内部,使用主机名很棘手,所以我将其更改为
<connectors>
<connector name="netty-connector">tcp://${ipv4addr:localhost}:61618</connector>
</connectors>
当然,ipv4addr
需要以某种方式注入属性。对我来说,设置JAVA_OPTS
为-Dipv4addr=$(hostname -i)
就行了。
Artemis 集群的扩大和缩小现在可以按预期进行。