Activemq+zookeeper cluster deployment based on Levedb

Source: Internet
Author: User
Tags zookeeper log4j

  1. Cluster diagram

    650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M02/8C/44/wKiom1hnIKPgGLvxAAEkCutmIdM854.png-wh_500x0-wm_3 -wmp_4-s_4170447191.png "title=" 1.png "alt=" Wkiom1hnikpgglvxaaekcutmidm854.png-wh_50 "/>

  2. Zookeeper cluster, the previous blog wrote the deployment of the zookeeper cluster

    zk01
    TD width= "153" valign= "top" > /tr>
    ip service registration port
    hostname
    td>
    192.168.56.15 2181
    192.168.56.16
    2181 zk02
    192.168.56.17
    2181 zk03
  3. ACTIVEMQ deployment


    Ip Control console Port Cluster communication port Message Port
    192.168.56.15
    8161 61621 51511
    192.168.56.16
    8162 61622
    51512
    192.168.56.17
    8163 61623 51513
  4. Host parsing must be done

[Email protected] conf]# cat/etc/hosts192.168.56.15 zk01192.168.56.16 zk02192.168.56.17 zk03

5.

5.1 Zookeeper cluster is not configured, see previous blog

5.2 Activemq Installation Package

  Description:zk03  is zookeeper  activemq03  is ACTIVEMQ  jdk  is the Java environment  redis no tube   All three machines are deployed  [[email protected] opt]# pwd/opt[[email protected] opt]# lltotal  12lrwxrwxrwx  1 root root    21 dec 31 18:20  activemq03 -> apache-activemq-5.9.0drwxr-xr-x 10  501 games 4096  Oct 15  2013 apache-activemq-5.9.0lrwxrwxrwx  1 root root     11 dec 25 01:27 jdk -> jdk1.7.0_80drwxr-xr-x  8    10   143 4096 apr 11  2015 jdk1.7.0_ 80lrwxrwxrwx  1 root root    11 dec 25 19:35 redis  -> redis-3.0.6drwxr-xr-x  4 root root    27 dec  25 19:38 redis-3.0.6drwxr-xR-x  2 root root   125 dec 31 18:20 toolslrwxrwxrwx   1 root root    15 Dec 25 01:29 zk03 ->  zookeeper-3.4.9drwxr-xr-x 12 1001  1001 4096 Dec 25 01:48  zookeeper-3.4.9[[email protected] opt]#

 5.3 Modify ports for all ACTIVEMQ consoles

Only the 118-row port is required [[email protected] conf]# pwd/opt/activemq01/conf[[email protected] conf]#  grep 8161 jetty.xml  118:      <property name= "Port"  value= "8161"/>[[email protected] conf]# grep -n  8161  Jetty.xml 118:        <property name= "Port"  value= " 8161 "/>[[email protected] conf]# [[email protected] conf]# grep -n  8162  jetty.xml 118:        <property name= " Port " value=" 8162 "/>135:                     <property name= "Port"  value= "8162"  />    #默认注释的端口   No tube [[Email protected] conf]# [[email protected] conf]# grep  -n  8163&Nbsp;jetty.xml 118:        <property name= "Port"   Value= "8163"/>[[email protected] conf]#

5.4 Modifying the name of the broker

VI Activemq.xml only need to modify Brokername= "dubboedu" default is localhost three changed to the same <broker xmlns= "http://activemq.apache.org/schema/ Core "brokername=" dubboedu "datadirectory=" ${activemq.data} ">

5.5 Modifying the port of the cluster communication and the LEVELDB storage mode

Content in <persistenceAdapter> in the  vim activemq.xml file   zk01:         <persistenceAdapter>               <replicatedLevelDB                   directory= "${activemq.data}/leveldb"    # Based on LEVELDB data storage path                    replicas= "3"     #复制的分片的个数   here are three                    bind= "tcp://0.0.0.0:62621"     #集群通讯的端口                    zkaddress= "192.168.56.51:2181,192.168.56.16:2181,192.168.56.17:2181"                    hostname= "Zk01"    #主机名                    zkpath= "/activemq/leveldb-stores"  # Path                 /in Zookeeper >        </persistenceAdapter>  zk02:       <persistenceAdapter>                   <replicatedLevelDB                          directory= "${activemq.data}/leveldb"                          replicas= "3"          &nbsP;               bind= "tcp:// 0.0.0.0:62622 "                         zkaddress= " 192.168.56.51:2181,192.168.56.16:2181,192.168.56.17:2181 "                         hostname= "zk02 "                         zkpath= "/activemq/leveldb-stores"                        />         </persistenceAdapter>           zk03:           <persistenceadapter>                 <replicatedLevelDB                   directory= "${activemq.data}/leveldb"                    replicas= "3"                    bind= "tcp:// 0.0.0.0:62623 "                   zkaddress= "192.168.56.51:2181,192.168.56.16:2181,192.168.56.17:2181"                    hostname= "Zk03"                    zkpath= "/ Activemq/leveldb-stores "/>        </persistenceadapter> 


