JBoss HornetQ 中的 EAP 6.4 集群,尽管它们在不同的盒子中

JBoss EAP 6.4 clustering in HornetQ although they are in different box

我的配置中有 2 个不同的盒子。每个盒子包含 2 个 JBoss EAP 6.4 实例。我正在为所有实例使用 stanadalone-full-ha.xml 配置。

我按以下方式在 2 个不同的盒子中启动 2 个实例:

standalone.sh -c standalone-full-ha.xml -b ipOfOneMachineInFirstBox -u 230.0.0.4 -Djboss.node.name=node1

standalone.sh -c standalone-full-ha.xml -b ipOfOneMachineInSecondBox -u 230.0.0.5  -Djboss.node.name=node1

当每个 JBoss 启动时,我可以在日志中看到它们连接到集群的消息。

13:28:21,715 INFO  [org.hornetq.core.server] (Thread-28 (HornetQ-server-HornetQServerImpl::serverUUID=c08d2d4d-1444-11e9-8c21-839549bb27e4-1283024282)) HQ221027: Bridge ClusterConnectionBridge@7d2f5397 [name=sf.my-cluster.f79947a0-1444-11e9-b0dd-e959e93529ee, queue=QueueImpl[name=sf.my-cluster.f79947a0-1444-11e9-b0dd-e959e93529ee, postOffice=PostOfficeImpl [server=HornetQServerImpl::serverUUID=c08d2d4d-1444-11e9-8c21-839549bb27e4]]@557c5a54 targetConnector=ServerLocatorImpl (identity=(Cluster-connection-bridge::ClusterConnectionBridge@7d2f5397 [name=sf.my-cluster.f79947a0-1444-11e9-b0dd-e959e93529ee, queue=QueueImpl[name=sf.my-cluster.f79947a0-1444-11e9-b0dd-e959e93529ee, postOffice=PostOfficeImpl [server=HornetQServerImpl::serverUUID=c08d2d4d-1444-11e9-8c21-839549bb27e4]]@557c5a54 targetConnector=ServerLocatorImpl [initialConnectors=[TransportConfiguration(name=netty, factory=org-hornetq-core-remoting-impl-netty-NettyConnectorFactory) ?port=5445&host=**ipOfOnMachineInSecondBox**], discoveryGroupConfiguration=null]]::ClusterConnectionImpl@837873239[nodeUUID=c08d2d4d-1444-11e9-8c21-839549bb27e4, connector=TransportConfiguration(name=netty, factory=org-hornetq-core-remoting-impl-netty-NettyConnectorFactory) ?port=5445&host=**ipOfOneMachineInFirstBox**, address=jms, server=HornetQServerImpl::serverUUID=c08d2d4d-1444-11e9-8c21-839549bb27e4])) [initialConnectors=[TransportConfiguration

我想我需要在 standalone-full-ha 中更改一些内容。他们都使用相同的配置。改个名字可以吗?

<subsystem xmlns="urn:jboss:domain:messaging:1.4">
        <hornetq-server>
            <clustered>true</clustered>
            <persistence-enabled>true</persistence-enabled>
            <security-enabled>false</security-enabled>
            <cluster-password>${jboss.messaging.cluster.password:CHANGE ME!!}</cluster-password>
            <backup>false</backup>
            <journal-type>NIO</journal-type>
            <journal-min-files>2</journal-min-files>

            <connectors>
                <netty-connector name="netty" socket-binding="messaging"/>
                <netty-connector name="netty-throughput" socket-binding="messaging-throughput">
                    <param key="batch-delay" value="50"/>
                </netty-connector>
                <in-vm-connector name="in-vm" server-id="0"/>
            </connectors>

            <acceptors>
                <netty-acceptor name="netty" socket-binding="messaging"/>
                <netty-acceptor name="netty-throughput" socket-binding="messaging-throughput">
                    <param key="batch-delay" value="50"/>
                    <param key="direct-deliver" value="false"/>
                </netty-acceptor>
                <in-vm-acceptor name="in-vm" server-id="0"/>
            </acceptors>

            <broadcast-groups>
                <broadcast-group name="bg-group1">
                    <socket-binding>messaging-group</socket-binding>
                    <broadcast-period>5000</broadcast-period>
                    <connector-ref>
                        netty
                    </connector-ref>
                </broadcast-group>
            </broadcast-groups>

            <discovery-groups>
                <discovery-group name="dg-group1">
                    <socket-binding>messaging-group</socket-binding>
                    <refresh-timeout>10000</refresh-timeout>
                </discovery-group>
            </discovery-groups>

            <cluster-connections>
                <cluster-connection name="my-cluster">
                    <address>jms</address>
                    <connector-ref>netty</connector-ref>
                    <discovery-group-ref discovery-group-name="dg-group1"/>
                </cluster-connection>
            </cluster-connections>

            <security-settings>
                <security-setting match="#">
                    <permission type="send" roles="guest"/>
                    <permission type="consume" roles="guest"/>
                    <permission type="createNonDurableQueue" roles="guest"/>
                    <permission type="deleteNonDurableQueue" roles="guest"/>
                </security-setting>
            </security-settings>

            <address-settings>
                <address-setting match="#">
                    <dead-letter-address>jms.queue.DLQ</dead-letter-address>
                    <expiry-address>jms.queue.ExpiryQueue</expiry-address>
                    <redelivery-delay>0</redelivery-delay>
                    <max-size-bytes>10485760</max-size-bytes>
                    <page-size-bytes>2097152</page-size-bytes>
                    <address-full-policy>PAGE</address-full-policy>
                    <message-counter-history-day-limit>10</message-counter-history-day-limit>
                    <redistribution-delay>1000</redistribution-delay>
                </address-setting>
            </address-settings>

            <jms-connection-factories>
                <connection-factory name="InVmConnectionFactory">
                    <connectors>
                        <connector-ref connector-name="in-vm"/>
                    </connectors>
                    <entries>
                        <entry name="java:/ConnectionFactory"/>
                    </entries>
                </connection-factory>
                <connection-factory name="RemoteConnectionFactory">
                    <connectors>
                        <connector-ref connector-name="netty"/>
                    </connectors>
                    <entries>
                        <entry name="java:jboss/exported/jms/RemoteConnectionFactory"/>
                    </entries>
                    <ha>true</ha>
                    <block-on-acknowledge>true</block-on-acknowledge>
                    <retry-interval>1000</retry-interval>
                    <retry-interval-multiplier>1.0</retry-interval-multiplier>
                    <reconnect-attempts>-1</reconnect-attempts>
                </connection-factory>
                <pooled-connection-factory name="hornetq-ra">
                    <transaction mode="xa"/>
                    <connectors>
                        <connector-ref connector-name="in-vm"/>
                    </connectors>
                    <entries>
                        <entry name="java:/JmsXA"/>
                    </entries>
                </pooled-connection-factory>
            </jms-connection-factories>

            <jms-destinations>
                <jms-queue name="ExpiryQueue">
                    <entry name="java:/jms/queue/ExpiryQueue"/>
                </jms-queue>
                <jms-queue name="DLQ">
                    <entry name="java:/jms/queue/DLQ"/>
                </jms-queue>
                <jms-queue name="SiGuardServerQueue">
                    <entry name="java:jboss/exported/queue/siguard/serverQueue"/>
                </jms-queue>
                <jms-topic name="SiGuardClientTopic">
                    <entry name="java:jboss/exported/topic/siguard/clientTopic"/>
                </jms-topic>
                <jms-topic name="SiGuardNodeTopic">
                    <entry name="java:jboss/exported/topic/siguard/nodeTopic"/>
                </jms-topic>
            </jms-destinations>
        </hornetq-server>
    </subsystem>

默认情况下,每个使用 standalone-full-ha.xml 的 HornetQ 实例将使用 UDP 多播来广播有关其自身的信息,并监听有关网络上其他潜在集群成员的信息。一般情况下,使用相同多播IP地址和端口的节点会相互发现并形成一个集群。

如果您根本不希望节点聚集在一起,那么您不应该配置集群。

如果您想在同一网络上拥有多个独立的节点集群,那么每个集群都必须通过在命令行中指定以下内容来使用唯一的多播地址:

  • -u:在socket-binding-group中使用的服务器配置中控制jboss.default.multicast.address系统属性。默认为 230.0.0.4.
  • -Djboss.messaging.group.address:这控制了用于HornetQ集群的messaging-group socket-binding使用的多播地址。默认为 231.7.7.7.

对于您的情况,我建议您使用如下内容启动您的 JBoss 实例:

standalone.sh -c standalone-full-ha.xml -b ipOfOneMachineInFirstBox -u 230.0.0.4 -Djboss.messaging.group.address=231.7.7.7 -Djboss.node.name=cluster1-node1

standalone.sh -c standalone-full-ha.xml -b ipOfOneMachineInSecondBox -u 230.0.0.5  -Djboss.messaging.group.address=231.7.7.8 -Djboss.node.name=cluster2-node1