提问者:小点点

集群中的ActiveMQ Artemis连接路由器配置


我需要使用连接路由器平衡ActiveMQ Artemis集群中活动节点上的传入连接。

我的集群由2个主节点(主节点A和主节点B)和2个从节点(从节点A和从节点B)组成,分为2组(组A和组B),这是一个2个实时备份对。我使用静态集群连接(tcp),从节点是主节点的副本(ha-policy复制)。

在我尝试添加连接路由器之前,一切都很好。HA集群对我的基本配置没问题(即在尝试添加连接路由器之前)。

在我尝试添加connect tion-routerconfig元素之前,从属节点出现在statist-连接器/连接器-ref中,并且接受器url中没有router参数。

我的客户端应用使用包含两个主节点的ConnectionFactoryURL(从节点不能接受连接,直到它们的主节点发生故障并且发生故障转移,所以我不会将它们放在这里)。

我的客户端应用程序有3个实例,每个实例都能够处理一个消费者,所以我期望每个主应用程序上有1个或2个消费者,这是我无法在每次启动时实现的。当然,有时会发生这种情况,但这只是巧合。

客户端应用程序使用admin/admin用户名和密码(用于测试目的)。

这是我所有4个实例的broc. xml(仅限相关部分):

大师A

<connectors>
    <!-- Connector used to be announced through cluster connections and notifications -->
    <connector name="masterA">tcp://localhost:61616</connector>
    <connector name="slaveA">tcp://localhost:61617</connector>
    <connector name="masterB">tcp://localhost:61626</connector>
    <connector name="slaveB">tcp://localhost:61627</connector>
</connectors>

  <acceptors>

     <acceptor name="artemis">tcp://localhost:61616?router=router-cluster-connection;tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;amqpMinLargeMessageSize=102400;protocols=CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE;useEpoll=true;amqpCredits=1000;amqpLowCredits=300;amqpDuplicateDetection=true;supportAdvisory=false;suppressInternalManagementObjects=false</acceptor>

  </acceptors>

  <cluster-user>myclusteruser</cluster-user>

  <cluster-password>myclusterpsw</cluster-password>

  <cluster-connections>
    <cluster-connection name="my-cluster">
      <connector-ref>masterA</connector-ref>
      <check-period>25001</check-period>
      <connection-ttl>30001</connection-ttl>
      <initial-connect-attempts>-1</initial-connect-attempts>
      <reconnect-attempts>-1</reconnect-attempts>
      <use-duplicate-detection>true</use-duplicate-detection>
      <message-load-balancing>ON_DEMAND</message-load-balancing>
      <max-hops>2</max-hops>
      <notification-interval>500</notification-interval>
      <notification-attempts>100</notification-attempts>
      <static-connectors>
        <connector-ref>masterA</connector-ref>
        <connector-ref>masterB</connector-ref>
<!--            <connector-ref>slaveA</connector-ref>
        <connector-ref>slaveB</connector-ref>-->
      </static-connectors>
    </cluster-connection>
  </cluster-connections>

  <connection-routers>
    <connection-router name="router-cluster-connection">
      <key-type>USER_NAME</key-type>
      <key-filter>admin</key-filter>
      <local-target-filter>admin</local-target-filter>
      <policy name="LEAST_CONNECTIONS" />
      <pool>
        <username>admin</username>
        <password>admin</password>
        <quorum-size>2</quorum-size>
        <local-target-enabled>true</local-target-enabled>
        <cluster-connection>my-cluster</cluster-connection>
      </pool>
    </connection-router>
  </connection-routers>

  <ha-policy>
     <replication>
        <master>
          <group-name>grappe-a</group-name>
          <check-for-live-server>true</check-for-live-server>
          <initial-replication-sync-timeout>3600000</initial-replication-sync-timeout>
          <vote-on-replication-failure>true</vote-on-replication-failure>
        </master>
     </replication>
  </ha-policy>

奴隶A

<connectors>
    <!-- Connector used to be announced through cluster connections and notifications -->
    <connector name="masterA">tcp://localhost:61616</connector>
    <connector name="slaveA">tcp://localhost:61617</connector>
    <connector name="masterB">tcp://localhost:61626</connector>
    <connector name="slaveB">tcp://localhost:61627</connector>
