RocketMQ 目前有两个版本  alibaba版本和apache版本

一、alibaba版本

tomcat部署:

  apache-tomcat-7.0.90.tar.gz

  jdk7

  虚拟机redhat6.5:192.168.1.201

1、上传rocketmq-console.war包到tomcat下webapps

  1. #新建目录
  2. mkdir rocketmq-console
  3. #解压war文件
  4. unzip rocketmq-console.war -d rocketmq-console
  5. #删除war
  6. rm -f rocketmq-console.war

2、修改配置  指定nameserveraddr

  1. cd /usr/local/tomcat7/webapps/rocketmq-console/WEB-INF/classes
  2.  
  3. vim config.properties
  4.  
  5. rocketmq.namesrv.addr=192.168.1.201:;192.168.1.202:
  6. throwDone=true

3、启动tomcat

  1. [root@ bin]# /usr/local/tomcat7/bin/startup.sh
  2. Using CATALINA_BASE: /usr/local/tomcat7
  3. Using CATALINA_HOME: /usr/local/tomcat7
  4. Using CATALINA_TMPDIR: /usr/local/tomcat7/temp
  5. Using JRE_HOME: /usr/local/java/jdk1..0_80
  6. Using CLASSPATH: /usr/local/tomcat7/bin/bootstrap.jar:/usr/local/tomcat7/bin/tomcat-juli.jar
  7. Tomcat started.
  8. [root@ bin]# jps
  9. Jps
  10. NamesrvStartup
  11. Bootstrap
  12. BrokerStartup

4、浏览器访问

http://192.168.1.201:8080/rocketmq-console

  1. /**
  2. * Copyright (C) 2010-2013 Alibaba Group Holding Limited
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package rocketmq.quickstart;
  17.  
  18. import com.alibaba.rocketmq.client.exception.MQClientException;
  19. import com.alibaba.rocketmq.client.producer.DefaultMQProducer;
  20. import com.alibaba.rocketmq.client.producer.SendResult;
  21. import com.alibaba.rocketmq.common.message.Message;
  22.  
  23. /**
  24. * Producer,发送消息
  25. *
  26. */
  27. public class Producer
  28. {
  29. public static void main(String[] args) throws MQClientException,
  30. InterruptedException
  31. {
  32. DefaultMQProducer producer = new DefaultMQProducer("QuickStart_Producer");
  33. producer.setNamesrvAddr("192.168.1.201:9876;192.168.1.202:9876");
  34. producer.start();
  35.  
  36. for (int i = 0; i < 1000; i++)
  37. {
  38. try
  39. {
  40. Message msg = new Message("TopicQuickStart",// topic
  41. "TagA",// tag
  42. ("Hello RocketMQ " + i).getBytes()// body
  43. );
  44. SendResult sendResult = producer.send(msg);
  45. System.out.println(sendResult);
  46. } catch (Exception e) {
  47. e.printStackTrace();
  48. Thread.sleep(1000);
  49. }
  50. }
  51.  
  52. producer.shutdown();
  53. }
  54. }
  1. /**
  2. * Copyright (C) 2010-2013 Alibaba Group Holding Limited
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package rocketmq.quickstart;
  17.  
  18. import java.io.UnsupportedEncodingException;
  19. import java.util.List;
  20.  
  21. import com.alibaba.rocketmq.client.consumer.DefaultMQPushConsumer;
  22. import com.alibaba.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
  23. import com.alibaba.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
  24. import com.alibaba.rocketmq.client.consumer.listener.MessageListenerConcurrently;
  25. import com.alibaba.rocketmq.client.exception.MQClientException;
  26. import com.alibaba.rocketmq.common.consumer.ConsumeFromWhere;
  27. import com.alibaba.rocketmq.common.message.MessageExt;
  28.  
  29. /**
  30. * Consumer,订阅消息
  31. */
  32. public class Consumer {
  33.  
  34. public static void main(String[] args) throws InterruptedException,
  35. MQClientException
  36. {
  37. DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("QuickStart_Consumer");
  38. consumer.setNamesrvAddr("192.168.1.201:9876;192.168.1.202:9876");
  39. /**
  40. * 设置Consumer第一次启动是从队列头部开始消费还是队列尾部开始消费<br>
  41. * 如果非第一次启动,那么按照上次消费的位置继续消费
  42. */
  43. consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET);
  44.  
  45. consumer.subscribe("TopicQuickStart", "*");
  46.  
  47. consumer.registerMessageListener(new MessageListenerConcurrently() {
  48.  
  49. @Override
  50. public ConsumeConcurrentlyStatus consumeMessage(
  51. List<MessageExt> msgs, ConsumeConcurrentlyContext context) {
  52. try {
  53. for (int i = 0; i < msgs.size(); i++) {
  54. MessageExt msg = msgs.get(i);
  55. String topic = msg.getTopic();
  56. String tag = msg.getTags();
  57. String body = new String(msg.getBody(), "UTF-8");
  58. System.out.println(Thread.currentThread().getName()
  59. + " Receive New Messages: topic="
  60. + topic+",tag="
  61. + tag +",body="
  62. + body);
  63.  
  64. }
  65. } catch (UnsupportedEncodingException e) {
  66. e.printStackTrace();
  67. return ConsumeConcurrentlyStatus.RECONSUME_LATER;
  68. }
  69. return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
  70. }
  71. });
  72.  
  73. consumer.start();
  74.  
  75. System.out.println("Consumer Started.");
  76. }
  77. }

