In the previous documents, we demonstrated how to use shared files and shared databases to realize the cluster of activemq. See also MasterSlave cluster deployment of ActiveMQ high availability solution (HA) (I)
In this section, we demonstrate how to implement clustering through leveldb + zookeeper.
Operation configuration list
service | Node name | Management port | Cluster communication port | Service directory |
---|---|---|---|---|
activemq | node2181 | 2181 | 2887:3887 | /usr/local/activemq-cluster/node2181 |
activemq | node2182 | 2182 | 2888:3888 | /usr/local/activemq-cluster/node2182 |
activemq | node2183 | 2183 | 2889:3889 | /usr/local/activemq-cluster/node2183 |
zookeeper | node2181 | 2181 | 2887:3887 | /usr/local/activemq-cluster/node2181 |
zookeeper | node2182 | 2182 | 2888:3888 | /usr/local/activemq-cluster/node2182 |
zookeeper | node2183 | 2183 | 2889:3889 | /usr/local/activemq-cluster/node2183 |
Key configuration
- activemq.xml
<!-- The persistent part is ZooKeeper Cluster connection address--> <persistenceAdapter> <replicatedLevelDB directory="${activemq.data}/leveldb" replicas="3" bind="tcp://0.0.0.0:0" zkAddress="localhost:2181,localhost:2182,localhost:2183" zkPath="/activemq/leveldb-stores" hostname="localhost" /> </persistenceAdapter>
The configuration is very simple, but there are many examples on the Internet, but I encountered a problem in the process of building. After the application deployment is completed, I can normally access the Master service, but after I try to turn off the Master service, I can check the Slave service log, and the exception message is as follows. I also check a lot of data on the Internet, and I have encountered the same problem. Clear activemq and zookeeper Restart after data, or delete a jar package and log information configuration, all of which have no effect. Later, I tried to backtrack the activemq version, and found that it can be active and standby. So here I write the version of my configuration.
2020-02-14 12:20:25,168 | INFO | No IOExceptionHandler registered, ignoring IO exception | org.apache.activemq.broker.BrokerService | LevelDB IOException handler. java.io.IOException: com/google/common/util/concurrent/internal/InternalFutureFailureAccess at org.apache.activemq.util.IOExceptionSupport.create(IOExceptionSupport.java:40)[activemq-client-5.15.11.jar:5.15.11] at org.apache.activemq.leveldb.LevelDBClient.might_fail(LevelDBClient.scala:552)[activemq-leveldb-store-5.15.11.jar:5.15.11] at org.apache.activemq.leveldb.LevelDBClient.replay_init(LevelDBClient.scala:667)[activemq-leveldb-store-5.15.11.jar:5.15.11] at org.apache.activemq.leveldb.LevelDBClient.start(LevelDBClient.scala:558)[activemq-leveldb-store-5.15.11.jar:5.15.11] at org.apache.activemq.leveldb.DBManager.start(DBManager.scala:648)[activemq-leveldb-store-5.15.11.jar:5.15.11] at org.apache.activemq.leveldb.LevelDBStore.doStart(LevelDBStore.scala:312)[activemq-leveldb-store-5.15.11.jar:5.15.11] at org.apache.activemq.leveldb.replicated.MasterLevelDBStore.doStart(MasterLevelDBStore.scala:110)[activemq-leveldb-store-5.15.11.jar:5.15.11] at org.apache.activemq.util.ServiceSupport.start(ServiceSupport.java:55)[activemq-client-5.15.11.jar:5.15.11] at org.apache.activemq.leveldb.replicated.ElectingLevelDBStore$$anonfun$start_master$1.apply$mcV$sp(ElectingLevelDBStore.scala:230)[activemq-leveldb-store-5.15.11.jar:5.15.11] at org.fusesource.hawtdispatch.package$$anon$4.run(hawtdispatch.scala:330)[hawtdispatch-scala-2.11-1.22.jar:1.22] at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)[:1.8.0_201] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)[:1.8.0_201] at java.lang.Thread.run(Thread.java:748)[:1.8.0_201] 2020-02-14 12:20:25,177 | INFO | Stopped LevelDB[/usr/local/activemq-cluster/node8162/data/leveldb] | org.apache.activemq.leveldb.LevelDBStore | LevelDB IOException handler.
Of course, if you want to see more detailed deployment steps, you can refer to the following link blog: