ActiveMQ notes (2): HA solution based on ZooKeeper, activemqzookeeper

Source: Internet
Author: User
Tags stomp

ActiveMQ notes (2): HA solution based on ZooKeeper, activemqzookeeper

Activemq official website provides three master/slave HA solution, see: http://activemq.apache.org/masterslave.html, based on shared file directory, db, zookeeper.

The following shows how to build an activemq Cluster Based on zookeeper on the local machine:

1. Install activemq in the activemq1 directory (refer to the previous article) and modify conf/activemq. xml.

 1     <broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost" dataDirectory="${activemq.data}"> 2         ... 3         <persistenceAdapter> 4             <!--<kahaDB directory="${activemq.data}/kahadb"/>--> 5             <replicatedLevelDB 6                     directory="activemq-data" 7                     replicas="3" 8                     bind="tcp://0.0.0.0:0" 9                     zkAddress="127.0.0.1:2181,127.0.0.1:2182,127.0.0.1:2183"10                     zkSessionTimeout="2s"11                     zkPath="/activemq/leveldb-stores"12             />13         </persistenceAdapter>14         ...15     </broker>

Note: To ensure zk HA, the local machine must have at least three zk nodes. For more information, see my previous articles.

 

2. Copy activemq1 to activemq2 and activemq3. To prevent port conflict, you must modify the port for activemq. xml in the two directories.

        <transportConnectors>            <transportConnector name="openwire"                                uri="tcp://0.0.0.0:61616?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>            <transportConnector name="amqp"                                uri="amqp://0.0.0.0:5672?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>            <transportConnector name="stomp"                                uri="stomp://0.0.0.0:61613?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>            <transportConnector name="mqtt"                                uri="mqtt://0.0.0.0:1883?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>            <transportConnector name="ws"                                uri="ws://0.0.0.0:61614?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/>        </transportConnectors>

The above several ports can be adjusted as long as the three activemq servers do not conflict with each other.

 

3. Start zk1, zk2, zk3, and activemq1, activemq2, and activemq3.

Note: We recommend that you use the./activemq. sh console to start activemq for ease of output observation.

 

Iv. Test Failover

After the master node is started normally, stop the master node manually and observe the output of the remaining two node terminals. Normally, one of them will be automatically upgraded to the master node after a while.

 

Note: after using the above HA scheme, although the system availability has been improved, the test on the local machine shows that the same test code and use cases as in the previous article, when a single node is running, 8 k + messages can be sent in one second. After zookeeper HA scheme is adopted, only about 500 messages can be written per second.

 

References:

Http://activemq.apache.org/replicated-leveldb-store.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.