生产消息:

消费消息:

监控消息:

二、apache版本

贡献给apache之后,上面的那个工具就无法使用了,不过今天从网上找到了个新的管理界面。

github地址:https://github.com/apache/incubator-rocketmq-externals

2018年1月23日,更新最新github地址为:https://github.com/apache/rocketmq-externals

参照帮助文件使用即可:

帮助文档路径:https://github.com/apache/incubator-rocketmq-externals/blob/master/rocketmq-console/README.md

具体如下:

1、修改配置文件,使管理界面与rocketmq集群产生关联。

incubator-rocketmq-externals-master/rocketmq-console/src/main/resources/application.properties

修改内容及修改结果如下图所示:

2、编译rocketmq-console

编译命令:mvn clean package -Dmaven.test.skip=true(注意:不要直接使用mvn package,会提示很多错误)

3、将编译好的jar包上传到linux服务器

(如果直接在Linux环境上编译,可以省略这步)

我这里上传到了本地虚拟机192.168.6.5上。路径为:/home/hadmin/jar

4、运行jar包

命令:java -jar target/rocketmq-console-ng-1.0.0.jar

5、使用浏览器访问管理界面

方位地址:http://192.168.6.5:8080/

6、可能遇到的问题

画面可以正常启动,不过从控制台的监控日志上看,存在如下的错误日志。

org.apache.rocketmq.remoting.exception.RemotingTimeoutException: wait response on the channel <192.168.1.80:10918> timeout, 5000(ms)

原因是isVIPChannel默认为true,会监控rocketmq的vip通道,将该属性设置为false即可。

设置后的配置文件如下所示:

  1. server.contextPath=
  2. server.port=8080
  3. #spring.application.index=true
  4. spring.application.name=rocketmq-console
  5. spring.http.encoding.charset=UTF-8
  6. spring.http.encoding.enabled=true
  7. spring.http.encoding.force=true
  8. logging.config=classpath:logback.xml
  9. #if this value is empty,use env value rocketmq.config.namesrvAddr NAMESRV_ADDR | now, you can set it in ops page.default localhost:9876
  10. rocketmq.config.namesrvAddr=192.168.1.80:9876;192.168.1.81:9876
  11. #if you use rocketmq version < 3.5.8, rocketmq.config.isVIPChannel should be false.default true
  12. rocketmq.config.isVIPChannel=false
  13. #rocketmq-console's data path:dashboard/monitor
  14. rocketmq.config.dataPath=/home/hadmin/data/rocketmq
  15. #set it false if you don't want use dashboard.default true
  16. rocketmq.config.enableDashBoardCollect=true

参考:https://www.cnblogs.com/quchunhui/p/7284752.html

