The LevelDB store has been deprecated and is no longer supported or recommended for use. The recommended store is KahaDB
The Replicated LevelDB Store uses Apache ZooKeeper to pick a master from a set of broker nodes configured to replicate a LevelDB Store. Then synchronizes all slave LevelDB Stores with the master keeps them up to date by replicating all updates from the master.
The Replicated LevelDB Store uses the same data files as a LevelDB Store, so you can switch a broker configuration between replicated and non replicated whenever you want.
Available as of ActiveMQ 5.9.0.
How it works.
It uses Apache ZooKeeper to coordinate which node in the cluster becomes the master. The elected master broker node starts and accepts client connections. The other nodes go into slave mode and connect the the master and synchronize their persistent state /w it. The slave nodes do not accept client connections. All persistent operations are replicated to the connected slaves. If the master dies, the slaves with the latest update gets promoted to become the master. The failed node can then be brought back online and it will go into slave mode.
All messaging operations which require a sync to disk will wait for the update to be replicated to a quorum of the nodes before completing. So if you configure the store with
replicas="3" then the quorum size is
(3/2+1)=2. The master will store the update locally and wait for 1 other slave to store the update before reporting success. Another way to think about it is that store will do synchronous replication to a quorum of the replication nodes and asynchronous replication replication to any additional nodes.
When a new master is elected, you also need at least a quorum of nodes online to be able to find a node with the lastest updates. The node with the lastest updates will become the new master. Therefore, it's recommend that you run with at least 3 replica nodes so that you can take one down without suffering a service outage.
Clients should be using the Failover Transport to connect to the broker nodes in the replication cluster. e.g. using a URL something like the following:
You should run at least 3 ZooKeeper server nodes so that the ZooKeeper service is highly available. Don't overcommit your ZooKeeper servers. An overworked ZooKeeper might start thinking live replication nodes have gone offline due to delays in processing their 'keep-alive' messages.
For best results, make sure you explicitly configure the hostname attribute with a hostname or ip address for the node that other cluster members to access the machine with. The automatically determined hostname is not always accessible by the other cluster members and results in slaves not being able to establish a replication session with the master.
You can configure ActiveMQ to use LevelDB for its persistence adapter - like below :
Replicated LevelDB Store Properties
All the broker nodes that are part of the same replication set should have matching
brokerName XML attributes. The following configuration properties should be the same on all the broker nodes that are part of the same replication set:
The number of nodes that will exist in the cluster. At least (replicas/2)+1 nodes must be online to avoid service outage.
A security token which must match on all replication nodes for them to accept each others replication requests.
A comma separated list of ZooKeeper servers.
The password to use when connecting to the ZooKeeper server.
The path to the ZooKeeper directory where Master/Slave election information will be exchanged.
How quickly a node failure will be detected by ZooKeeper. (prior to 5.11 - this had a typo zkSessionTmeout)
Controls where updates are reside before being considered complete. This setting is a comma separated list of the following options:
Different replication sets can share the same
zkPath as long they have different
The following configuration properties can be unique per node:
When this node becomes a master, it will bind the configured address and port to service the replication protocol. Using dynamic ports is also supported. Just configure with
The host name used to advertise the replication service when this node becomes the master. If not set it will be automatically determined.
The replication node that has the latest update with the highest weight will become the master. Used to give preference to some nodes towards becoming master.
The store also supports the same configuration properties of a standard LevelDB Store but it does not support the pluggable storage lockers :
Standard LevelDB Store Properties
The directory which the store will use to hold it's data files. The store will create the directory if it does not already exist.
The number of concurrent IO read threads to allowed.
The max size (in bytes) of each data log file before log file rotation occurs.
Set to true to force checksum verification of all data that is read from the file system.
Make the store error out as soon as possible if it detects internal corruption.
The factory classes to use when creating the LevelDB indexes
Number of open files that can be used by the index.
Number keys between restart points for delta encoding of keys.
Amount of index data to build up in memory before converting to a sorted on-disk file.
The size of index data packed per block.
The maximum amount of off-heap memory to use to cache index blocks.
The type of compression to apply to the index blocks. Can be snappy or none.
The type of compression to apply to the log records. Can be snappy or none.
The LevelDB store does not yet support storing data associated with Delay and Schedule Message Delivery. Those are are stored in a separate non-replicated KahaDB data files. Unexpected results will occur if you use Delay and Schedule Message Delivery with the replicated leveldb store since that data will be not be there when the master fails over to a slave.