ZOOKEEPER+ACTIVEMQ High Availability

Source: Internet
Author: User
Tags zookeeper

1, high availability of data in several ways

①shared Nothing master/slave
    Master and Slave each individually store persistent messages that do not share data.

②shared Database Master/slave
    The data between master and slave is shared.

③shared File System Master/slave
    This approach is essentially the same as the shared database storage principle.

④replicated leveldb Store
    This way uses zookeeper to elect master. To conduct an election, a majority of "participants" are required. Because there are multiple broker in the replicated LEVELDB store, a master is elected from multiple broker, and others become slave. Only master receives the client's connection, slave is responsible for connecting to master, and receives (synchronously, asynchronously) data on master.

2. Practical operation (Ubuntu 12.04)
(1) Choose 3 machines, should be greater than or equal to 3 units, involving the use of replicated LEVELDB store this way, needs to carry out the election needs.
(2) Download zookeeper installation

wget http://mirror.bit.edu.cn/apache/zookeeper/zookeeper-3.3.6/zookeeper-3.3.6.tar.gz
and then unzip:
     TAR-XVF  zookeeper-3.3.6.tar.gz-c/opt/amqbroker (path to be unzipped)
Modify Profile:
          zoo_sample.cfg Modify file name Zoo.cfg
Modify the Zoo.cfg configuration file content to
ticktime=2000
initlimit=10
synclimit=5
datadir=/opt/amqbroker/zookeeper/data
datalogdir=/opt/ Amqbroker/zookeeper/log
clientport=2181
server.one=192.168.0.100:2888:3888
server.two= 192.168.0.101:2888:3888
server.three=192.168.0.102:2888:3888

Then create the myID file in the/opt/amqbroker/zookeeper/data directory, write the ID of the current machine in the file, such as server.one=192.168.0.100:2888:3888 in the configuration, write characters in myID file One to save the exit.
Another 2 machines, like the configuration of this machine, myID write the ID name of the respective server.

3. Download Activemq and configure

(1) Download address: wget  http://archive.apache.org/dist/activemq/5.10.1/apache-activemq-5.10.1-bin.tar.gz

(2) decompression  tar-xvf apache-activemq-5.10.1-bin.tar.gz

(3) Modify configuration file (/opt/amqbroker/apache-activemq-5.10.1/conf) 
<persistenceAdapter>
   <!--   <kahadb directory= "${activemq.data}/kahadb"/>-->
    < Replicatedleveldb directory= "${activemq.data}/leveldb"    replicas= "3" bind= "tcp://0.0.0.0:0" "zkAddress=" 192.168.0.100:2181,192.168.0.101:2181,192.168.0.102:2181 "Hostname=" 42.123.81.111 "zkpath="/activemq/ Leveldb-stores "/>
</persistenceAdapter>
Start ACTIVEMQ Server (switch path is/opt/amqbroker/apache-activemq-5.10.1/bin directory):
run the following command:
./activemq start 

The other 2 servers are configured again, note that in the MQ configuration, hostname is the IP address of the respective server.
3 servers start at once.

Vi/opt/amqbroker/apache-activemq-5.10.1/conf/jetty.xml

<bean id= "Jettyport" class= "Org.apache.activemq.web.WebConsolePort" init-method= "Start" >
 <!--the Default port number for the Web console-->
        <property name= "host" value= "0.0.0.0"/> <property name=
        "Port" value= "8161"/>
</bean>

Jetty Default port is 8161

Finally, open 3 Web page addresses in the browser:

http://192.168.0.100:8161/admin/queues.jsp
http://192.168.0.101:8161/admin/queues.jsp
http:// 192.168.0.102:8161/admin/queues.jsp

If a page can open ACTIVEMQ interface, this server is master server, others are slave (standby server)

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.