zoukankan      html  css  js  c++  java
  • 安装dubbo的监控中心dubbo-monitor-simple

    1、下载dubbo-monitor-simple

    2、修改配置指定注册中心地址

    进入dubbo-monitor-simplesrcmain esourcesconf目录修改 dubbo.properties文件

    # 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-monitor
    dubbo.application.name=simple-monitor
    dubbo.application.owner=dubbo
    #dubbo.registry.address=multicast://224.5.6.7:1234
    dubbo.registry.address=zookeeper://127.0.0.1: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=8080
    dubbo.jetty.directory=${user.home}/monitor
    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
    

    3、打包dubbo-monitor-simple

    进入pom.xml文件所在目录D:BaiduNetdiskDownloadDubboincubator-dubbo-ops-masterdubbo-monitor-simple

    运行mvn clean package -Dmaven.test.skip=true命令进行打包

    4、解压dubbo-monitor-simple-2.0.0-assembly.tar.gz文件

    5、进入D:BaiduNetdiskDownloadDubbodubbo-monitor-simple-2.0.0assembly.bin目录,运行start.bat

    6、在浏览器中访问8080端口

    7、配置监控中心

    所有服务配置连接监控中心,进行监控统计
    <!-- 监控中心协议,如果为protocol="registry",表示从注册中心发现监控中心地址,否则直连监控中心 -->
    <dubbo:monitor protocol="registry"></dubbo:monitor>

    Simple Monitor 挂掉不会影响到 Consumer 和 Provider 之间的调用,所以用于生产环境不会有风险。Simple Monitor 采用磁盘存储统计信息,请注意安装机器的磁盘限制,如果要集群,建议用mount共享磁盘。

    1)、在服务提供者user-service-provider的配置文件provider.xml中添加如下内容:

    <!-- 连接监控中心 -->
    <dubbo:monitor protocol="registry"></dubbo:monitor>
    <!--直连监控中心-->
    <!-- <dubbo:monitor address="127.0.0.1:7070"></dubbo:monitor> -->
    

    添加后的provider.xml文件内容如下:

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
           xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
           xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
           xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
    		http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
    
        <!-- 1、指定当前服务/应用的名字(同样的服务名字相同,不要和别的服务同名) -->
        <dubbo:application name="user-service-provider"></dubbo:application>
    
        <!-- 2、指定注册中心的位置 -->
        <!-- <dubbo:registry address="zookeeper://127.0.0.1:2181"></dubbo:registry> -->
        <dubbo:registry protocol="zookeeper" address="127.0.0.1:2181"></dubbo:registry>
    
        <!-- 3、指定通信规则(通信协议&通信端口) -->
        <dubbo:protocol name="dubbo" port="20880"></dubbo:protocol>
    
        <!-- 4、暴露服务   ref:指向服务的真正的实现对象 -->
        <dubbo:service interface="com.lina02.gmall.service.UserService" ref="userServiceImpl"/>
    
        <!-- 服务的实现 -->
        <bean id="userServiceImpl" class="com.lina02.gmall.service.impl.UserServiceImpl"></bean>
    
        <!-- 连接监控中心 -->
        <dubbo:monitor protocol="registry"></dubbo:monitor>
        <!--直连监控中心-->
        <!-- <dubbo:monitor address="127.0.0.1:7070"></dubbo:monitor> -->
    </beans>
    

    2)在服务消费者order-service-consumer的配置文件consumer.xml中添加如下内容:

    <!-- 连接监控中心 -->
    <dubbo:monitor protocol="registry"></dubbo:monitor>
    <!--直连监控中心-->
    <!-- <dubbo:monitor address="127.0.0.1:7070"></dubbo:monitor> -->
    

    添加后的consumer.xml文件内容如下: 

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="http://www.springframework.org/schema/beans"
    	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    	xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
    	xmlns:context="http://www.springframework.org/schema/context"
    	xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
    		http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.3.xsd
    		http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd
    		http://code.alibabatech.com/schema/dubbo http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
    	<context:component-scan base-package="com.lina02.gmall.service.impl"></context:component-scan>
    
    	<dubbo:application name="order-service-consumer"></dubbo:application>
    	
    	<dubbo:registry address="zookeeper://127.0.0.1:2181"></dubbo:registry>
    	
    	<!--声明需要调用的远程服务的接口;生成远程服务代理  -->
    	<dubbo:reference interface="com.lina02.gmall.service.UserService" id="userService">
    	</dubbo:reference>
    
    	<!-- 连接监控中心 -->
    	<dubbo:monitor protocol="registry"></dubbo:monitor>
    	<!--直连监控中心-->
    	<!-- <dubbo:monitor address="127.0.0.1:7070"></dubbo:monitor> -->
    	
    </beans>
    

    8、查看监控中心

  • 相关阅读:
    C#开发中is和as的区别
    Winform开发框架之系统登录实现
    C#几个经常犯错误汇总
    JavaScript事件冒泡简介及应用
    在C#的winForm程序中调用和执行javascript
    C#关于托管程序和非托管程序的区别
    分布式计算 网格计算 并行计算 云计算
    (转)960的秘密
    集群概念:集群技术简介(转)
    好用的Sql格式化工具
  • 原文地址:https://www.cnblogs.com/xidian2014/p/9848117.html
Copyright © 2011-2022 走看看