基于zookeeper和leveldb搭建activemq集群,仅提供主备功能,避免单点故障,没有负载均衡功能。
搭建zookeeper环境
- 下载
- 修改 配置文件名 zoo_sample.cfg 修改为 zoo.cfg
- 修改 配置文件:
dataDir和dataLogDir需要创建一个文件夹data01,5个就是:data01、data02、data03、data04、data05 dataDir和dataLogDir可分开创建;
dataDir对应的文件夹必须分别创建一个文件myid 里面依次写上1,2,3,4,5,6
- clientPort端口,对应每个配置:2181、2182、2183、2184、2185
- 添加以下参数:5个配置相同
server.1=127.0.0.1:2888:3888
server.2=127.0.0.1:2889:3889
server.3=127.0.0.1:2890:3890
server.4=127.0.0.1:2891:3891
server.5=127.0.0.1:2892:3892
配置文件:
`# 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.
dataDir=/root/zook/data01
dataLogDir=/root/zook/data01
# the port at which the clients will connect
clientPort=2181
server.1=127.0.0.1:2888:3888
server.2=127.0.0.1:2889:3889
server.3=127.0.0.1:2890:3890
server.4=127.0.0.1:2891:3891
server.5=127.0.0.1:2892:3892 `
启动/状态/停止:bin目录下 #./zkServer.sh start /[status]/[stop]
二、activeMQ配置
- 下载
- 添加以下配置到activemq.xml配置文件,bind参数端口3个MQ依次对应62621,62622,62623
<persistenceAdapter> <replicatedLevelDB directory="${activemq.data}/leveldb"
replicas="3" bind="tcp://0.0.0.0:62621" zkAddress="127.0.0.1:2181,127.0.0.1:2182,127.0.0.1:2183,
127.0.0.1:2184,127.0.0.1:2185" hostname="localhost" zkPath="/activemq/leveldb-stores"/>
</persistenceAdapter>
启动/状态/停止 bin目录下 ./activemq start /[status]/[stop]
三、查看ZooInspector
四、完成收工
版权声明:本文为原创文章,版权归本站所有,欢迎分享本文,转载请保留出处!