ActiveMQ-5.13.0集群
ActiveMQ集群介绍
ActiveMQ具有强大和灵活的集群功能,但在使用的过程中会发现很多的缺点,ActiveMQ的集群方式主要由两种:Master-Slave(ActiveMQ5.8版本已不可用)和Broker Cluster。
Broker集群
一个常见的场景是有多个 JMS broker ,有一个客户连接到其中一个 broker 。如果这个 broker 失效,那么客户会自动重新连接到其它的 broker 。在 ActiveMQ 中使用 failover:// 协议来实现这个功能。如果某个网络上有多个 brokers 而且客户使用静态发现(使用 Static Transport 或 Failover Transport )或动态发现(使用 Discovery Transport ),那么客户可以容易地在某个 broker 失效的情况下切换到其它的 brokers, 下面介绍静态发现方式:
(
动态方式也同理--只是配置文件的不同:
ActiveMQ解压目录\examples\conf\activemq-dynamic-network-broker1.xml
)
首先把从官网下载的压缩包文件解压成三个文件夹!
Static-broker1的配置:
(ActiveMQ解压目录
1\examples\conf\activemq-static-network-broker1.xml)的内容全部替换到(ActiveMQ解压目
录1\conf\activemq.xml) ---默认tcp://0.0.0.0:61616
配置文件内容稍加修改如下:
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!--
Create a static network of brokers
For more information, see: http://activemq.apache.org/networks-of-brokers.html To run this example network of ActiveMQ brokers run $ bin/activemq console xbean:examples/conf/activemq-static-network-broker1.xml and $ bin/activemq console xbean:examples/conf/activemq-static-network-broker2.xml in separate consoles
-->
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:amq="http://activemq.apache.org/schema/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd
http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd"> <!-- Allows us to use system properties as variables in this configuration file -->
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/> <broker xmlns="http://activemq.apache.org/schema/core" brokerName="static-broker2" dataDirectory="${activemq.data}"> <plugins>
<!-- use JAAS to authenticate using the login.config file on the classpath to configure JAAS -->
<jaasAuthenticationPlugin configuration="activemq" />
<!-- lets configure a destination based authorization mechanism -->
<authorizationPlugin>
<map>
<authorizationMap>
<authorizationEntries>
<authorizationEntry topic=">" read="admins" write="admins" admin="admins" />
<authorizationEntry queue=">" read="admins" write="admins" admin="admins" />
<authorizationEntry topic="ActiveMQ.Advisory.>" read="admins" write="admins" admin="admins"/>
<authorizationEntry queue="ActiveMQ.Advisory.>" read="admins" write="admins" admin="admins"/>
</authorizationEntries>
</authorizationMap>
</map>
</authorizationPlugin>
</plugins> <!-- Destination specific policies using destination names or wildcards -->
<destinationPolicy>
<policyMap>
<policyEntries>
<policyEntry queue=">" producerFlowControl="true" memoryLimit="20mb">
<deadLetterStrategy>
<individualDeadLetterStrategy queuePrefix="DLQ." useQueueForQueueMessages="true" />
</deadLetterStrategy>
</policyEntry>
<policyEntry topic=">" producerFlowControl="true" memoryLimit="20mb">
</policyEntry>
</policyEntries>
</policyMap>
</destinationPolicy> <!-- Use the following to configure how ActiveMQ is exposed in JMX -->
<managementContext>
<managementContext createConnector="true" connectorPort="1102"/>
</managementContext> <!--
The store and forward broker networks ActiveMQ will listen to
Create a duplex connector to the first broker
-->
<networkConnectors>
<networkConnector userName="admin" password="admin123456" uri="static:(tcp://localhost:61618)" duplex="true"/>
</networkConnectors> <persistenceAdapter>
<kahaDB directory="${activemq.data}/static-broker2/kahadb" />
</persistenceAdapter> <!-- The maximum amount of space the broker will use before slowing down producers -->
<systemUsage>
<systemUsage>
<memoryUsage>
<memoryUsage limit="20 mb"/>
</memoryUsage>
<storeUsage>
<storeUsage limit="1 gb" name="foo"/>
</storeUsage>
<tempUsage>
<tempUsage limit="100 mb"/>
</tempUsage>
</systemUsage>
</systemUsage> <!-- The transport connectors ActiveMQ will listen to -->
<transportConnectors>
<transportConnector name="openwire" uri="tcp://0.0.0.0:61616"/>
</transportConnectors> </broker> <import resource="jetty.xml"/> </beans>
(ActiveMQ解压目录2\examples\conf\activemq-static-network-broker1.xml)的内容全部替换 到(ActiveMQ解压目录2\conf\activemq.xml) ---默认tcp://0.0.0.0:61618
配置文件内容稍加修改如下:
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!--
Create a static network of brokers
For more information, see: http://activemq.apache.org/networks-of-brokers.html To run this example network of ActiveMQ brokers run $ bin/activemq console xbean:examples/conf/activemq-static-network-broker1.xml and $ bin/activemq console xbean:examples/conf/activemq-static-network-broker2.xml in separate consoles
-->
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:amq="http://activemq.apache.org/schema/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd
http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd"> <!-- Allows us to use system properties as variables in this configuration file -->
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/> <broker xmlns="http://activemq.apache.org/schema/core" brokerName="static-broker2" dataDirectory="${activemq.data}"> <plugins>
<!-- use JAAS to authenticate using the login.config file on the classpath to configure JAAS -->
<jaasAuthenticationPlugin configuration="activemq" />
<!-- lets configure a destination based authorization mechanism -->
<authorizationPlugin>
<map>
<authorizationMap>
<authorizationEntries>
<authorizationEntry topic=">" read="admins" write="admins" admin="admins" />
<authorizationEntry queue=">" read="admins" write="admins" admin="admins" />
<authorizationEntry topic="ActiveMQ.Advisory.>" read="admins" write="admins" admin="admins"/>
<authorizationEntry queue="ActiveMQ.Advisory.>" read="admins" write="admins" admin="admins"/>
</authorizationEntries>
</authorizationMap>
</map>
</authorizationPlugin>
</plugins> <!-- Destination specific policies using destination names or wildcards -->
<destinationPolicy>
<policyMap>
<policyEntries>
<policyEntry queue=">" producerFlowControl="true" memoryLimit="20mb">
<deadLetterStrategy>
<individualDeadLetterStrategy queuePrefix="DLQ." useQueueForQueueMessages="true" />
</deadLetterStrategy>
</policyEntry>
<policyEntry topic=">" producerFlowControl="true" memoryLimit="20mb">
</policyEntry>
</policyEntries>
</policyMap>
</destinationPolicy> <!-- Use the following to configure how ActiveMQ is exposed in JMX -->
<managementContext>
<managementContext createConnector="true" connectorPort="1102"/>
</managementContext> <!--
The store and forward broker networks ActiveMQ will listen to
Create a duplex connector to the first broker
-->
<networkConnectors>
<networkConnector userName="admin" password="admin123456" uri="static:(tcp://localhost:61620)" duplex="true"/>
</networkConnectors> <persistenceAdapter>
<kahaDB directory="${activemq.data}/static-broker2/kahadb" />
</persistenceAdapter> <!-- The maximum amount of space the broker will use before slowing down producers -->
<systemUsage>
<systemUsage>
<memoryUsage>
<memoryUsage limit="20 mb"/>
</memoryUsage>
<storeUsage>
<storeUsage limit="1 gb" name="foo"/>
</storeUsage>
<tempUsage>
<tempUsage limit="100 mb"/>
</tempUsage>
</systemUsage>
</systemUsage> <!-- The transport connectors ActiveMQ will listen to -->
<transportConnectors>
<transportConnector name="openwire" uri="tcp://0.0.0.0:61618"/>
</transportConnectors> </broker> <import resource="jetty.xml"/> </beans>
(ActiveMQ解压目录3\examples\conf\activemq-static-network-broker1.xml)的内容全部替换 到(ActiveMQ解压目录3\conf\activemq.xml) ---默认tcp://0.0.0.0:61618
配置文件内容稍加修改如下:
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<!--
Create a static network of brokers
For more information, see: http://activemq.apache.org/networks-of-brokers.html To run this example network of ActiveMQ brokers run $ bin/activemq console xbean:examples/conf/activemq-static-network-broker1.xml and $ bin/activemq console xbean:examples/conf/activemq-static-network-broker2.xml in separate consoles
-->
<beans
xmlns="http://www.springframework.org/schema/beans"
xmlns:amq="http://activemq.apache.org/schema/core"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd
http://activemq.apache.org/camel/schema/spring http://activemq.apache.org/camel/schema/spring/camel-spring.xsd"> <!-- Allows us to use system properties as variables in this configuration file -->
<bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/> <broker xmlns="http://activemq.apache.org/schema/core" brokerName="static-broker2" dataDirectory="${activemq.data}"> <plugins>
<!-- use JAAS to authenticate using the login.config file on the classpath to configure JAAS -->
<jaasAuthenticationPlugin configuration="activemq" />
<!-- lets configure a destination based authorization mechanism -->
<authorizationPlugin>
<map>
<authorizationMap>
<authorizationEntries>
<authorizationEntry topic=">" read="admins" write="admins" admin="admins" />
<authorizationEntry queue=">" read="admins" write="admins" admin="admins" />
<authorizationEntry topic="ActiveMQ.Advisory.>" read="admins" write="admins" admin="admins"/>
<authorizationEntry queue="ActiveMQ.Advisory.>" read="admins" write="admins" admin="admins"/>
</authorizationEntries>
</authorizationMap>
</map>
</authorizationPlugin>
</plugins> <!-- Destination specific policies using destination names or wildcards -->
<destinationPolicy>
<policyMap>
<policyEntries>
<policyEntry queue=">" producerFlowControl="true" memoryLimit="20mb">
<deadLetterStrategy>
<individualDeadLetterStrategy queuePrefix="DLQ." useQueueForQueueMessages="true" />
</deadLetterStrategy>
</policyEntry>
<policyEntry topic=">" producerFlowControl="true" memoryLimit="20mb">
</policyEntry>
</policyEntries>
</policyMap>
</destinationPolicy> <!-- Use the following to configure how ActiveMQ is exposed in JMX -->
<managementContext>
<managementContext createConnector="true" connectorPort="1102"/>
</managementContext> <!--
The store and forward broker networks ActiveMQ will listen to
Create a duplex connector to the first broker
-->
<networkConnectors>
<networkConnector userName="admin" password="admin123456" uri="static:(tcp://localhost:61616)" duplex="true"/>
</networkConnectors> <persistenceAdapter>
<kahaDB directory="${activemq.data}/static-broker2/kahadb" />
</persistenceAdapter> <!-- The maximum amount of space the broker will use before slowing down producers -->
<systemUsage>
<systemUsage>
<memoryUsage>
<memoryUsage limit="20 mb"/>
</memoryUsage>
<storeUsage>
<storeUsage limit="1 gb" name="foo"/>
</storeUsage>
<tempUsage>
<tempUsage limit="100 mb"/>
</tempUsage>
</systemUsage>
</systemUsage> <!-- The transport connectors ActiveMQ will listen to -->
<transportConnectors>
<transportConnector name="openwire" uri="tcp://0.0.0.0:61620"/>
</transportConnectors> </broker> <import resource="jetty.xml"/> </beans>
需要注意的是:由于是本地配置测试,故不能端口号相同(包括tcp和http),如果是三台服务器上配置,那么端口可以相同。
tcp:(ActiveMQ解压目录\conf\activemq.xml)
(1).<managementContext createConnector="true" connectorPort="1102"/>
(2).<networkConnector userName="admin" password="admin123456" uri="static:(tcp://localhost:61616)" duplex="true"/>
(3).<transportConnector name="openwire" uri="tcp://0.0.0.0:61620"/>
http:(ActiveMQ解压目录\conf\jetty.xml)
<property name="port" value="8162"/>
最后分别启动这三个activemq服务! (此处是windows7 64位系统)
(ActiveMQ解压目录1\bin\win64\activemq.bat)
(ActiveMQ解压目录2\bin\win64\activemq.bat)
(ActiveMQ解压目录3\bin\win64\activemq.bat)
测试:先启动消费者!然后启动生产者发送消息。(至于消费者和生产者代码,请留意我的另一篇博文activemq整合spring)
先测试两个服务同时启动情况,然后把其中一个服务关闭保留一个再测试。(点对点 一对多也进行测试)
ActiveMQ-5.13.0集群的更多相关文章
- apache-kylin-2.5.2-bin-cdh57与cdh-5.13.0集群整合运用
1.下载kylin最新版apache-kylin-2.5.2-bin-cdh57: 2.解压配置环境变量: export BASE_PATH="/opt/cloudera/parcels/C ...
- 在Hadoop-2.2.0集群上安装 Hive-0.13.1 with MySQL
fesh个人实践,欢迎经验交流!本文Blog地址:http://www.cnblogs.com/fesh/p/3872872.html 软件环境 操作系统:Ubuntu14.04 JDK版本:jdk1 ...
- 关于ActiveMQ的几种集群配置
ActiveMQ的几种集群配置. Queue consumer clusters 此集群让多个消费者同时消费一个队列,若某个消费者出问题无法消费信息,则未消费掉的消息将被发给其他正常的消费者,结构图如 ...
- ActiveMQ的几种集群配置
ActiveMQ是一款功能强大的消息服务器,它支持许多种开发语言,例如Java, C, C++, C#等等.企业级消息服务器无论对服务器稳定性还是速度,要求都很高,而ActiveMQ的分布式集群则能很 ...
- activemq+Zookeper高可用集群方案配置
在高并发.对稳定性要求极高的系统中,高可用的是必不可少的,当然ActiveMQ也有自己的集群方案.从ActiveMQ 5.9开始,ActiveMQ的集群实现方式取消了传统的Master-Slave方式 ...
- Ubuntu 12.04下spark1.0.0 集群搭建(原创)
spark1.0.0新版本的于2014-05-30正式发布啦,新的spark版本带来了很多新的特性,提供了更好的API支持,spark1.0.0增加了Spark SQL组件,增强了标准库(ML.str ...
- hadoop-2.6.0集群开发环境配置
hadoop-2.6.0集群开发环境配置 一.环境说明 1.1安装环境说明 本例中,操作系统为CentOS 6.6, JDK版本号为JDK 1.7,Hadoop版本号为Apache Hadoop 2. ...
- centos7.4安装高可用(haproxy+keepalived实现)kubernetes1.6.0集群(开启TLS认证)
目录 目录 前言 集群详情 环境说明 安装前准备 提醒 一.创建TLS证书和秘钥 安装CFSSL 创建 CA (Certificate Authority) 创建 CA 配置文件 创建 CA 证书签名 ...
- Spring Cloud Alibaba(7)---docker-compose搭建nacos1.4.0集群
docker-compose搭建nacos1.4.0集群 有关Nacos之前写过四篇文章. Spring Cloud Alibaba(3)---Nacos概述 Spring Cloud Alibaba ...
随机推荐
- CentOS防火墙开启、关闭与开放指定端口
系统为centos 5.5,部署好Tomcat之后却发现输入114.80.*.*:8080(即ip:8080)却无法显示Tomcat默认的首页.由于以前部署在Win Server的VPS上,Linux ...
- mysql常用函数汇总(分享)
以下是对mysql中的常用函数进行了汇总介绍.需要的朋友可以过来参考下. 一.数学函数ABS(x) 返回x的绝对值BIN(x) 返回x的二进制(OCT返回八进制,HEX返回十六进制)CEILING(x ...
- cocos2d-x开发记录:二,基本概念(骨骼动画)
九,骨骼动画 1.骨骼动画vs Sprite sheets 你能使用sprite sheets 创建动画,它很快又容易.直到你意识到你的游戏需要大量的动画并且内存消耗越来越高,并且需要时间载入全部数据 ...
- Spring 一二事(7) - annotation
之前的文章大多都是一带而过,一方面比较简单,一方面不是用的注解形式 在企业开发中,主要还是使用的注解来进行开发的 1 <!-- component:把一个类放入到spring容器中,该类就是一个 ...
- 如何对多个文件进行MODELSIM仿真? (由于是一个很大的项目,不可能把所有MODULE都放在一个文件里。 如何在ModelSim中对多个.V文件进行仿真?)
可以将所有要编译的所有文件的名字做一个list.新建一个文本文档,重命名为vflist vflist内容例子如下(src为文件夹):src/base_addr_chk.vsrc/config_mux. ...
- 桶排序-py
http://blog.chinaunix.net/uid-20775448-id-4222915.html 看了<啊哈算法>第一节,排序从小到大自己实现了. 从大到小,搜集了下资料.看了 ...
- CF 366E - Dima and Magic Guitar 最远曼哈顿距离
题目:http://codeforces.com/problemset/problem/366/E 事实上就是找 n * m 矩阵中数字 x 和 数字 y 的最远距离. 方法參照武森的论文<浅谈 ...
- angular学习笔记(七)-迭代1
本篇介绍angular中元素的迭代: <!DOCTYPE html> <html ng-app> <head> <title>4.1.迭代</ti ...
- tornado源码分析-模块介绍
1.Core web framework tornado.web - web框架功能模块,包括RequestHandler和Application两个重要的类 tornado.httpserver - ...
- Oracle PLSQL Demo - 04.数字FOR LOOP循环[NUMBERABLE (FOR) LOOP]
declare v_display ); begin .. loop .. loop dbms_output.put_line(i || ' - ' || j); end loop; end loop ...