这里:记录dubbo 3,以及最新 dubbo-admin 操作记录。
$ git clone https://github.com/apache/dubbo-admin.git (官方)
作者为了保证当时版本统一保留一份 git(可以试用如下)
https://gitee.com/zhang405710664/dubbo_admin.git $ git clone https://gitee.com/zhang405710664/dubbo_admin.git
Dubbo Admin 是一个控制台,为 Dubbo 集群提供更好可视化服务。Admin 支持 Dubbo3 并很好的兼容 2.7.x、2.6.x 和 2.5.x。
下载代码: git clone https://github.com/apache/dubbo-admin.git
在 dubbo-admin-server/src/main/resources/application.properties中指定注册中心地址
构建
mvn clean package -Dmaven.test.skip=true
启动
mvn --projects dubbo-admin-server spring-boot:run 或者
cd dubbo-admin-distribution/target; java -jar dubbo-admin-${project.version}.jar
访问 http://localhost:38080
注意:dubbo-admin 链接虚拟机的 zookeeper时间较长,需要设置超时时间
server.port=38080
dubbo.protocol.port=30880
dubbo.application.qos-port=32222
dubbo.registry.timeout=999999
dubbo.registry.param.blockUntilConnectedWait=9999999
admin.registry.address=zookeeper://192.168.10.100:2181
admin.config-center=zookeeper://192.168.10.100:2181
admin.metadata-report.address=zookeeper://192.168.10.100:2181
admin.root.user.name=root
admin.root.user.password=root
#session timeout, default is one hour
admin.check.sessionTimeoutMilli=3600000
GitHub - apache/dubbo-samples: samples for Apache Dubbo (官方)
如果你链接不上 gitHub ,作者为了保证当时版本统一保留一份 git(可以试用如下)
https://gitee.com/zhang405710664/apache-dubbo-samples.git
注意: 链接虚拟机的 zookeeper时间较长,需要设置超时时间
dubbo:
application:
name: dubbo-springboot-demo-provider
protocol:
name: dubbo
port: -1
registry:
address: zookeeper://192.168.10.101:2181
timeout: 250000
parameters:
blockUntilConnectedWait: 250
1 动态路由
enabled: true
force: false
runtime: false
conditions:
- host = 192.168.10.101 =>
经过验证,有效
配置动态路由
先配置 均衡规则;
配置权重: 配置动态规则
enabled: true
configs:
- side: consumer
addresses:
- 0.0.0.0
providerAddresses:
- '192.168.10.100:20880'
- '192.168.10.101:20881'
parameters:
timeout: 6000
loadbalance: random
- side: provider
addresses:
- '192.168.10.101:20880'
parameters:
threadpool: fixed
threads: 200
iothreads: 4
dispatcher: all
weight: 50
- side: provider
addresses:
- '192.168.10.102:20880'
parameters:
threadpool: fixed
threads: 200
iothreads: 4
dispatcher: all
weight: 100
这里配置 ,走了很多弯路,参考 基于 Dubbo Admin 动态调整服务超时时间_慕课手记
规则详解
配置模板
---
configVersion: v2.7
scope: application/service
key: app-name/group+service+version
enabled: true
configs:
- addresses: ["0.0.0.0"]
providerAddresses: ["1.1.1.1:20880", "2.2.2.2:20881"]
side: consumer
applications/services: []
parameters:
timeout: 1000
loadbalance: random
- addresses: ["0.0.0.0:20880"]
side: provider
applications/services: []
parameters:
threadpool: fixed
threads: 200
iothreads: 4
dispatcher: all
weight: 200
...
对于动态调整超时时间场景,只需要理清楚以下问题基本就知道配置该怎么写了:
scope: application, key: app-name
(还可使用services
指定某几个服务)。scope: service, key:group+service+version
。side: consumer
,作用到消费端时,你还可以进一步使用providerAddress
, applications
选定特定的提供者示例或应用,如果同时配置消费者和提供者,消费者会覆盖提供者。side: provider
。addresses: ["0.0.0.0"]
或addresses: ["0.0.0.0:*"]
具体由side值决定。addersses[实例地址列表]
。