搭建集群环境
消息的持久化和签收机制等都是为了保证消息的可靠性,但仅保证可靠性是不够的,有时我们还需要保证高可用性,这时就需要搭建ActiveMQ集群,以避免单点故障提升可用性。官方为我们介绍了三种集群搭建的方式
Master Slave Type | Requirements | Pros | Cons |
---|---|---|---|
Shared File System Master Slave | A shared file system such as a SAN | Run as many slaves as required. Automatic recovery of old masters | Requires shared file system |
JDBC Master Slave | A Shared database | Run as many slaves as required. Automatic recovery of old masters | Requires a shared database. Also relatively slow as it cannot use the high performance journal |
Replicated LevelDB Store | ZooKeeper Server | Run as many slaves as required. Automatic recovery of old masters. Very fast. | Requires a ZooKeeper server. |
5.6版本之后推出了LevelDB的持久化引擎,它使用自定义的索引代替常用的BTree索引,持久化性能高于KahaDB。虽然目前默认的持久化方式还是KahaDB,但是LevelDB会是趋势。5.9版本还提供了基于Zookeeper和LevelDB的数据主从复制方式(即Replicated LevelDB Store),是主从数据复制方案的首选。