dickrong 发表于 2019-1-8 09:15:17

activemq+zookeeper 集群部署基于levedb


[*]  集群图
http://s1.运维网.com/wyfs02/M02/8C/44/wKiom1hnIKPgGLvxAAEkCutmIdM854.png-wh_500x0-wm_3-wmp_4-s_4170447191.png
[*]  zookeeper集群,上一篇博客写了zookeeper集群的部署
Ip服务注册端口
主机名
192.168.56.152181zk01
192.168.56.16
2181zk02
192.168.56.17
2181zk03

[*]  activemq部署
  

IP管控台端口集群通讯端口消息端口192.168.56.15
81616162151511192.168.56.16
816261622
51512192.168.56.17
81636162351513
[*]  host解析必须做
# cat /etc/hosts
192.168.56.15 zk01
192.168.56.16 zk02
192.168.56.17 zk03  5.
  5.1 zookeeper 集群不在配置,参看前面博客
  5.2 activemq 安装包
说明:zk03 是zookeeper的 activemq03 是activemq的 jdk 是java环境 redis不用管
三台机器全部部署
# pwd
/opt
# ll
total 12
lrwxrwxrwx1 root root    21 Dec 31 18:20 activemq03 -> apache-activemq-5.9.0
drwxr-xr-x 10501 games 4096 Oct 152013 apache-activemq-5.9.0
lrwxrwxrwx1 root root    11 Dec 25 01:27 jdk -> jdk1.7.0_80
drwxr-xr-x8   10   143 4096 Apr 112015 jdk1.7.0_80
lrwxrwxrwx1 root root    11 Dec 25 19:35 redis -> redis-3.0.6
drwxr-xr-x4 root root    27 Dec 25 19:38 redis-3.0.6
drwxr-xr-x2 root root   125 Dec 31 18:20 tools
lrwxrwxrwx1 root root    15 Dec 25 01:29 zk03 -> zookeeper-3.4.9
drwxr-xr-x 12 10011001 4096 Dec 25 01:48 zookeeper-3.4.9
#  5.3 修改所有activemq管控台的端口
只需要该118行的端口
# pwd
/opt/activemq01/conf
# grep 8161 jetty.xml
118:      
# grep -n8161 jetty.xml
118:      
#
# grep -n 8162jetty.xml
118:      
135:                      #默认注释的端口 不用管
#
# grep -n8163 jetty.xml
118:      
#  5.4 修改broker的名称
vi activemq.xml
只需要修改brokerName="dubboedu"   默认是localhost
三台改成一样的
  5.5 修改集群通讯的端口以及leveldb存储模式
vim activemq.xml文件中中的内容
zk01:
      
            
      
zk02:
      
                  
      
zk03:
         
               
        

  5.6 修改消息端口
activemq.xml配置文件
zk01
# grep-n51511 activemq.xml
120:            
#
zk02
# grep-n 51512 activemq.xml
120:            
#
zk03
# grep -n51513 activemq.xml
120:              6.启动activemq

zookeeper一定要提前启动
顺序启动activemq
# /opt/activemq01/bin/activemq start
INFO: 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/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 details
INFO: pidfile created : '/opt/activemq01/data/activemq-zk01.pid' (pid '4541')

# /opt/activemq02/bin/activemq start
INFO: 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 details
INFO: pidfile created : '/opt/activemq02/data/activemq-zk02.pid' (pid '4492')
#

# /opt/activemq03/bin/activemq start
INFO: 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/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 details
INFO: pidfile created : '/opt/activemq03/data/activemq-zk03.pid' (pid '2296')  7.查看分片以及zookeeper的信息
登录任意一台zookeeper就行
# pwd
/opt/zk02/bin
# ./zkCli.sh   -server 192.168.56.16:2181
ls/

ls /activemq

ls /activemq/leveldb-stores


elected值不为空的是消息activemq的master节点
get /activemq/leveldb-stores/00000000002
{"id":"dubboedu","container":null,"address":null,"position":-1,"weight":1,"elected":null}
cZxid = 0x400000012
ctime = Sat Dec 31 19:33:44 CST 2016
mZxid = 0x400000012
mtime = Sat Dec 31 19:33:44 CST 2016
pZxid = 0x400000012
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x259544b516a0000
dataLength = 89
numChildren = 0
get /activemq/leveldb-stores/00000000001
{"id":"dubboedu","container":null,"address":null,"position":-1,"weight":1,"elected":null}
cZxid = 0x400000008
ctime = Sat Dec 31 19:33:16 CST 2016
mZxid = 0x400000015
mtime = Sat Dec 31 19:33:45 CST 2016
pZxid = 0x400000008
cversion = 0
dataVersion = 8
aclVersion = 0
ephemeralOwner = 0x359544bcfbb0001
dataLength = 89
numChildren = 0
get /activemq/leveldb-stores/00000000000
{"id":"dubboedu","container":null,"address":"tcp://zk01:62621","position":-1,"weight":1,"elected":"0000000000"}
cZxid = 0x400000005
ctime = Sat Dec 31 19:32:51 CST 2016
mZxid = 0x40000000d
mtime = Sat Dec 31 19:33:17 CST 2016
pZxid = 0x400000005
cversion = 0
dataVersion = 4
aclVersion = 0
ephemeralOwner = 0x359544bcfbb0000
dataLength = 111
numChildren = 0
  8 测试高可用activemq

  8.1 正产三个节点:
ls /activemq/leveldb-stores

  8.2 此时activemq02处于主节点,停掉主节点
停掉主节点activemq:
# ./activemq stop
查看消息队列的信息,可以看出重新选出来主节点
ls /activemq/leveldb-stores

ls /activemq/leveldb-stores/00000000002
[]
get /activemq/leveldb-stores/00000000002
{"id":"dubboedu","container":null,"address":null,"position":-1,"weight":1,"elected":null}
cZxid = 0x400000012
ctime = Sat Dec 31 19:33:44 CST 2016
mZxid = 0x400000012
mtime = Sat Dec 31 19:33:44 CST 2016
pZxid = 0x400000012
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x259544b516a0000
dataLength = 89
numChildren = 0
get /activemq/leveldb-stores/00000000000
{"id":"dubboedu","container":null,"address":"tcp://zk01:62621","position":-1,"weight":1,"elected":"0000000000"}
cZxid = 0x400000005
ctime = Sat Dec 31 19:32:51 CST 2016
mZxid = 0x40000000d
mtime = Sat Dec 31 19:33:17 CST 2016
pZxid = 0x400000005
cversion = 0
dataVersion = 4
aclVersion = 0
ephemeralOwner = 0x359544bcfbb0000  8.3 启动activemq02
# ./activemq start
查看消息队列的信息
ls /activemq/leveldb-stores            
               #重新加进来
  8.5java代码链接activemq
  javaconf 消息队列的配置文件
failover:(tcp://192.168.56.15:51511,tcp://192.168.56.16:51512.tcp://192.168.56.17:51513)?random=false
mq.username=admin
my.password=admin      #这是消息队列的用户名和密码 生产场景自己修改
mq.pool.maxConnection=10
queueName=队列的名称  9.开机自动启动不要忘了做了!!
  




页: [1]
查看完整版本: activemq+zookeeper 集群部署基于levedb