当前位置:   article > 正文

Dubbo:搭建监控中心(dubbo-monitor-simple)_dubbo monitor

dubbo monitor

Dubbo-Monitor介绍

  1. Dubbo-Monitor主要用来统计服务的调用次数和调用时间,服务消费者和提供者,在内存中累计调用次数和调用时间,定时每分钟发送一次统计数据到监控中心,监控中心则使用数据绘制图表来显示。
  2. Dubbo-Monitor挂掉不会影响到Consumer和Provider之间的调用,所以用于生产环境不会有风险。 
  3.  配置好了之后可以结合admin管理后台使用,可以清晰的看到服务的访问记录、成功次数、失败次数等…..
  4. Simple Monitor采用磁盘存储统计信息,请注意安装机器的磁盘限制,如果要集群,建议用mount共享磁盘。 

Dubbo-Monitor安装和配置

下载dubbo-monitor-simple

官网地址:https://github.com/apache/incubator-dubbo/tree/2.5.x/dubbo-simple

配置dubbo.properties

  1. # Licensed to the Apache Software Foundation (ASF) under one or more
  2. # contributor license agreements. See the NOTICE file distributed with
  3. # this work for additional information regarding copyright ownership.
  4. # The ASF licenses this file to You under the Apache License, Version 2.0
  5. # (the "License"); you may not use this file except in compliance with
  6. # the License. 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. dubbo.container=log4j,spring,registry,jetty
  16. dubbo.application.name=simple-monitor
  17. dubbo.application.owner=
  18. #dubbo.registry.address=multicast://224.5.6.7:1234
  19. dubbo.registry.address=zookeeper://192.168.60.207:2181
  20. #dubbo.registry.address=redis://127.0.0.1:6379
  21. #dubbo.registry.address=dubbo://127.0.0.1:9090
  22. # 是Monitor提供的远程服务监听端口,服务提供者和消费者会调用这个端口提供的服务,发送统计信息到Monitor
  23. dubbo.protocol.port=7070
  24. # 设置Jetty容器的监听地址,类似于Tomcat的8080端口,这里设置为8099
  25. dubbo.jetty.port=8099
  26. # 存放图表的位置
  27. dubbo.jetty.directory=${user.home}/monitor
  28. #dubbo.charts.directory=${dubbo.jetty.directory}/charts
  29. dubbo.charts.directory=${user.home}/monitor/charts
  30. dubbo.statistics.directory=${user.home}/monitor/statistics
  31. # 日志
  32. dubbo.log4j.file=logs/dubbo-monitor-simple.log
  33. dubbo.log4j.level=WARN

监控服务提供方和消费方

需要在服务提供方和消费方增加连接配置中心的配置来实现监控

<dubbo:monitor/>监控中心配置用于配置连接监控中心相关信息,可选

在服务提供方和消费方的配置文件中添加如下代码

  1. <!-- 连接监控中心 -->
  2. <dubbo:monitor protocol="registry"></dubbo:monitor>
  3. <!--
  4. <dubbo:monitor address="127.0.0.1:7070"></dubbo:monitor>
  5. -->

示例(dubbo-demo-provider.xml):

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!--
  3. Licensed to the Apache Software Foundation (ASF) under one or more
  4. contributor license agreements. See the NOTICE file distributed with
  5. this work for additional information regarding copyright ownership.
  6. The ASF licenses this file to You under the Apache License, Version 2.0
  7. (the "License"); you may not use this file except in compliance with
  8. the License. You may obtain a copy of the License at
  9. http://www.apache.org/licenses/LICENSE-2.0
  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. <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  17. xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
  18. xmlns="http://www.springframework.org/schema/beans"
  19. xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
  20. http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
  21. <!-- provider's application name, used for tracing dependency relationship -->
  22. <dubbo:application name="demo-provider"/>
  23. <!-- use multicast registry center to export service -->
  24. <!--<dubbo:registry address="multicast://224.5.6.7:1234"/>-->
  25. <dubbo:registry protocol="zookeeper" address="192.168.60.207:2181" />
  26. <!-- use dubbo protocol to export service on port 20880 -->
  27. <dubbo:protocol name="dubbo" port="20880"/>
  28. <!-- service implementation, as same as regular local bean -->
  29. <bean id="demoService" class="com.alibaba.dubbo.demo.provider.DemoServiceImpl"/>
  30. <!-- declare the service interface to be exported -->
  31. <dubbo:service interface="com.alibaba.dubbo.demo.DemoService" ref="demoService"/>
  32. <!--监控中心-->
  33. <dubbo:monitor protocol="registry"/>
  34. </beans>

 

启动Dubbo-Monitor

进入\dubbo-monitor-simple-2.5.10-assembly\dubbo-monitor-simple-2.5.10\bin

启动:

./bin/start.sh  (windows系统是/bin/start.bat)

Dubbo-Monitor常用命令

启动:

./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

Dubbo-Monitor

访问 http://192.168.60.207:8099

可以服务查看,应用程序查看,调用情况统计;

可以看到服务提供的名称(Service Name),配置的提供者的名称(Application),提供者的数量(Providers(2)),消费者的数量( Consumers(3)),统计(Statistics) 和 图表(Charts)。

    1.点击 Providers(1),可以看到提供者的详细信息,即提供者的URL

  2.点击Consumers(1),可以看到消费者的详细信息,即消费者的URL

  3.点击Statistics,成功的次数,失败的次数,平均花费的时间,最大花费的时间,并发的次数。

  4.点击Charts,可以看到请求和响应的图表。
 

 

Dubbo-Monitor图表不显示

1.可能不会自动创建monitor文件夹,需要在${user.home}目录下创建monitor目录

2.需要在服务端配置<dubbo:monitor protocol="registry"/>

3.在消费端配置<dubbo:monitor protocol="registry"/>

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/笔触狂放9/article/detail/169649
推荐阅读
相关标签
  

闽ICP备14008679号