赞
踩
- Dubbo-Monitor主要用来统计服务的调用次数和调用时间,服务消费者和提供者,在内存中累计调用次数和调用时间,定时每分钟发送一次统计数据到监控中心,监控中心则使用数据绘制图表来显示。
- Dubbo-Monitor挂掉不会影响到Consumer和Provider之间的调用,所以用于生产环境不会有风险。
- 配置好了之后可以结合admin管理后台使用,可以清晰的看到服务的访问记录、成功次数、失败次数等…..
- Simple Monitor采用磁盘存储统计信息,请注意安装机器的磁盘限制,如果要集群,建议用mount共享磁盘。
官网地址:https://github.com/apache/incubator-dubbo/tree/2.5.x/dubbo-simple
- # Licensed to the Apache Software Foundation (ASF) under one or more
- # contributor license agreements. See the NOTICE file distributed with
- # this work for additional information regarding copyright ownership.
- # The ASF licenses this file to You 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.
-
- dubbo.container=log4j,spring,registry,jetty
- dubbo.application.name=simple-monitor
- dubbo.application.owner=
- #dubbo.registry.address=multicast://224.5.6.7:1234
- dubbo.registry.address=zookeeper://192.168.60.207:2181
- #dubbo.registry.address=redis://127.0.0.1:6379
- #dubbo.registry.address=dubbo://127.0.0.1:9090
- # 是Monitor提供的远程服务监听端口,服务提供者和消费者会调用这个端口提供的服务,发送统计信息到Monitor
- dubbo.protocol.port=7070
- # 设置Jetty容器的监听地址,类似于Tomcat的8080端口,这里设置为8099
- dubbo.jetty.port=8099
- # 存放图表的位置
- dubbo.jetty.directory=${user.home}/monitor
- #dubbo.charts.directory=${dubbo.jetty.directory}/charts
- dubbo.charts.directory=${user.home}/monitor/charts
- dubbo.statistics.directory=${user.home}/monitor/statistics
- # 日志
- dubbo.log4j.file=logs/dubbo-monitor-simple.log
- dubbo.log4j.level=WARN
需要在服务提供方和消费方增加连接配置中心的配置来实现监控
<dubbo:monitor/> | 监控中心配置 | 用于配置连接监控中心相关信息,可选 |
在服务提供方和消费方的配置文件中添加如下代码
- <!-- 连接监控中心 -->
- <dubbo:monitor protocol="registry"></dubbo:monitor>
- <!--
- <dubbo:monitor address="127.0.0.1:7070"></dubbo:monitor>
- -->
示例(dubbo-demo-provider.xml):
- <?xml version="1.0" encoding="UTF-8"?>
- <!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You 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.
- -->
- <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
- xmlns="http://www.springframework.org/schema/beans"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
- http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
-
- <!-- provider's application name, used for tracing dependency relationship -->
- <dubbo:application name="demo-provider"/>
-
- <!-- use multicast registry center to export service -->
- <!--<dubbo:registry address="multicast://224.5.6.7:1234"/>-->
- <dubbo:registry protocol="zookeeper" address="192.168.60.207:2181" />
-
- <!-- use dubbo protocol to export service on port 20880 -->
- <dubbo:protocol name="dubbo" port="20880"/>
-
- <!-- service implementation, as same as regular local bean -->
- <bean id="demoService" class="com.alibaba.dubbo.demo.provider.DemoServiceImpl"/>
-
- <!-- declare the service interface to be exported -->
- <dubbo:service interface="com.alibaba.dubbo.demo.DemoService" ref="demoService"/>
-
- <!--监控中心-->
- <dubbo:monitor protocol="registry"/>
-
- </beans>
进入\dubbo-monitor-simple-2.5.10-assembly\dubbo-monitor-simple-2.5.10\bin
启动:
./bin/start.sh (windows系统是/bin/start.bat)
启动:
./bin/start.sh (windows系统是/bin/start.bat)
停止:./bin/stop.sh
重启:./bin/restart.sh
调试:./bin/start.sh debug
系统状态:./bin/dump.sh
总控入口:./bin/server.sh start
./bin/server.sh stop
./bin/server.sh restart
./bin/server.sh debug
./bin/server.sh dump
可以服务查看,应用程序查看,调用情况统计;
可以看到服务提供的名称(Service Name),配置的提供者的名称(Application),提供者的数量(Providers(2)),消费者的数量( Consumers(3)),统计(Statistics) 和 图表(Charts)。
1.点击 Providers(1),可以看到提供者的详细信息,即提供者的URL
2.点击Consumers(1),可以看到消费者的详细信息,即消费者的URL
3.点击Statistics,成功的次数,失败的次数,平均花费的时间,最大花费的时间,并发的次数。
4.点击Charts,可以看到请求和响应的图表。
1.可能不会自动创建monitor文件夹,需要在${user.home}目录下创建monitor目录
2.需要在服务端配置<dubbo:monitor protocol="registry"/>
3.在消费端配置<dubbo:monitor protocol="registry"/>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。