</connectors>


  <acceptors>

     <!-- Acceptor for every supported protocol -->
     <acceptor name="artemis">tcp://localhost:61617?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;amqpMinLargeMessageSize=102400;protocols=CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE;useEpoll=true;amqpCredits=1000;amqpLowCredits=300;amqpDuplicateDetection=true;supportAdvisory=false;suppressInternalManagementObjects=false</acceptor>

  </acceptors>

  <cluster-user>myclusteruser</cluster-user>

  <cluster-password>myclusterpsw</cluster-password>

  <cluster-connections>
     <cluster-connection name="my-cluster">
      <connector-ref>slaveA</connector-ref>
      <check-period>25003</check-period>
      <connection-ttl>30003</connection-ttl>
      <initial-connect-attempts>-1</initial-connect-attempts>
      <reconnect-attempts>-1</reconnect-attempts>
      <use-duplicate-detection>true</use-duplicate-detection>
      <message-load-balancing>ON_DEMAND</message-load-balancing>
      <max-hops>2</max-hops>
      <notification-interval>500</notification-interval>
      <notification-attempts>100</notification-attempts>
      <static-connectors>
        <connector-ref>masterA</connector-ref>
        <connector-ref>masterB</connector-ref>
<!--            <connector-ref>slaveA</connector-ref>
        <connector-ref>slaveB</connector-ref>-->
      </static-connectors>
    </cluster-connection>
  </cluster-connections>

  <ha-policy>
     <replication>
        <slave>
          <group-name>grappe-a</group-name>
          <allow-failback>true</allow-failback>
          <initial-replication-sync-timeout>36000000</initial-replication-sync-timeout>
            </slave>
     </replication>
  </ha-policy>

大师B

<connectors>
    <!-- Connector used to be announced through cluster connections and notifications -->
      <connector name="masterA">tcp://localhost:61616</connector>
      <connector name="slaveA">tcp://localhost:61617</connector>
      <connector name="masterB">tcp://localhost:61626</connector>
      <connector name="slaveB">tcp://localhost:61627</connector>
</connectors>

  <acceptors>
     <!-- Acceptor for every supported protocol -->
     <acceptor name="artemis">tcp://localhost:61626?router=router-cluster-connection;tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;amqpMinLargeMessageSize=102400;protocols=CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE;useEpoll=true;amqpCredits=1000;amqpLowCredits=300;amqpDuplicateDetection=true;supportAdvisory=false;suppressInternalManagementObjects=false</acceptor>

  </acceptors>

  <cluster-user>myclusteruser</cluster-user>

  <cluster-password>myclusterpsw</cluster-password>

  <cluster-connections>
    <cluster-connection name="my-cluster">
      <connector-ref>masterB</connector-ref>
      <check-period>25002</check-period>
      <connection-ttl>30002</connection-ttl>
      <initial-connect-attempts>-1</initial-connect-attempts>
      <reconnect-attempts>-1</reconnect-attempts>
      <use-duplicate-detection>true</use-duplicate-detection>
      <message-load-balancing>ON_DEMAND</message-load-balancing>
      <max-hops>2</max-hops>
      <notification-interval>500</notification-interval>
      <notification-attempts>100</notification-attempts>
      <static-connectors>
        <connector-ref>masterA</connector-ref>
        <connector-ref>masterB</connector-ref>
<!--            <connector-ref>slaveA</connector-ref>
        <connector-ref>slaveB</connector-ref>-->
      </static-connectors>
    </cluster-connection>
  </cluster-connections>

  <connection-routers>
    <connection-router name="router-cluster-connection">
      <key-type>USER_NAME</key-type>
      <key-filter>admin|NULL</key-filter>
      <local-target-filter>admin|NULL</local-target-filter>
      <policy name="LEAST_CONNECTIONS" />
      <pool>
        <username>admin</username>
        <password>admin</password>
        <quorum-size>2</quorum-size>
        <local-target-enabled>true</local-target-enabled>
        <cluster-connection>my-cluster</cluster-connection>
      </pool>
    </connection-router>
  </connection-routers>

  <ha-policy>
     <replication>
        <master>
          <group-name>grappe-b</group-name>
          <check-for-live-server>true</check-for-live-server>
          <initial-replication-sync-timeout>3600000</initial-replication-sync-timeout>
          <vote-on-replication-failure>true</vote-on-replication-failure>
        </master>
     </replication>
  </ha-policy>

奴隶b