5.6 Modifying the message port

  activemq.xml configuration file  zk01   [[email protected] conf]# grep   -n  51511 activemq.xml 120:             <transportconnector name= "Openwire"  uri= "tcp://0.0.0.0:51511?maximumconnections =1000&amp;wireformat.maxframesize=104857600 "/>[[email protected] conf]#   zk02     [[email protected] conf]# grep  -n 51512  activemq.xml 120:            < Transportconnector name= "Openwire"  uri= "tcp://0.0.0.0:51512?maximumconnections=1000&amp; wireformat.maxframesize=104857600 "/>[[email protected] conf]#  zk03  [[email  protected] conf]# grep -n  51513 activemq.xml 120:             <transportconnector name= "Openwire"  uri= "tcp://0.0.0.0:51513?maximumconnections=1000& amp;wireformat.maxframesize=104857600 "/>

6. Start Activemq

Zookeeper be sure to start the sequence start in advance Activemq[[email protected] bin]# /opt/activemq01/bin/activemq start  info: using default configuration (you can configure options in  ONE&NBSP;OF&NBSP;THESE&NBSP;FILE:&NBSP;/ETC/DEFAULT/ACTIVEMQ&NBSP;/ROOT/.ACTIVEMQRC) INFO: Invoke the  following command to create a configuration file/opt/activemq01/bin/ Activemq setup [ /etc/default/activemq | /root/.activemqrc ]info: using  java  '/opt/jdk/bin/java ' info: starting - inspect logfiles specified  In logging.properties and log4j.properties to get detailsinfo: pidfile  created :  '/opt/activemq01/data/activemq-zk01.pid '   (pid  ' 4541 ') [[email  protected] conf]# /opt/activemq02/bin/activemq startinfo: using default  Configuration (you can configure  options in one of these file: /etc/default/activemq /root/.activemqrc) INFO :  invoke the following command to create a configuration file/opt /activemq02/bin/activemq setup [ /etc/default/activemq | /root/.activemqrc ]info : using java  '/opt/jdk/bin/java ' info: starting - inspect logfiles  Specified in logging.properties and log4j.properties to get detailsinfo:  pidfile created :  '/opt/activemq02/data/activemq-zk02.pid '   (pid  ' 4492 ') [email  protected] conf]# [[email protected] conf]# /opt/activemq03/bin/activemq  Startinfo: using default configuration (you can configure options in  ONE&NBSP;OF&NBSP;THESE&NBSP;FILE:&NBSP;/ETC/DEFAULT/ACTIVEMQ&NBSP;/ROOT/.ACTIVEMQRC) INFO: Invoke the  following command to create a configuration file/opt/activemq03/bin/activemq setup [  /etc/default/activemq | /root/.activemqrc ]INFO: Using java  '/opt/jdk/bin/ Java ' info: starting - inspect logfiles specified in logging.properties  and log4j.properties to get detailsINFO: pidfile created :  '/opt /activemq03/data/activemq-zk03.pid '   (pid  ' 2296 ')

7. View information on shards and zookeeper

