机器为 172.25.1.23 172.25.1.24 172.25.1.28 可以在/conf/users.properties中寻找 http://172.25.1.28:8161/index.html admin admin

TCP端口61616(主从集群172.25.1.23,172.25.1.24,172.25.1.28) 管理端口8161

软件下载 zookeeper下载地址: https://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.6.1/apache-zookeeper-3.6.1-bin.tar.gz Activemq下载地址 http://activemq.apache.org/components/classic/download/

首先需要初始化系统及安装JDK,并配置环境变量

export JAVA_HOME=/opt/app/jdk1.8.0_251 export PATH=$JAVA_HOME/bin:$PATH export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar

1、zookeeper安装 解压apache-zookeeper-3.6.1-bin.tar.gz /opt/app/zookeeper

cp /opt/app/zookeeper/conf/{zoo_sample,zoo}.cfg 修改为zoo.cfg文件如下 dataDir=/opt/app/zookeeper/data dataLogDir=/opt/app/zookeeper/logs

server.1=172.25.1.23:2888:3888 server.2=172.25.1.24:2888:3888 server.3=172.25.1.28:2888:3888 admin.serverPort=8888

同步至其它两台服务器 然后再修改以下相关参数

10.23 echo "1" >>/opt/app/zookeeper/data/myid 10.24 echo "2" >>/opt/app/zookeeper/data/myid 10.28 echo "3" >>/opt/app/zookeeper/data/myid

2、activemq安装 解压apache-activemq-5.16.0-bin.tar.gz至 /opt/app/activemq目录下面 进入/opt/app/activemq/conf目录 cp activemq.xml activemq.xml_bak 修改activemq.xml <persistenceAdapter> <!-- <kahaDB directory="${activemq.data}/kahadb"/> --> <replicatedLevelDB directory="${activemq.data}/leveldb" replicas="3" bind="tcp://0.0.0.0:0" zkAddress="172.25.1.23:2181,172.25.1.24:2181,172.25.1.28:2181" zkPath="/activemq/leveldb-stores" hostname="172.25.1.23" /> #注意hostname修改为各个主机的IP地址 修改jetty.xml cp jetty.xml jetty.xml_bak vi jetty.xml 将localhost修改为0.0.0.0 <property name="host" value="0.0.0.0"/>

3、activemq同步并启动 activemq同步至其它两台服务器 并修改activemq.xml配置文件 hostname=

启动

cd /opt/app/activemq/bin ./activemq start

三台都执行 只有一台提供服务 同步8161也只有一台可以打开

可以在/conf/users.properties中寻找 http://172.25.1.28:8161/index.html admin admin

出现以下报错就别折腾了,换版本为apache-activemq-5.15.9-bin.zip zookeeper也可以换一个低版本的。 至于以下报错,没有查出来是什么原因。 包括最新版本同样有这样的报错。 就是在三台中,把master杀掉后,slave不能自动接管。直接报错。 清理zk和data下面的以及修改日志,都不能解决。 只有换低一点版本。

以上文档,是用了最新的版本,但有问题,只是不想去改文档 ,直接换成apache-activemq-5.15.9-bin.zip

2020-09-04 10:46:56,775 | INFO | Using the pure java LevelDB implementation. | org.apache.activemq.leveldb.LevelDBClient | ActiveMQ BrokerService[activemq-pro] Task-2 2020-09-04 10:46:56,799 | 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.13.jar:5.15.13] at org.apache.activemq.leveldb.LevelDBClient.might_fail(LevelDBClient.scala:552)[activemq-leveldb-store-5.15.13.jar:5.15.13] at org.apache.activemq.leveldb.LevelDBClient.replay_init(LevelDBClient.scala:667)[activemq-leveldb-store-5.15.13.jar:5.15.13] at org.apache.activemq.leveldb.LevelDBClient.start(LevelDBClient.scala:558)[activemq-leveldb-store-5.15.13.jar:5.15.13] at org.apache.activemq.leveldb.DBManager.start(DBManager.scala:648)[activemq-leveldb-store-5.15.13.jar:5.15.13] at org.apache.activemq.leveldb.LevelDBStore.doStart(LevelDBStore.scala:312)[activemq-leveldb-store-5.15.13.jar:5.15.13] at org.apache.activemq.leveldb.replicated.MasterLevelDBStore.doStart(MasterLevelDBStore.scala:110)[activemq-leveldb-store-5.15.13.jar:5.15.13] at org.apache.activemq.util.ServiceSupport.start(ServiceSupport.java:55)[activemq-client-5.15.13.jar:5.15.13] at org.apache.activemq.leveldb.replicated.ElectingLevelDBStore$$anonfun$start_master$1.apply$mcV$sp(ElectingLevelDBStore.scala:230)[activemq-leveldb-store-5.15.13. jar:5.15.13] 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_251] at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)[:1.8.0_251] at java.lang.Thread.run(Thread.java:748)[:1.8.0_251] 2020-09-04 10:46:56,808 | INFO | Stopped LevelDB[/opt/app/activemq/data/leveldb] | org.apache.activemq.leveldb.LevelDBStore | LevelDB IOException handler.