ActiveMQ高可用集羣部署(基於Replicated LevelDB Store + Zookeeper)

ActiveMQ集羣的三種模式,如圖(官網php

一、第一種模式基於共享文件系統實現的,例如NFS、GlusterFshtml

二、第二種模式是共享一個數據庫數據庫

三、第三種依賴Zookeeper協調分佈式服務apache

 

以下記載基於第三種方式的安裝與配置,基於3臺雲服務器(m1,m1s1,m1s2)安全

 

1、安裝Zookeeper

官網下載壓縮包,三臺機器分別解壓,在zookeeper根目錄下建立 data 和 logs 文件夾,把conf目錄下的zoo_sample.cfg文件拷貝一份並更名爲zoo.cfg(默認配置名),配置以下bash

# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial 
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between 
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just 
# example sakes.
dataDir=/home/taydawn/zookeeper/data
dataLogDir=/home/taydawn/zookeeper/logs
# the port at which the clients will connect
clientPort=2181
server.1=0.0.0.0:2888:3888
server.2=m1s1:2888:3888
server.3=m1s2:2888:3888
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the 
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1

三臺機器配置相似。若是三臺機器實在同一局域網下,server配置能夠直接用主機名;不然須要把本機的zoo.cfg中的本機的主機名改成 0.0.0.0,不然會出錯(例子)。
服務器

查看暴露在公網上的Zookeeper的服務器信息tcp

echo envi | nc xx.xx.xx.xx 2181

 

2、安裝ActiveMQ

官網下載壓縮包,三臺機器分別解壓,修改conf目錄下的 activemq.conf,修改持久化配置,三臺機器的broker名稱必須同樣分佈式

<persistenceAdapter>
	<!-- <kahaDB directory="${activemq.data}/kahadb"/> -->
	<replicatedLevelDB directory="${activemq.data}/leveldb"
			replicas="3"
			bind="tcp://0.0.0.0:0"
			zkAddress="m1:2181,m1s1:2181,m1s2:2181"
			hostname="m1s1"
			zkPath="/activemq/leveldb-stores"
	/>
</persistenceAdapter>

 三臺機器配置相似,其中「zkPath」爲zookeeper的建立節點名稱,可以使用 zkCli.sh -server m1:2181 登陸zookeeper命令查看(其中bind配置能夠指定port,例如0.0.0.0:61619,0.0.0.0:0表明使用動態端口,由ActiveMQ本身指定空閒端口)ide

 

3、啓動

依次啓動Zookeeper的每個節點,而後再依次啓動ActiveMQ的三個節點便可。

 

相關文章

一、集羣配置參考文章

二、Zookeeper安全問題

相關文章
相關標籤/搜索