Dubbo+Zookeeper架构—基础篇7—Dubbo监控中心的介绍与简易监控中心的安装

一、 监控中心服务接口调用统计报表的显示配置

1、 Dubbo 服务提供者和服务消费者中的 spring 配置文件中增加以下配置:

<!-- 监控中心配置 --> 

<!-- 监控中心协议,如果为protocol="registry",表示从注册中心发现监控中心地址,否则直连监控中心 --> 
<!-- 直连监控中心服务器地址,如:address="192.168.3.71:7070" --> 

<dubbo:monitor protocol= "registry" /> 

配置截图如下:

 添加完以上配置后,重新构建部署 Dubbo 服务和服务消费者应用。 

2、 Dubbo 简易监控中心的配置解释(不需要修改,使用默认配置) 

上传dubbo monitor监控中心的tar包到linux服务器中。解压后进行配置

配置文件dubbo-monitor/conf/dubbo.profile

##
# Copyright 1999-2011 Alibaba Group.
#  
# 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.
##
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.126.129:2181
#dubbo.registry.address=redis://127.0.0.1:6379
#dubbo.registry.address=dubbo://127.0.0.1:9090
dubbo.protocol.port=7070
dubbo.jetty.port=8090
dubbo.jetty.directory=${user.home}/monitor
dubbo.charts.directory=${dubbo.jetty.directory}/charts
dubbo.statistics.directory=${user.home}/monitor/statistics
dubbo.log4j.file=logs/dubbo-monitor-simple.log
dubbo.log4j.level=WARN
~                                                                                       
~          

dubbo.registry.address=zookeeper://192.168.126.129:2181,配置的是zookeeper中心的位置。

dubbo.protocol.port=7070
dubbo.jetty.port=8090
dubbo.jetty.directory=${user.home}/monitor
dubbo.charts.directory=${dubbo.jetty.directory}/charts
dubbo.statistics.directory=${user.home}/monitor/statistics

恐怕端口会被占用,所以修改端口避免被占用。

看上面配置文件中标红的的 3 行内容,理解${user.home}这个变量的意思则可,${user.home} 指的就是启动 dubbo-monitor 程序的操作系统用户目录。我们这里用的是 wusc 用户,那么 就是/home/wusc 目录(如果是 root 用户启动,那就是/root)。

然后防火墙配置端口不拦截。

[root@edu-procider-01 monitorDir]# vim /etc/sysconfig/iptables


# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited

# 开放zookeeper需要的端口
-A INPUT -m state --state NEW -m tcp -p tcp --dport 2181 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 2888 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3888 -j ACCEPT

# 开放dubbo monitor监控中心的端口
-A INPUT -m state --state NEW -m tcp -p tcp --dport 7070 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8090 -j ACCEPT

# 开放tomcat的端口
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 20880 -j ACCEPT


COMMIT
~                                                                                       
~                                                                                       
~                                                                                       
-- 插入 -- 

然后,启动 zookeeper注册中心、dubbo控制台、dubbo服务提供者,启动dubbo monitor监控中心

查看控制台:

4、 此时再进入 Dubbo 简易监控中心就能查看到对应的报表数据 ,过程monitor监控中心配的访问地址是8090:

http://192.168.126.129:8090/service.html


 

猜你喜欢

转载自blog.csdn.net/weixin_40663800/article/details/83041628