RocketMQ 集群监控以及Hello World的更多相关文章

  1. RocketMQ集群部署记录

    RocketMQ集群部署记录 #引用    https://cloud.tencent.com/developer/article/1147765         一.RocketMQ基础知识介绍 A ...

  2. CentOS7.4上搭建rocketMQ集群

    一.rocketMQ集群部署方案优缺点对比: 多Master模式(2m-noslave) : 一个集群无Slave,全是Master,例如2个Master或者3个Master 优点:配置简单,单个Ma ...

  3. RocketMQ集群搭建(3m-3s-async)

    RocketMQ集群搭建(3m-3s-async) 各角色介绍 角色 作用 Producer 消息发送者,将消息发送到 Broker.无状态,其与NameServer集群中的一个节点建立长连接,定期从 ...

  4. DB监控-Riak集群监控

    公司的Riak版本是2.0.4,目前已根据CMDB三级业务部署了十几套集群,大部分是跨机房部署.监控采集分为两个大的维度,第一个维度是单机,也就是 「IP:端口」:第二个维度是集群,也就是所有节点指标 ...

  5. 集群监控系统Ganglia应用案例

    集群监控系统Ganglia应用案例 --我们把集群系统投入生产环境后,这时就需要一套可视化的工具来监视集群系统,这将有助于我们迅速地了解机群的整体配置情况,准确地把握机群各个监控节点的信息,全面地察看 ...

  6. redis sentinel 集群监控 配置

    环境: ip  172.16.1.31 26379  redis sentinel ip  172.16.1.30 6379   主 1 ip  172.16.1.31 6380   从 1 ip   ...

  7. Hbase集群监控

    Hbase集群监控 Hbase Jmx监控 监控每个regionServer的总请求数,readRequestsCount,writeRequestCount,region分裂,region合并,St ...

  8. 改造断路器集群监控Hystrix Turbine实现自动注册消费者、实时监控多个服务

    在上一篇文章中,我们搭建了Hystrix Dashoard,对指定接口进行监控.但是只能对一个接口进行监听,功能比较局限: Turbine:汇总系统内多个服务的数据并显示到 Hystrix Dashb ...

  9. 分布式协调服务Zookeeper集群监控JMX和ZkWeb应用对比

    分布式协调服务Zookeeper集群监控JMX和ZkWeb应用对比 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. JMX是用来远程监控Java应用的框架,这个也可以用来监控其他的J ...

随机推荐

  1. Go学习笔记:Win7+LiteIDE+Go+Beego 环境搭建

    安装过程比较简单 1.安装go语言环境: 2.安装git: 3.git bash      安装beego,输入“go get github.com/astaxie/beego”,等待一会儿,在D盘的 ...

  2. linux resin 基本站点配置

    进入配置文件目录: [root@linuxidc resin-]# cd /usr/local/resin/conf/ 查看都有哪些配置文件: [root@linuxidc conf]# ls app ...

  3. 32.Mysql Cluster

    32.Mysql Cluster Cluster是一组节点的组合.节点分为数据节点.SQL节点.管理节点.节点组合在一起可以为应用提供高可用.高性能.可缩放的Cluster数据管理.数据节点使用NDB ...

  4. journalctl 清理journal日志

    在CentOS 7开始使用的systemd使用了journal日志,这个日志的管理方式和以往使用syslog的方式不同,可以通过管理工具维护. 使用df -h检查磁盘文件,可以看到/run目录下有日志 ...

  5. Win 10 安装手机驱动

    直接上图,看图操作即可.

  6. loadtxt()函数的糟心历程

    原计划:导入一个csv文件,然后算出平均值 import numpy as np c=np.loadtxt('d:\python36\data.csv', delimiter=',', usecols ...

  7. Python select模块学习

    select 是常用的异步socket 处理方法 一般用法: # iwtd,owtd,ewtd 分别为需要异步处理的读socket队列, 写socket队列(一般不用), 和错误socket队列, 返 ...

  8. Something of HTTP

    学习发现所需且所欠知识: 参考:  1.一堆博客   2.HTTP图解(链接奉上,自取)提取码: n6jq http简介 http返回状态码 http方法(点击查看) GET POST PATCH H ...

  9. 连续子数组和的最大值plus

    package wodeshiyao; import java.io.BufferedWriter; import java.io.File; import java.io.FileInputStre ...

  10. JavaScript日历(es5版本)

    近期在知乎上看到这么一个帖子,题主说自己JavaScript都学完了,结果老师留的作业还是不会写,就是写一个日历的插件,结果楼下一堆大牛出现了,百度的阿里的纷纷站出来发表自己的看法,有人认为简单,有人 ...