Activemq file sharing-based Master/Slave configuration Scheme

Source: Internet
Author: User
Assume that the two servers with the activemq Service are:
<span style="white-space:pre"></span>192.160.102.90192.168.102.91 

We plan to share the data storage directory in the activemq directory on 91 to the activemq service of 90.


Configuration on 91:

1. Install the NFS service and rpcbind service. These two services are generally installed on the server, you can run the "service NFS status" and "service rpcbind status" commands to check whether the two services have been started. If the two services are not installed in the system, install them first.

2. Modify the NFS shared configuration file:/etc/exports
# File path/usr/local/apache-activemq-5.7.0/data/kahadb 192.168.102.90 (RW, no_root_squash)

/Usr/local/apache-activemq-5.7.0/data/kahadb is the folder to be shared: 192.168.102.90 is the address that can access the folder (wildcard * is supported, such as can be configured as 192.168.102. *); RW indicates that read/write operations are supported; no_root_squash indicates that the client maps to the local nobody user when accessing the database as root. this parameter is very important and must be specified, otherwise, an error indicating no access permission may be reported.

3. Disable the firewall (Service iptables stop) or enable the relevant port (you can use rpcinfo-P 192.168.102.91 to view the port number to be enabled ).

4. Restart the NFS service and rpcbind service.

Configuration on 90:

1. The configuration is the same as that of 1 on 91.

2. Create a directory/data/activemq

3. modify the configuration file CONF/activemq. xml of activemq
<span style="white-space:pre"></span><persistenceAdapter>            <kahaDB directory="/${activemq.data}/kahadb"/>        </persistenceAdapter>
To:
  <span style="white-space:pre"></span><persistenceAdapter>            <kahaDB directory="/data/activemq"/>        </persistenceAdapter>   

Change the data file storage directory of activemq to the directory created in Step 1:/data/activemq.

4. Check the file system that can be mounted: the showmount-e 192.168.102.91 system will list the files that can be mounted.
Export list for 192.168.102.91:/usr/local/apache-activemq-5.7.0/data/kahadb 192.168.102.90

5. mount a File System
mount -t nfs 192.168.102.91:/usr/local/apache-activemq-5.7.0/data/kahadb /data/activemq
This command mounts the/usr/local/apache-activemq-5.7.0/data/kahadb directory on 91 to the local directory/data/activemq. 

Of course, the directory is automatically mounted to avoid manual mounting after the system is restarted. Automatically mount the configuration file/etc/fstab

In this way, the master-slave configuration is complete.
In the code, modify brokerurl: failover: // (TCP: // 192.168.102.90: 61616, TCP: // 192.168.102.91: 61616) and enable the reconnection mechanism.

In this way, when activemq of 90 is killed, the system automatically connects to 91. If you want to connect to the 90 s after the 90 s, kill activemq of 91.

Note:

1. The master-slave configuration of shared files is implemented through the file share lock. The service that gets the filelock first is the master, and the other is the slave service. By default, the slave Service tries to get the filelock every 10 seconds. You can view the activemq console.

2. Only the master Console (such as http: // 192.168.102.91: 8161/admin) can access the server Load balancer console. The reason is that the Server Load balancer does not get the file lock and cannot access the file.


Activemq file sharing-based Master/Slave configuration Scheme

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.