Log on to any zookeeper on the line [[email protected] bin]# pwd/opt/zk02/bin[[email protected] bin]#  ./zkcli.sh   -server 192.168.56.16:2181[zk: 192.168.56.16:2181 (CONNECTED)   0] ls  /[activemq, dubbo, zookeeper][zk: 192.168.56.16:2181 (CONNECTED)  1]  ls /activemq[leveldb-stores][zk: 192.168.56.16:2181 (CONNECTED)  2] ls /activemq/ leveldb-stores[00000000002, 00000000001, 00000000000][zk: 192.168.56.16:2181 (CONNECTED)  3]  elected value is not empty is the master node of message activemq [zk: 192.168.56.16:2181 (CONNECTED)  3] get /activemq/ leveldb-stores/00000000002{"id": "dubboedu", "container": null, "address": null, "position":-1, "Weight": 1, "elected": Null}czxid = 0x400000012ctime = sat dec 31 19:33:44 cst 2016mzxid  = 0x400000012mtime = sat dec 31 19:33:44 cst 2016pzxid =  0x400000012cversion = 0dataversion = 0aclversion = 0ephemeralowner =  0x259544b516a0000datalength = 89numchildren = 0[zk: 192.168.56.16:2181 (CONNECTED)  4] get /activemq/leveldb-stores/00000000001{"id": "dubboedu", "container": null, "address": null, " Position ":-1," Weight ": 1," elected ": null}czxid = 0x400000008ctime = sat dec 31  19:33:16 CST 2016mZxid = 0x400000015mtime = Sat Dec 31  19:33:45 cst 2016pzxid = 0x400000008cversion = 0dataversion =  8aclversion = 0ephemeralowner = 0x359544bcfbb0001datalength = 89numchildren  = 0[zk: 192.168.56.16:2181 (CONNECTED)  5] get /activemq/leveldb-stores/ 00000000000{"id": "dubboedu", "container": null, "Address": "tcp://zk01:62621", "position":-1, "Weight": 1, "elected": " 0000000000 "}czxid = 0x400000005ctime =  sat dec 31 19:32:51 cst 2016mzxid = 0x40000000dmtime = sat  Dec 31 19:33:17 cst 2016pzxid = 0x400000005cversion = 0dataversion  = 4aclVersion = 0ephemeralOwner = 0x359544bcfbb0000dataLength =  111numchildren = 0[zk: 192.168.56.16:2181 (CONNECTED)  6]

8 Testing high-availability ACTIVEMQ

8.1 Positive production three nodes:

[Zk:192.168.56.16:2181 (CONNECTED) 3] ls/activemq/leveldb-stores[00000000002, 00000000001, 00000000000][zk: 192.168.56.16:2181 (CONNECTED) 4]

8.2 At this point the activemq02 is in the master node and the master node is deactivated

To stop the master node activemq:[[email protected] bin]# ./activemq stop  view Message Queuing information, you can see the re-elected to the master node [ZK:  192.168.56.16:2181 (CONNECTED)  4] ls /activemq/leveldb-stores[00000000002,  00000000000][zk: 192.168.56.16:2181 (CONNECTED)  5] ls /activemq/leveldb-stores/00000000002[ ][zk: 192.168.56.16:2181 (CONNECTED)  6] get /activemq/leveldb-stores/00000000002{"id": " Dubboedu "," container ": null," address ": null," position ":-1," Weight ": 1," elected ":null}czxid =  0x400000012ctime = sat dec 31 19:33:44 cst 2016mzxid =  0x400000012mtime = sat dec 31 19:33:44 cst 2016pzxid =  0x400000012cversion = 0dataversion = 0aclversion = 0ephemeralowner =  0x259544b516a0000datalength = 89numchildren = 0[zk: 192.168.56.16:2181 (CONNECTED)  7] get /activemq/leveldb-stores/00000000000{"id":" dubboedu "," container ": null," Address ":" tcp://zk01:62621 "," position ":-1," Weight ": 1," elected ":" 0000000000 "} Czxid = 0x400000005ctime = sat dec 31 19:32:51 cst 2016mzxid  = 0x40000000dmtime = sat dec 31 19:33:17 cst 2016pzxid =  0x400000005cversion = 0dataversion = 4aclversion = 0ephemeralowner =  0x359544bcfbb0000

8.3 Start activemq02

[[email protected] bin]#./activemq start View Message Queuing information [zk:192.168.56.16:2181 (CONNECTED) 8] Ls/activemq/leveldb-stores [00000000003, 00000000002, 00000000000] #重新加进来 [zk:192.168.56.16:2181 (CONNECTED) 9]

8.5java Code Link ACTIVEMQ

Java conf configuration file for Message Queuing

Failover: (tcp://192.168.56.15:51511,tcp://192.168.56.16:51512.tcp://192.168.56.17:51513)? random= Falsemq.username=adminmy.password=admin #这是消息队列的用户名和密码 Production Scenarios Modify the name of the mq.pool.maxconnection=10queuename= queue yourself

9. Boot Auto start don't forget to do it!!


This article is from the "Brick Blog" blog, please be sure to keep this source http://wsxxsl.blog.51cto.com/9085838/1887846

Activemq+zookeeper cluster deployment based on Levedb

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.