在本机完成2个broker的共享文件测试
2个broker的完整配置文件如下

 

<!--Licensed to the Apache Software Foundation (ASF) under one or morecontributor license agreements.  See the NOTICE file distributed withthis 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 withthe License.  You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed 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 andlimitations under the License.
-->
<!--  Create a dynamic network of brokersFor more information, see:http://activemq.apache.org/networks-of-brokers.htmlTo run this example network of ActiveMQ brokers run$ bin/activemq console xbean:conf/activemq-dynamic-network-broker1.xmland$ bin/activemq console xbean:conf/activemq-dynamic-network-broker2.xmlin separate consoles-->
<beansxmlns="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-2.0.xsdhttp://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"><bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/><broker xmlns="http://activemq.apache.org/schema/core" brokerName="dynamic-broker2" dataDirectory="${activemq.base}/data" ><!-- 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="1100"/></managementContext><!--Configure network connector to use multicast protocolFor more information, seehttp://activemq.apache.org/multicast-transport-reference.html--><networkConnectors><networkConnector uri="multicast://default"dynamicOnly="true" networkTTL="3" prefetchSize="1" decreaseNetworkConsumerPriority="true" /></networkConnectors><persistenceAdapter><!--<kahaDB directory="${activemq.base}/data/dynamic-broker2/kahadb" />--><kahaDB directory="D:/"/> </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 toConfigure discovery URI to use multicast protocol--><transportConnectors><transportConnector name="openwire" uri="tcp://0.0.0.0:61618" discoveryUri="multicast://default" /></transportConnectors></broker></beans>

另外一个Borker

<!--Licensed to the Apache Software Foundation (ASF) under one or morecontributor license agreements.  See the NOTICE file distributed withthis 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 withthe License.  You may obtain a copy of the License athttp://www.apache.org/licenses/LICENSE-2.0Unless required by applicable law or agreed to in writing, softwaredistributed 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 andlimitations under the License.
-->
<!--  Create a dynamic network of brokersFor more information, see:http://activemq.apache.org/networks-of-brokers.htmlTo run this example network of ActiveMQ brokers run$ bin/activemq console xbean:conf/activemq-dynamic-network-broker1.xmland$ bin/activemq console xbean:conf/activemq-dynamic-network-broker2.xmlin separate consoles-->
<beansxmlns="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-2.0.xsdhttp://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd"><bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/><broker xmlns="http://activemq.apache.org/schema/core" brokerName="dynamic-broker1" dataDirectory="${activemq.base}/data" ><!-- 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"/></managementContext><!--Configure network connector to use multicast protocolFor more information, seehttp://activemq.apache.org/multicast-transport-reference.html--><networkConnectors><networkConnector uri="multicast://default"dynamicOnly="true" networkTTL="3" prefetchSize="1" decreaseNetworkConsumerPriority="true" /></networkConnectors><persistenceAdapter><!--<kahaDB directory="${activemq.base}/data/dynamic-broker1/kahadb"/>--><kahaDB directory="D:/"/> </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 toConfigure discovery URI to use multicast protocol--><transportConnectors><transportConnector name="openwire" uri="tcp://0.0.0.0:61616" discoveryUri="multicast://default" /></transportConnectors></broker></beans>

上述2个配置文件中,重点在于2个配置文件在同一个目录, <kahaDB directory="D:/"/> 

分别启动2个broker。

客户端连接按照:private static final String URL="failover:(tcp://localhost:61616,tcp://localhost:61618)"; 进行连接,即初始61616端口为Master,61618为Slave .

1、验证是否可以正常发送接收。

启动producer发送消息,日志输出

[Thread-1] Sending message: 'Message: 0 sent at: Wed Oct 30 09:46:42 CST 2013  ...'
[Thread-1] Sending message: 'Message: 1 sent at: Wed Oct 30 09:46:52 CST 2013  ...'
[Thread-1] Sending message: 'Message: 2 sent at: Wed Oct 30 09:47:02 CST 2013  ...'
[Thread-1] Sending message: 'Message: 3 sent at: Wed Oct 30 09:47:12 CST 2013  ...'
[Thread-1] Sending message: 'Message: 4 sent at: Wed Oct 30 09:47:22 CST 2013  ...'
[Thread-1] Sending message: 'Message: 5 sent at: Wed Oct 30 09:47:32 CST 2013  ...'

启动consumer接收消息,日志输出

[Thread-1] Received: 'Message: 0 sent at: Wed Oct 30 09:46:42 CST 2013  ...' (length 255)
[Thread-1] Received: 'Message: 1 sent at: Wed Oct 30 09:46:52 CST 2013  ...' (length 255)
[Thread-1] Received: 'Message: 2 sent at: Wed Oct 30 09:47:02 CST 2013  ...' (length 255)
[Thread-1] Received: 'Message: 3 sent at: Wed Oct 30 09:47:12 CST 2013  ...' (length 255)
[Thread-1] Received: 'Message: 4 sent at: Wed Oct 30 09:47:22 CST 2013  ...' (length 255)
[Thread-1] Received: 'Message: 5 sent at: Wed Oct 30 09:47:32 CST 2013  ...' (length 255)

