RocketMQ 集群监控以及Hello World
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
#新建目录
mkdir rocketmq-console
#解压war文件
unzip rocketmq-console.war -d rocketmq-console
#删除war
rm -f rocketmq-console.war
2、修改配置 指定nameserveraddr
cd /usr/local/tomcat7/webapps/rocketmq-console/WEB-INF/classes vim config.properties rocketmq.namesrv.addr=192.168.1.201:;192.168.1.202:
throwDone=true
3、启动tomcat
[root@ bin]# /usr/local/tomcat7/bin/startup.sh
Using CATALINA_BASE: /usr/local/tomcat7
Using CATALINA_HOME: /usr/local/tomcat7
Using CATALINA_TMPDIR: /usr/local/tomcat7/temp
Using JRE_HOME: /usr/local/java/jdk1..0_80
Using CLASSPATH: /usr/local/tomcat7/bin/bootstrap.jar:/usr/local/tomcat7/bin/tomcat-juli.jar
Tomcat started.
[root@ bin]# jps
Jps
NamesrvStartup
Bootstrap
BrokerStartup
4、浏览器访问
http://192.168.1.201:8080/rocketmq-console
/**
* Copyright (C) 2010-2013 Alibaba Group Holding Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package rocketmq.quickstart; import com.alibaba.rocketmq.client.exception.MQClientException;
import com.alibaba.rocketmq.client.producer.DefaultMQProducer;
import com.alibaba.rocketmq.client.producer.SendResult;
import com.alibaba.rocketmq.common.message.Message; /**
* Producer,发送消息
*
*/
public class Producer
{
public static void main(String[] args) throws MQClientException,
InterruptedException
{
DefaultMQProducer producer = new DefaultMQProducer("QuickStart_Producer");
producer.setNamesrvAddr("192.168.1.201:9876;192.168.1.202:9876");
producer.start(); for (int i = 0; i < 1000; i++)
{
try
{
Message msg = new Message("TopicQuickStart",// topic
"TagA",// tag
("Hello RocketMQ " + i).getBytes()// body
);
SendResult sendResult = producer.send(msg);
System.out.println(sendResult);
} catch (Exception e) {
e.printStackTrace();
Thread.sleep(1000);
}
} producer.shutdown();
}
}
/**
* Copyright (C) 2010-2013 Alibaba Group Holding Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package rocketmq.quickstart; import java.io.UnsupportedEncodingException;
import java.util.List; import com.alibaba.rocketmq.client.consumer.DefaultMQPushConsumer;
import com.alibaba.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
import com.alibaba.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
import com.alibaba.rocketmq.client.consumer.listener.MessageListenerConcurrently;
import com.alibaba.rocketmq.client.exception.MQClientException;
import com.alibaba.rocketmq.common.consumer.ConsumeFromWhere;
import com.alibaba.rocketmq.common.message.MessageExt; /**
* Consumer,订阅消息
*/
public class Consumer { public static void main(String[] args) throws InterruptedException,
MQClientException
{
DefaultMQPushConsumer consumer = new DefaultMQPushConsumer("QuickStart_Consumer");
consumer.setNamesrvAddr("192.168.1.201:9876;192.168.1.202:9876");
/**
* 设置Consumer第一次启动是从队列头部开始消费还是队列尾部开始消费<br>
* 如果非第一次启动,那么按照上次消费的位置继续消费
*/
consumer.setConsumeFromWhere(ConsumeFromWhere.CONSUME_FROM_FIRST_OFFSET); consumer.subscribe("TopicQuickStart", "*"); consumer.registerMessageListener(new MessageListenerConcurrently() { @Override
public ConsumeConcurrentlyStatus consumeMessage(
List<MessageExt> msgs, ConsumeConcurrentlyContext context) {
try {
for (int i = 0; i < msgs.size(); i++) {
MessageExt msg = msgs.get(i);
String topic = msg.getTopic();
String tag = msg.getTags();
String body = new String(msg.getBody(), "UTF-8");
System.out.println(Thread.currentThread().getName()
+ " Receive New Messages: topic="
+ topic+",tag="
+ tag +",body="
+ body); }
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
return ConsumeConcurrentlyStatus.RECONSUME_LATER;
}
return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
}
}); consumer.start(); System.out.println("Consumer Started.");
}
}
生产消息:
消费消息:
监控消息:
二、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即可。
设置后的配置文件如下所示:
server.contextPath=
server.port=8080
#spring.application.index=true
spring.application.name=rocketmq-console
spring.http.encoding.charset=UTF-8
spring.http.encoding.enabled=true
spring.http.encoding.force=true
logging.config=classpath:logback.xml
#if this value is empty,use env value rocketmq.config.namesrvAddr NAMESRV_ADDR | now, you can set it in ops page.default localhost:9876
rocketmq.config.namesrvAddr=192.168.1.80:9876;192.168.1.81:9876
#if you use rocketmq version < 3.5.8, rocketmq.config.isVIPChannel should be false.default true
rocketmq.config.isVIPChannel=false
#rocketmq-console's data path:dashboard/monitor
rocketmq.config.dataPath=/home/hadmin/data/rocketmq
#set it false if you don't want use dashboard.default true
rocketmq.config.enableDashBoardCollect=true
参考:https://www.cnblogs.com/quchunhui/p/7284752.html
RocketMQ 集群监控以及Hello World的更多相关文章
- RocketMQ集群部署记录
RocketMQ集群部署记录 #引用 https://cloud.tencent.com/developer/article/1147765 一.RocketMQ基础知识介绍 A ...
- CentOS7.4上搭建rocketMQ集群
一.rocketMQ集群部署方案优缺点对比: 多Master模式(2m-noslave) : 一个集群无Slave,全是Master,例如2个Master或者3个Master 优点:配置简单,单个Ma ...
- RocketMQ集群搭建(3m-3s-async)
RocketMQ集群搭建(3m-3s-async) 各角色介绍 角色 作用 Producer 消息发送者,将消息发送到 Broker.无状态,其与NameServer集群中的一个节点建立长连接,定期从 ...
- DB监控-Riak集群监控
公司的Riak版本是2.0.4,目前已根据CMDB三级业务部署了十几套集群,大部分是跨机房部署.监控采集分为两个大的维度,第一个维度是单机,也就是 「IP:端口」:第二个维度是集群,也就是所有节点指标 ...
- 集群监控系统Ganglia应用案例
集群监控系统Ganglia应用案例 --我们把集群系统投入生产环境后,这时就需要一套可视化的工具来监视集群系统,这将有助于我们迅速地了解机群的整体配置情况,准确地把握机群各个监控节点的信息,全面地察看 ...
- 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 ...
- Hbase集群监控
Hbase集群监控 Hbase Jmx监控 监控每个regionServer的总请求数,readRequestsCount,writeRequestCount,region分裂,region合并,St ...
- 改造断路器集群监控Hystrix Turbine实现自动注册消费者、实时监控多个服务
在上一篇文章中,我们搭建了Hystrix Dashoard,对指定接口进行监控.但是只能对一个接口进行监听,功能比较局限: Turbine:汇总系统内多个服务的数据并显示到 Hystrix Dashb ...
- 分布式协调服务Zookeeper集群监控JMX和ZkWeb应用对比
分布式协调服务Zookeeper集群监控JMX和ZkWeb应用对比 作者:尹正杰 版权声明:原创作品,谢绝转载!否则将追究法律责任. JMX是用来远程监控Java应用的框架,这个也可以用来监控其他的J ...
随机推荐
- Rancher 2.0 简单使用 重要部分截取
学习地址 : https://rancher.com/docs/rancher/v2.x/en/quick-start-guide/ Install Rancher sudo docker run - ...
- AudiosessionSetActive
IOS audiosession 会话控制声音播放 今天遇到一个问题: 当我外部想要关闭声音播放的时候 audiosessionsetActive(false) 居然报错了,但是作用起了 AVAud ...
- python note 07 集合
1.删除特例 lis = [11,22,33,44,55] for i in range(len(lis)): print(i) del lis[i] print(lis) #每删除链表中一个值链表就 ...
- 随笔 | 分布式版本控制系统Git的安装与使用
作业要求来自https://edu.cnblogs.com/campus/gzcc/GZCC-16SE2/homework/2097 GitHub远程仓库的地址https://github.com/W ...
- swift 警告框 - 自定义按钮颜色,图片
1.封装 弹框http://www.hangge.com/blog/cache/detail_651.html import UIKit extension UIAlertController { / ...
- adc指令
adc是带进位加法指令,它利用了CF位上记录的进位值. 指令格式: adc 操作对象1,操作对象2 功能:操作对象1 = 操作对象1 + 操作对象2 + CF 例如指令 adc ax,bx实现的功能 ...
- centos 搭建git 服务器
安装 git yum -y install git 添加git 用户 adduser git 切换到git 用户 su git 在git用户家目录下创建 .ssh文件夹 mkdir .ssh 修改文 ...
- 6M - 循环多少次?
我们知道,在编程中,我们时常需要考虑到时间复杂度,特别是对于循环的部分.例如, 如果代码中出现 for(i=1;i<=n;i++) OP ; 那么做了n次OP运算,如果代码中出现 fori=1; ...
- 2019.03.01 bzoj2555: SubString(sam+lct)
传送门 题意简述: 要求在线支持两个操作 (1):在当前字符串的后面插入一个字符串 (2):询问字符串s在当前字符串中出现了几次?(作为连续子串) 思路: 考虑用lctlctlct来动态维护samsa ...
- JavaScript基础视频教程总结(021-030章)
<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title&g ...