Activemq+zookeeper High-availability cluster __apache

Source: Internet
Author: User
Tags zookeeper

First, activemq the main categories of deployment comparison 1, the default stand-alone deployment (KAHADB) 2, based on zookeeper master-slave (Leveldb master/slave) 3, based on shared database of Master and slave (shared JDBC master/ Slave) Second, server description III, data preparation IV, ACTIVEMQ configuration upload to the specified location decompression modify Brokername value comment out the default persistenceadapter add new Leveldb week02, week03 configuration changes Five , start six, view log seven, login ACTIVEMQ Web page

first, activemq the main types of deployment methods comparison 1, the default stand-alone deployment (KAHADB)

The ACTIVEMQ default storage is stored as a local kahadb file, so performance metrics are entirely dependent on local disk IO and cannot provide high availability. 2, based on the Zookeeper master (leveldb Master/slave)

Starting from apache-activemq-5.9.0, the new master-slave implementation, based on zookeeper to elect a master, the other nodes automatically as slave real-time synchronization messages.

Because of the presence of slave with real-time synchronization data, master does not have to worry about data loss, so LEVELDB takes a memory store message and asynchronously synchronizes it to disk. So the ACTIVEMQ read and write performance of this method is the best, especially the write performance can be comparable to the non-persistent message.

Advantages: High availability and good data security

disadvantage: because more than half of the election mechanism, so the minimum need for 3 nodes, in order to achieve high availability. 3, based on shared database of Master and slave (shared JDBC master/slave)

Can be based on Postgres, MySQL, Oracle and other common databases.
Each node starts with a scramble for database locks, which guarantees the uniqueness of master, and other nodes as backups, waiting for database locks to be released.
Because all of the message read and write, is actually database operations, the ACTIVEMQ node itself is very small pressure, performance depends entirely on database performance.

Advantages: Achieve high availability and data security simple and flexible, 2 nodes can achieve high availability

disadvantage: stability relies on database performance dependency database

here is the Activemq+zookeeper cluster integration

Zookeeper in the Linux cluster build, please refer to: http://blog.csdn.net/xiaojin21cen/article/details/79056578 II, server description

There are 3 servers, the server's operating system is centos6.4, and other information is as follows:

Service Name Server 1 Server 2 Server 3
IP Address 192.168.4.101 192.168.4.102 192.168.4.103
Host Name Week01 Week02 Week03
III. Data Preparation

Use ACTIVEMQ Download Address: HTTPS://MIRRORS.CNNIC.CN/APACHE/ACTIVEMQ (Tsinghua University Mirror)
Select the apache-activemq-5.14.5-bin.tar.gz IV, ACTIVEMQ configuration upload to the specified location

/my_soft
Decompression

The following is the modification of the contents of the Activemq.xml modify Brokername value

Modify

Brokername= "Activemq-cluster"
comment out the default persistenceadapter
<!--
    <persistenceAdapter>
        <kahadb directory= "${activemq.data}/kahadb"/>
    </ Persistenceadapter>
 
Add a new leveldb

WEEK01:

<persistenceAdapter>
    <replicatedleveldb 
        directory= "${activemq.data}/leveldb" 
        replicas= "3"   
        bind= "tcp://0.0.0.0:0"
        zkaddress= "192.168.4.101:2181,192.168.4.102:2181,192.168.4.103:2181"
        Hostname= "week01"
        sync= "Local_disk" zkpath= "/activemq/leveldb-stores"
    />
Directory: path to store data replicas: Number of nodes in a cluster [(REPLICAS/2) +1 formula indicates the number of services in the cluster that are at least functioning], that is, 3 clusters that guarantee two to run properly bind: This node becomes master, It binds the configured addresses and ports to perform the IP and port hostname of the master-slave Replication protocol Zkaddress:zookeeper: Host name or IP zkpath:zookeeper the storage path of election information interchange

There are also configuration items: zkpassword= "password" The password to use when connecting to the zookeeper server. configuration modifications for week02, week03

Upload the configured activemq remotely to week02, week03 server

Scp-r/my_soft/apache-activemq-5.14.5  root@week02:/my_soft/
scp-r/my_soft/apache-activemq-5.14.5  root@week03:/my_soft/

Upload completed, only need to modify the contents of the above changes in the hostname, respectively, to Hostname= "week02", hostname= "week03" can be. v. Launch

Under the/my_soft/apache-activemq-5.14.5/bin directory, execute the start command:

[Root@week01 bin]#./activemq start

WEEK02, week03 Use the same command to start the service.

activemq Command Description:
./activemq Start ACTIVEMQ
./activemq Stop Stop Activemq Six, view log

The default log storage directory is/apache-activemq-5.14.5/data/activemq.log

To view Log commands:

TAIL-500F Activemq.log

Seven, Login activemq Web page

In the browser address bar, enter:

http://192.168.4.101:8161/admin/
http://192.168.4.102:8161/admin/
http://192.168.4.103:8161/admin/

Because using zookeeper to do load balancing, three only one is master, the other two are in the waiting state, so only one of the services, but once the server down, there will be another replacement, so several other IP address is not open, only one can open.

The

kills the currently accessible ACTIVEMQ process, and one of the remaining two becomes master, which can be accessed.

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.