<connectors>
    <!-- Connector used to be announced through cluster connections and notifications -->
    <connector name="masterA">tcp://localhost:61616</connector>
    <connector name="slaveA">tcp://localhost:61617</connector>
    <connector name="masterB">tcp://localhost:61626</connector>
    <connector name="slaveB">tcp://localhost:61627</connector>
</connectors>


  <acceptors>

     <!-- Acceptor for every supported protocol -->
     <acceptor name="artemis">tcp://localhost:61627?tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;amqpMinLargeMessageSize=102400;protocols=CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE;useEpoll=true;amqpCredits=1000;amqpLowCredits=300;amqpDuplicateDetection=true;supportAdvisory=false;suppressInternalManagementObjects=false</acceptor>

  </acceptors>

  <cluster-user>myclusteruser</cluster-user>

  <cluster-password>myclusterpsw</cluster-password>

  <cluster-connections>
     <cluster-connection name="my-cluster">
      <connector-ref>slaveB</connector-ref>
      <check-period>25004</check-period>
      <connection-ttl>30004</connection-ttl>
      <initial-connect-attempts>-1</initial-connect-attempts>
      <reconnect-attempts>-1</reconnect-attempts>
      <use-duplicate-detection>true</use-duplicate-detection>
      <message-load-balancing>ON_DEMAND</message-load-balancing>
      <max-hops>2</max-hops>
      <notification-interval>500</notification-interval>
      <notification-attempts>100</notification-attempts>
      <static-connectors>
        <connector-ref>masterA</connector-ref>
        <connector-ref>masterB</connector-ref>
<!--            <connector-ref>slaveA</connector-ref>
        <connector-ref>slaveB</connector-ref>-->
      </static-connectors>
    </cluster-connection>
  </cluster-connections>


  <ha-policy>
     <replication>
        <slave>
          <group-name>grappe-b</group-name>
          <allow-failback>true</allow-failback>
          <initial-replication-sync-timeout>36000000</initial-replication-sync-timeout>
        </slave>
     </replication>
  </ha-policy>

ActiveMQ Artemis的版本是2.22.0,在java11上运行。

我应该如何在我的代理中配置连接路由器以均匀平衡传入连接?

是否支持HA在代理上仅进行连接路由?

如果我在从代理中添加连接路由器元素,它们将无法复制。这是预期的吗?如果主服务器发生故障并发生故障转移,如果我希望从服务器复制,但无法将其添加到从服务器上,连接路由器功能如何仍然有效?

如果需要,我会提供更多细节。

更新路由器相关配置元素

<connectors>
    <connector name="masterA">tcp://localhost:61616</connector>
    <connector name="slaveA">tcp://localhost:61617</connector>
    <connector name="masterB">tcp://localhost:61626</connector>
    <connector name="slaveB">tcp://localhost:61627</connector>
    <connector name="routerA">tcp://localhost:61620</connector>
</connectors>

<acceptors>
    <acceptor name="artemis">tcp://127.0.0.1:61620?router=router-cluster-connection;tcpSendBufferSize=1048576;tcpReceiveBufferSize=1048576;amqpMinLargeMessageSize=102400;protocols=CORE,AMQP,STOMP,HORNETQ,MQTT,OPENWIRE;useEpoll=true;amqpCredits=1000;amqpLowCredits=300;amqpDuplicateDetection=true;supportAdvisory=false;suppressInternalManagementObjects=false</acceptor>
</acceptors>

<connection-routers>
    <connection-router name="router-cluster-connection">
        <key-type>USER_NAME</key-type>
        <key-filter>admin</key-filter>
        <policy name="ROUND_ROBIN" />
        <pool>
            <username>admin</username>
            <password>admin</password>
            <quorum-size>2</quorum-size>
            <local-target-enabled>false</local-target-enabled>
            <static-connectors>
                <connector-ref>masterA</connector-ref>
                <connector-ref>masterB</connector-ref>
            </static-connectors>
        </pool>
    </connection-router>
</connection-routers>


共1个答案

匿名用户

LEAST_CONNECTIONS策略可以很好地平衡传入连接,但尚未使用HA进行测试(由于连接路由器的备份代理引起的复制问题应由ARTEMIS-4113修复)。

通常,跨代理分区数据比平衡传入连接以提高性能更好,有关更多详细信息,请参阅对称简单示例。

为了避免SPOF,您可以使用对称架构,请参阅对称重定向和对称简单示例