ActiveMQ HA solution based on shared file system
ActiveMQ HA solution based on shared file system
Configure NFS server
Yum install nfs-utils rpcbind
Set the shared directory and edit/etc/exports
/Home/mq1_data 192.168.41.199 (rw, sync, no_root_squash)
/Home/mq1_data 192.168.41.199 (rw, sync, no_root_squash)
Start the NFS server
Service rpcbind start
Chkconfig rpcbind on
Service nfs start
Configure NFS client
Yum install nfs-utils portmap (for CentOS 5)
Yum install nfs-utils rpcbind (for centos 6)
Check the file system that can be mounted
Showmount-e 192.168.188.143
Mount a File System
Mount-t nfs 192.168.188.143:/home/mq1_data/home/mq1_data-o nolock
Adjust the configuration file of message-oriented Middleware
Modify activemq. xml
<PersistenceAdapter>
<KahaDB directory = "/home/mq1_data"/>
</PersistenceAdapter>
Use failover as the connection string
ConnectionFactory connectionFactory = new ActiveMQConnectionFactory (
ActiveMQConnection. DEFAULT_USER,
ActiveMQConnection. DEFAULT_PASSWORD,
"Failover :( tcp: // 192.168.41.197: 61616, tcp: // 192.168.41.198: 61616 )");
Principle
The principle based on the shared file system is still relatively simple, because activemq locks the lock file at startup. When the Master is up, slaver will naturally wait there.
When the Master falls down, the lock of the lock file will be released, and one of the slaver will lock the lock file, which will exist as the Master.
When the fallen Master is up, the lock file is locked, so it can only be slaver, as for data .. Shared storage, data is there anyway
Recommended reading:
ActiveMQ installation in Linux
ACTIVEMQ server in Ubuntu
Error solving when ActiveMQ is started in CentOS 6.5
Spring + JMS + ActiveMQ + Tomcat Implement Message Service
Set ActiveMQ port and WEB port in Linux
This article permanently updates the link address: