| — | — | — | — | — |
| zookeeper | 192.168.50.43 | 2181 | 注册中心、配置中心 | 作用 |
| springboot-zk-provider | 192.168.50.12 | 8080 | springbootzkprovider | 服务提供者 |
| springboot-zk-consumer | 192.168.50.12 | 8081 | springbootzkconsumer | 服务消费者 |
接下来要准备配置信息,首选要强调的是dubbo-admin有三个重要的配置项:admin.config-center(配置中心),admin.registry.address(注册中心)、admin.metadata-report.address(元数据中心);
如果在配置文件中只有admin.registry.address(旧版本的做法),此时dubbo-admin会将admin.registry.address的值作为注册中心和配置中心使用,元数据中心将无法使用,因此官方不推荐这样的配置;
官方推荐的做法:在配置文件中只有admin.config-center,此配置的值是zookeeper地址,在zookeeper服务中有个节点,路径是/dubbo/config/dubbo/dubbo.properties,内容是admin.registry.address和admin.metadata-report.address的配置,如下所示:
dubbo.registry.address=zookeeper://127.0.0.1:2181
dubbo.metadata-report.address=zookeeper://127.0.0.1:2181
基于上述分析,咱们要先在zookeeper中创建好节点/dubbo/config/dubbo/dubbo.properties,以便dubbo-admin使用,请登录zookeeper所在服务器,进入zookeeper的bin目录;
由于前面的文章已经使用过zookeeper作为注册中心,因此"/dubbo/config/"目录已经存在,下面的命令会创建/dubbo/config/dubbo节点:
./zkCli.sh create /dubbo/config/dubbo “”
./zkCli.sh create /dubbo/config/dubbo/dubbo.properties "dubbo.registry.address=zookeeper://192.168.50.43:2181
dubbo.metadata-report.address=zookeeper://192.168.50.43:2181"
《一线大厂Java面试题解析+后端开发学习笔记+最新架构讲解视频+实战项目源码讲义》
【docs.qq.com/doc/DSmxTbFJ1cmN1R2dB】 完整内容开源分享
,输入和响应如下所示,可见节点创建成功,值也是预期的:
root@zookeeper:/opt/zookeeper-3.4.13/bin# ./zkCli.sh get /dubbo/config/dubbo/dubbo.properties
Connecting to localhost:2181
2020-10-25 03:47:50,512 [myid:] - INFO [main:Environment@100] - Client environment:zookeeper.version=3.4.13-2d71af4dbe22557fda74f9a9b4309b15a7487f03, built on 06/29/2018 04:05 GMT
environment:user.home=/root
2020-10-25 03:47:50,526 [myid:] - INFO [main:Environment@100] - Client environment:user.dir=/opt/zookeeper-3.4.13/bin
2020-10-25 03:47:50,529 [myid:] - INFO [main:ZooKeeper@442] - Initiating client connection, connectString=localhost:2181 sessionTimeout=30000 watcher=org.apache.zookeeper.ZooKeeperMain$MyWatcher@674e5e21
2020-10-25 03:47:50,584 [myid:] - INFO [main-SendThread(localhost:2181):ClientCnxn$SendThread@1029] - Opening socket connection to server localhost/127.0.0.1:2181. Will not attempt to authenticate using SASL (unknown error)
WATCHER::
WatchedEvent state:SyncConnected type:None path:null
dubbo.registry.address=zookeeper://192.168.50.43:2181
dubbo.metadata-report.address=zookeeper://192.168.50.43:2181
cZxid = 0x6b5
ctime = Sun Oct 25 03:47:30 UTC 2020
mZxid = 0x6b5
mtime = Sun Oct 25 03:47:30 UTC 2020
pZxid = 0x6b5
cversion = 0
dataVersion = 0
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 114
numChildren = 0
请确保docker已部署并正常运行;
官方Github建议通过docker镜像快速体验管理控制台,如下图,咱们就按照官方的建议先用docker镜像试试:
docker pull apache/dubbo-admin
docker run \
-p 8083:8080 \
-e admin.config-center=zookeeper://192.168.50.43:2181 \
–rm \
apache/dubbo-admin
用上述命令启动的容器是一次性的,如果用Ctrl+C中断控制台,容器就会自动销毁,另外容器的8080端口被映射到了宿主机的8083端口;
用浏览器访问宿主机的8083端口,如下图所示,dubbo-admin已经启动了:
以上就是官方提供的体验版,算是让咱们对管理控制台有了基本了解,但这仅是用于体验的镜像,实际生产环境中,首先未必会用docker,并且可能需要有对应的源码以便学习和分析问题,甚至有可能用源码做进一步定制,因此这个docker版本就不适合了,接下来一起下载dubbo-admin源码自行编译构建;
在启动docker容器的控制台执行Ctrl+C,刚才创建的容器就会自动销毁;
git clone https://github.com/apache/dubbo-admin.git
server.port=8083
#admin.registry.address=zookeeper://127.0.0.1:2181
admin.config-center=zookeeper://192.168.50.43:2181
#admin.metadata-report.address=zookeeper://127.0.0.1:2181
admin.root.user.name=root
admin.root.user.password=root
#group
admin.registry.group=dubbo
admin.config-center.group=dubbo
admin.metadata-report.group=dubbo
admin.apollo.token=e16e5cd903fd0c97a116c873b448544b9d086de9
admin.apollo.appId=test
admin.apollo.env=dev
admin.apollo.cluster=default
admin.apollo.namespace=dubbo
#compress
server.compression.enabled=true
server.compression.mime-types=text/css,text/javascript,application/javascript
server.compression.min-response-size=10240
mvn clean compile -U
[INFO] — maven-compiler-plugin:3.7.0:compile (default-compile) @ dubbo-admin-test —