dubbo 官网:http://dubbo.apache.org/zh-cn/docs/user/quick-start.html
dubbo-admin 下载 : https://github.com/locationbai/incubator-dubbo-ops-master
一、配置dubbo监控中心
下载 dubbo-admin
进入dubbo-admin 目录,执行 mvn clean package 打包
启动zookeeper
启动 jar 包
浏览器访问:localhost:7001
输入用户名/密码,root/root(在配置文件中配置)
二、配置提供者与消费者
目录结构:模拟订单信息(消费者)、用户信息(生产者)、接口信息,维护公共的信息
案例下载地址:https://github.com/locationbai/dubbo-demo
1.提供者配置
<?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.userservice</groupId> <artifactId>userservice</artifactId> <version>1.0-SNAPSHOT</version> <dependencies> <dependency> <groupId>com.total-interface</groupId> <artifactId>total-interface</artifactId> <version>1.0-SNAPSHOT</version> </dependency> <!--dubbo依赖--> <dependency> <groupId>com.alibaba</groupId> <artifactId>dubbo</artifactId> <version>2.6.2</version> </dependency> <!--zookeeper客户端--> <dependency> <groupId>org.apache.curator</groupId> <artifactId>curator-framework</artifactId> <version>2.12.0</version> </dependency> <dependency> <groupId>org.slf4j</groupId> <artifactId>slf4j-nop</artifactId> <version>1.7.2</version> </dependency> </dependencies> </project>
2.消费者配置
<?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-4.3.xsd http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <context:component-scan base-package="server.impl"></context:component-scan> <!-- 消费方应用名,用于计算依赖关系,不是匹配条件,不要与提供方一样 --> <dubbo:application name="order-service" /> <!-- 使用multicast/zookeeper广播注册中心暴露发现服务地址 --> <dubbo:registry address="zookeeper://127.0.0.1:2181" /> <!-- 生成远程服务代理,可以和本地bean一样使用demoService --> <dubbo:reference id="demoService" interface="service.UserService" /> <dubbo:monitor address="127.0.0.1:7001"></dubbo:monitor> </beans>
三、启动提供者与消费者
访问:localhost:7001 (7001为监控中心地址)
四、开启monitor
进入dubbo-monitor-simple 目录,执行 mvn package jar打包
将打好的包的另一个压缩包解压
在bin目录下启动 monitor
访问:localhost:8080 查看