activitymq 集群构建
测试zk是否正常
[root@node2 bin]# cd /zk/1/zookeeper-3.4.10/bin/ [root@node2 bin]# ./zkCli.sh -server 10.50.50.38:2181 Connecting to 10.50.50.38:2181 2018-12-03 16:03:09,869 [myid:] - INFO [main:Environment@100] - Client environment:zookeeper.version=3.4.10-39d3a4f269333c922ed3db283be479f9deacaa0f, built on 03/23/2017 10:13 GMT 2018-12-03 16:03:09,873 [myid:] - INFO [main:Environment@100] - Client environment:host.name=node2 2018-12-03 16:03:09,873 [myid:] - INFO [main:Environment@100] - Client environment:java.version=1.8.0_171 2018-12-03 16:03:09,876 [myid:] - INFO [main:Environment@100] - Client environment:java.vendor=Oracle Corporation 2018-12-03 16:03:09,876 [myid:] - INFO [main:Environment@100] - Client environment:java.home=/usr/java/jdk1.8.0_171-amd64/jre 2018-12-03 16:03:09,877 [myid:] - INFO [main:Environment@100] - Client environment:java.io.tmpdir=/tmp 2018-12-03 16:03:09,877 [myid:] - INFO [main:Environment@100] - Client environment:java.compiler=<NA> 2018-12-03 16:03:09,877 [myid:] - INFO [main:Environment@100] - Client environment:os.name=Linux 2018-12-03 16:03:09,877 [myid:] - INFO [main:Environment@100] - Client environment:os.arch=amd64 2018-12-03 16:03:09,877 [myid:] - INFO [main:Environment@100] - Client environment:os.version=3.10.0-862.el7.x86_64 2018-12-03 16:03:09,877 [myid:] - INFO [main:Environment@100] - Client environment:user.name=root 2018-12-03 16:03:09,877 [myid:] - INFO [main:Environment@100] - Client environment:user.home=/root 2018-12-03 16:03:09,877 [myid:] - INFO [main:Environment@100] - Client environment:user.dir=/zk/1/zookeeper-3.4.10/bin 2018-12-03 16:03:09,879 [myid:] - INFO [main:ZooKeeper@438] - Initiating client connection, connectString=10.50.50.38:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyW atcher@799f7e29Welcome to ZooKeeper! 2018-12-03 16:03:09,905 [myid:] - INFO [main-SendThread(10.50.50.38:2181):ClientCnxn$SendThread@1032] - Opening socket connection to server 10.50.50.38/10.50.50.38:2181. Will not attempt to authenticate using SASL (unknown error)JLine support is enabled 2018-12-03 16:03:09,982 [myid:] - INFO [main-SendThread(10.50.50.38:2181):ClientCnxn$SendThread@876] - Socket connection established to 10.50.50.38/10.50.50.38:2181, initiating session 2018-12-03 16:03:09,997 [myid:] - INFO [main-SendThread(10.50.50.38:2181):ClientCnxn$SendThread@1299] - Session establishment complete on server 10.50.50.38/10.50.50.38:2181, sessionid = 0x1 6772dd90850001, negotiated timeout = 30000 WATCHER:: WatchedEvent state:SyncConnected type:None path:null [zk: 10.50.50.38:2181(CONNECTED) 0]
下载配置启动
mkdir -pv /activemq/activemq{1,2,3} tar xf apache-activemq-5.14.3-bin.tar.gz -C /activemq/activemq1/ tar xf apache-activemq-5.14.3-bin.tar.gz -C /activemq/activemq2/ tar xf apache-activemq-5.14.3-bin.tar.gz -C /activemq/activemq3/ cd /activemq/activemq1/apache-activemq-5.14.3/conf/ cp -a activemq.xml{,.bak} 后面需要修改的配置文件都在ACTIVEMQ_HOME/conf文件夹下。首先修改每个ActiveMQ的持久化方式(修改ACTIVEMQ_HOME/bin/activemq.xml文件),ActiveMQ默认使用的是kahaDB作为持久化存储数据的,这里修改成levelDB。如下所示 vim activemq.xml <persistenceAdapter> <replicatedLevelDB directory="${activemq.data}/leveldb" replicas="3" bind="tcp://0.0.0.0:62621" zkAddress="10.50.50.38:2381,10.50.50.38:2381,10.50.50.38:2381" hostname="10.50.50.38" zkPath="/activemq/leveldb-stores" /> </persistenceAdapter> [root@node2 conf]# cd /activemq/activemq2/apache-activemq-5.15.8/conf/ [root@node2 conf]# vim activemq.xml mechanism is the KahaDB store (identified by the kahaDB tag). For more information, see: http://activemq.apache.org/persistence.html --> <persistenceAdapter> <replicatedLevelDB directory="${activemq.data}/leveldb" replicas="3" bind="tcp://0.0.0.0:62621" zkAddress="10.50.50.38:2381,10.50.50.38:2381,10.50.50.38:2381" hostname="10.50.50.38" zkPath="/activemq/leveldb-stores" /> </persistenceAdapter> <transportConnectors> <!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB --> <transportConnector name="openwire" uri="tcp://0.0.0.0:61617?maximumConnections=1000&wireFormat.maxFrameSize=104857600"/> 把端口改61617 <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> [root@node2 conf]# vim jetty.xml <bean id="contexts" class="org.eclipse.jetty.server.handler.ContextHandlerCollection"> </bean> <bean id="jettyPort" class="org.apache.activemq.web.WebConsolePort" init-method="start"> <!-- the default port number for the web console --> <property name="host" value="0.0.0.0"/> <property name="port" value="8162"/> 修改默认端口 </bean> [root@node2 conf]# cd /activemq/activemq3/apache-activemq-5.15.8/conf/ [root@node2 conf]# vim activemq.xml [root@node2 conf]# vim activemq.xml <persistenceAdapter> <replicatedLevelDB directory="${activemq.data}/leveldb" replicas="3" bind="tcp://0.0.0.0:62621" zkAddress="10.50.50.38:2381,10.50.50.38:2381,10.50.50.38:2381" hostname="10.50.50.38" zkPath="/activemq/leveldb-stores" /> </persistenceAdapter> <transportConnectors> <!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB --> <transportConnector name="openwire" uri="tcp://0.0.0.0:61618?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"/> [root@node2 conf]# vim jetty.xml </tran <bean id="jettyPort" class="org.apache.activemq.web.WebConsolePort" init-method="start"> <!-- the default port number for the web console --> <property name="host" value="0.0.0.0"/> <property name="port" value="8163"/> 修改默认端口 </bean> sportConnectors>
启动服务
[root@node2 conf]# cd /activemq/activemq1/apache-activemq-5.15.8/bin/ [root@node2 bin]# ./activemq start [root@node2 bin]#cd /activemq/activemq2/apache-activemq-5.15.8/bin/ [root@node2 bin]# ./activemq start [root@node2 bin]#cd /activemq/activemq3/apache-activemq-5.15.8/bin/ [root@node2 bin]# ./activemq start [root@node2 bin]# ss -lntp | grep 61616 LISTEN 0 128 :::61616 :::* users:(("java",pid=13674,fd=154))
参考文章:https://blog.csdn.net/haoyuyang/article/details/53931710
草都可以从石头缝隙中长出来更可况你呢