说明收发正常。

2、验证Master宕机时,Slave进行消息处理,是否有消息丢失。

先停止consumer,记住此时已经接收了消息的序号,(此时消息id是18 待重启的时候看是否从下一个序号开始接收),procuder一直保持消息的发送,

停止61616端口上的master ,然后再启动consumer,发现consumer接收的消息从第19个消息开始接收。

Connecting to URL: failover:(tcp://localhost:61616,tcp://localhost:61618)
Consuming queue: TOOL.DEFAULT.SJ
Using a non-durable subscription
Running 1 parallel threads
log4j:WARN No appenders could be found for logger (org.apache.activemq.transport.failover.FailoverTransport).
log4j:WARN Please initialize the log4j system properly.
log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.
[Thread-1] Received: 'Message: 19 sent at: Wed Oct 30 09:49:52 CST 2013 ...' (length 255)

说明master宕机后,不用进行任何处理,slave就可以继续处理消息了。

Shared File System Master Slave 全配置以及测试相关推荐

  1. virtio-fs: A Shared File System for Virtual Machines

    virtio-fs: A Shared File System for Virtual Machines

  2. Bind view的master与slave部署与测试

    上次写过一篇关于"centos 6.2安装bind 9.8.2 master.slave与自动修改后更新",地址为http://dl528888.blog.51cto.com/23 ...

  3. master slave mysql_Mysql---Master-slave复制方案 - dba成长之路 - 博客频道 - CSDN.NET

    准备环节: 主.从服务器 操作系统.mysql版本必须一致 一.环境 主机: master操作系统:centos 5.5  64位 IP:192.168.3.28 MySQL版本:5.5.17 从机: ...

  4. master slave mysql_MYSQL高可用之复制(MASTER/SLAVE)

    MYSQL高可用之复制(MASTER/SLAVE) 随着互联网的快速发展,对数据库的访问已经越来越频繁,仅凭单个服务器已经无法应对高并发的访问,也无法满足数据库提供7*24的服务,这个时候我们就必须考 ...

  5. 磁盘、分区及Linux文件系统 [Disk, Partition, Linux File System]

    1.磁盘基础知识 1.1 物理结构 硬盘的物理结构一般由磁头与碟片.电动机.主控芯片与排线等部件组成:当主电动机带动碟片旋转时,副电动机带动一组(磁头)到相对应的碟片上并确定读取正面还是反面的碟面,磁 ...

  6. 转:经典论文翻译导读之《Google File System》

    首页 所有文章 资讯 Web 架构 基础技术 书籍 教程 Java小组 工具资源 - 导航条 -首页所有文章资讯Web架构基础技术书籍教程Java小组工具资源 经典论文翻译导读之<Google ...

  7. 【转】The Google File System 中文版

    原文链接 http://www.cnblogs.com/lijunjie/archive/2011/03/08/1976660.html#top 摘要 我们设计并实现了Google GFS文件系统,一 ...

  8. GFS - The Google File System

    The Google File System http://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.125.789&rep=rep1 ...

  9. The Google File System

    摘要 我们设计并实现了Google GFS文件系统,一个面向大规模数据密集型应用的.可伸缩的分布式文件系统.GFS虽然运行在廉价的普遍硬件设备上,但是它依然了提供灾难冗余的能力,为大量客户机提供了高性 ...

  10. Mysql的master,slave的配置

    MYSQL的master,slave环境的搭建<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:off ...

最新文章

  1. 如何在SQL Server 2005中使用作业实现备份和特定删除
  2. 只做决定的架构师会成为团队的瓶颈!
  3. Mysql总结(二)
  4. Codeforces Round #565 (Div. 3) A. Divide it!
  5. 自建服务器调试,Mac简单实现服务器搭建(本地)与iOS调试
  6. CTF SQL注入知识点
  7. RealSense D435i数据录制 VINS离线运行
  8. 小程序投票帮怎么刷票
  9. 光谱共焦的干涉测量原理及厚度测量模式
  10. 基于Android的人脸门禁系统
  11. kafka 分区多节点消费
  12. 云原生 Kuma 简单部署与使用
  13. Unity编辑器拓展(GraphView制作对话系统编辑器)
  14. Drupal独到的编程思想
  15. 自我管理经典书籍推荐:除了《自我管理必读12篇》,这些书也不容错过
  16. 【C语言学习笔记】输出函数puts()
  17. MCSE 2012之应用程序控制策略AppLocker
  18. 使用pdfbox把PDF转换成图片
  19. 流量不清零:还在忽悠广大网民?
  20. MCU接入阿里物联网平台遇到的各种坑

热门文章

  1. C/C++中使用可变参数
  2. POJ 3414 Pots(BFS + 打印路径)
  3. 对PostgreSQL中bufmgr.c 中 bufs_to_lap的初步理解
  4. 无法连接 Plugins Market 失效的日子
  5. sql Server 2008 数据库自动备份维护计划
  6. Nerd的套现ATM机
  7. 可靠的Windows版Redis
  8. String.format中大括号的加入方法
  9. 【一周一算法】算法3:最常用的排序——快速排序
  10. [转贴]壮观啊!实拍中国最美公路