关于更多activeMQ的实践(学习记录)请移步:https://gitee.com/ikgwr/activemq
节点 | 服务端口 | 管理端口 | 存储 | 网络连接器 | 用途 |
---|---|---|---|---|---|
Node-A | 61616 | 8161 | - | Node-B、Node-C | 消费者 |
Node-B | 61617 | 8162 | /activemq/kahadb/ | Node-A | 生产者、消费者 |
Node-C | 61618 | 8163 | /activemq/kahadb/ | Node-A | 生产者、消费者 |
1、创建三个activeMQ服务器
cp -rf apache-activemq-5.15.9 activemq/activemq-a
cp -rf apache-activemq-5.15.9 activemq/activemq-b
cp -rf apache-activemq-5.15.9 activemq/activemq-c
2、创建kahadb目录,作为Master/Slave集群使用的共享储存文件夹
cd activemq/
mkdir kahadb
3、编辑activemq-a下配置文件/conf/activemq.xml以及/conf/jetty.xml,注释其他协议,保留tcp协议,并添加网络连接配置项
<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="8161"/>
</bean>
<transportConnectors>
<!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB -->
<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>
<networkConnectors>
<networkConnector name="local_network" uri="static:(tcp://127.0.0.1:61617,tcp://127.0.0.1:61618)"/>
</networkConnectors>
5、编辑activemq-b下配置文件/conf/activemq.xml以及/conf/jetty.xml,注释其他协议,保留tcp协议,修改端口号,并添加网络连接配置项。因为B/C节点需要配置成Master/Slave,所以要修改共享存储文件的目录。
<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>
<persistenceAdapter>
<kahaDB directory="/software/activemq/kahadb"/>
</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"/>
<!-- <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>
<networkConnectors>
<networkConnector name="network_a" uri="static:(tcp://127.0.0.1:61616)"/>
</networkConnectors>
6、编辑activemq-c下配置文件/conf/activemq.xml以及/conf/jetty.xml,注释其他协议,保留tcp协议,修改端口号,并添加网络连接配置项。因为B/C节点需要配置成Master/Slave,所以要修改共享存储文件的目录。
<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>
<persistenceAdapter>
<kahaDB directory="/software/activemq/kahadb"/>
</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"/> -->
</transportConnectors>
<networkConnectors>
<networkConnector name="network_a" uri="static:(tcp://127.0.0.1:61616)"/>
</networkConnectors>
7、分别启动a/b/c节点
./software/activemq/activemq-a/bin/activemq start
./software/activemq/activemq-b/bin/activemq start
./software/activemq/activemq-c/bin/activemq start
8、查看对应端口,a/b节点已启动并监听相关端口,c节点在等待获得资源,没有启动提供服务
netstat -anp|grep 61616
netstat -anp|grep 61617
netstat -anp|grep 61618
9、停掉b节点,c节点启动提供服务