1.activemq版本信息
activemq:apache-activemq-5.18.4
2.activemq架构
3.activemq集群配置
activemq集群配置基于Networks of Brokers
这种HA方案的优点:是占用的节点数更少(只需要2个节点),而且2个broker都可以响应消息的接收与发送。不足:2个broker接收的信息,彼此不会互相同步;当其中一个broker节点异常down而无法启动时,如果删除data目录下的文件,启动activemq时,其上的消息也就丢失了
以下操作,需要在两个节点进行操作
1.进入activemq conf目录,备份activemq.xml文件
2.编辑activemq.xml文件,增加如下配置
节点1:
#定义brokerName="activemq1"
<broker xmlns="http://activemq.apache.org/schema/core" brokerName="activemq1" dataDirectory="${activemq.data}">
#在is(192.168.10.129)服务器节点上进行配置(写入is-2:61616,is-2即:192.168.10.173)
<networkConnectors>
<networkConnector uri="static:(tcp://is-2:61616)" />
</networkConnectors>
<broker xmlns="http://activemq.apache.org/schema/core" brokerName="activemq1" dataDirectory="${activemq.data}">
......<managementContext><managementContext createConnector="true" connectorPort="8899"/></managementContext><networkConnectors><networkConnector uri="static:(tcp://is-2:61616)" /></networkConnectors><!--Configure message persistence for the broker. The default persistencemechanism is the KahaDB store (identified by the kahaDB tag).For more information, see:http://activemq.apache.org/persistence.html--><persistenceAdapter><kahaDB directory="${activemq.data}/kahadb"/></persistenceAdapter>
......
节点2:
#定义brokerName="activemq2"
<broker xmlns="http://activemq.apache.org/schema/core" brokerName="activemq2" dataDirectory="${activemq.data}">
#在is-2(192.168.10.173)服务器节点上进行配置(写入is:61616,is即:192.168.10.129)
<networkConnectors>
<networkConnector uri="static:(tcp://is:61616)" />
</networkConnectors>
<broker xmlns="http://activemq.apache.org/schema/core" brokerName="activemq2" dataDirectory="${activemq.data}">
......<managementContext><managementContext createConnector="false"/></managementContext><networkConnectors><networkConnector uri="static:(tcp://is:61616)" /></networkConnectors><!--Configure message persistence for the broker. The default persistencemechanism is the KahaDB store (identified by the kahaDB tag).For more information, see:http://activemq.apache.org/persistence.html--><persistenceAdapter><kahaDB directory="${activemq.data}/kahadb"/></persistenceAdapter>
......
3.hosts文件设置ip地址和主机名映射
节点1:
节点2:
4.配置完成后,分别启动activemq
节点1:
节点2:
5.验证
节点1:
日志
activemq控制台(http://ip:8161 (默认的账号:admin 默认密码:admin))
节点2:
日志
activemq控制台(http://ip:8161 (默认的账号:admin 默认密码:admin))