activemq master/slave 结构配置解析

   activemq是Apache一个重要的开源产品,对于queue的应用起到了很大的推动作用,当在实际的项目中应用时,通过queue传输的数据的安全性,是一个首要要考虑的问题,在activemq的配置中提供了三种mater/slave的备份方式:

一是内存备份,在系统停机后,原来的数据丢失,配置文件如下:

master broker的配置文件,没有任何特殊的地方,是一个标准的broker配置。

<beans
  xmlns="http://www.springframework.org/schema/beans"
  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.xsd
  http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd
  http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">

  <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>

  <broker brokerName="master"  xmlns="http://activemq.apache.org/schema/core">
    <transportConnectors>
      <transportConnector uri="tcp://localhost:62001"/>
    </transportConnectors>

  </broker>

</beans>

slave broker的配置文件中,红色的部分很重要,表明和一个master组成一个备份的结构,在正常情况下,这个slave处于standby状态,当master出现问题是,slave转为工作状态。

<beans
  xmlns="http://www.springframework.org/schema/beans"
  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.xsd
  http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd
  http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">

  <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>

  <broker brokerName="slave"  shutdownOnMasterFailure = "false"  masterConnectorURI="tcp://localhost:62001"  xmlns="http://activemq.apache.org/schema/core">

   <managementContext >
  <managementContext createConnector="true" connectorPort ="1098"/>
   </managementContext>
    <transportConnectors>
      <transportConnector uri="tcp://localhost:62002"/>
    </transportConnectors>


  </broker>

</beans>

二、利用共享文件配置master/slave的结构:

  1、在默认的情况下,activemq启动是利用文件作为持久化的存储,所以当两个broker在同一台服务器上启动,
 都不配 persistenceAdapter的情况下,就是文件文件共享式的互备机制。
  2、利用persistenceAdapter可以配置共享文件的位置,当broker启动在不同的服务器上时,
 才能形成互备机制。

     两个配置文件,除去transportationConnector不一致外,其他都相同:


<beans
  xmlns="http://www.springframework.org/schema/beans"
  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.xsd
  http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd
  http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd">

  <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"/>

  <broker brokerName="shared"   xmlns="http://activemq.apache.org/schema/core">

 <!--
  在默认的情况下,activemq启动是利用文件作为持久化的存储,所以当两个broker在同一台服务器上启动,
 都不配 persistenceAdapter的情况下,就是文件文件共享式的互备机制。
  利用persistenceAdapter可以配置共享文件的位置,当broker启动在不同的服务器上时,
 才能形成互备机制。
 -->
    <persistenceAdapter>
      <journaledJDBC dataDirectory="/sharedFileSystem/broker"/>
    </persistenceAdapter>


    <transportConnectors>
      <transportConnector uri="tcp://localhost:62001"/>
    </transportConnectors>

  </broker>

</beans>
三、利用数据库进行备份和文件的备份机制基本相同。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值