编程知识 cdmana.com

Dubbo actual combat 4: management console Dubbo admin

Welcome to visit mine GitHub

Here we classify and summarize all the original works of Xinchen ( Including supporting source code ):https://github.com/zq2599/blog_demos

《dubbo actual combat 》 Series navigation

  1. Prepare and experience
  2. And SpringBoot Integrate
  3. Use Zookeeper Registry Center
  4. Administrative console dubbo-admin

An overview of this article

  • This article is about 《dubbo actual combat 》 The fourth in the series , The content is deployment and startup dubbo Administrative console service , The service is being developed 、 test 、 Production and other links are very important , Let's learn and understand it through actual combat , official GitHub Address :https://github.com/apache/dubbo-admin
  • The whole article consists of the following :
  1. preparation ( Registry Center 、 Service providers 、 Serving consumers );
  2. preparation ( Configuration information );
  3. Experience docker edition ;
  4. Download the source code and build it yourself ;

preparation ( Registry Center 、 Service providers 、 Serving consumers )

  1. The so-called preparatory work , Is to prepare a relatively complete dubbo Environmental Science , There's a registry in there 、 Service providers 、 Serving consumers ;
  2. In the last article 《dubbo The third part of the actual battle : Use Zookeeper Registry Center 》, We have created and validated service providers and consumers , And take zookeeper As a registry , Now please start all of these services , My service here is as follows :
service IP port Project name effect
zookeeper 192.168.50.43 2181 Registry Center 、 Configuration center effect
springboot-zk-provider 192.168.50.12 8080 springbootzkprovider Service providers
springboot-zk-consumer 192.168.50.12 8081 springbootzkconsumer Serving consumers
  1. Make sure zookeeper、 Service providers 、 All service consumers are activated and functioning properly ;

preparation ( Configuration information )

  1. The next step is to prepare the configuration information , The first thing to emphasize is dubbo-admin There are three important configuration items :admin.config-center( Configuration center ),admin.registry.address( Registry Center )、admin.metadata-report.address( Metadata Center );
  2. If there are only admin.registry.address( The old version did ), here dubbo-admin Will admin.registry.address The value of is used as registry and configuration center , The metadata center will not be available , Therefore, the official does not recommend such a configuration ;
  3. Officially recommended practice : In the configuration file, only admin.config-center, The value of this configuration is zookeeper Address , stay zookeeper There is a node in the service , The path is a /dubbo/config/dubbo/dubbo.properties, The content is admin.registry.address and admin.metadata-report.address Configuration of , As shown below :
dubbo.registry.address=zookeeper://127.0.0.1:2181
dubbo.metadata-report.address=zookeeper://127.0.0.1:2181
  1. In short , Only the address of the configuration center is placed in the local configuration file , wait until dubbo-admin After connecting to the configuration center , Get other configuration information from the configuration center , Draw a sketch to help understand , as follows :
     Insert picture description here
  2. Based on the above analysis , Let's go to zookeeper Create a good node in /dubbo/config/dubbo/dubbo.properties, In order to dubbo-admin Use , Please log in zookeeper Server , Get into zookeeper Of bin Catalog ;
  3. Because the previous article has used zookeeper As a registry , therefore "/dubbo/config/" The directory already exists , The following command creates /dubbo/config/dubbo node :
./zkCli.sh create /dubbo/config/dubbo ""
  1. To create a /dubbo/config/dubbo/dubbo.properties node :
./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"
  1. Last , See if it was created successfully , The input and response are as follows , Visible node created successfully , The value is also expected :
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
  1. thus , The preparatory work is all finished , You can deploy and try dubbo-admin 了 , Let's start with the official recommended quick experience , namely docker edition ;

Experience docker edition

  1. Please make sure docker Deployed and working properly ;
  2. official Github Recommended by docker Mirror quick experience management console , Here's the picture , Let's use... According to the official suggestion docker Try the mirror image :
     Insert picture description here
  3. Download mirroring ( This step may not be performed , I want to see how long it takes to download the image ):
docker pull apache/dubbo-admin
  1. Execute the following command to start docker Containers :
docker run \
-p 8083:8080 \
-e admin.config-center=zookeeper://192.168.50.43:2181 \
--rm \
apache/dubbo-admin
  1. The container started with the above command is one-time , If you use Ctrl+C Interrupt console , The container will be destroyed automatically , In addition, the container's 8080 The port is mapped to the host's 8083 port ;

  2. Access the host with a browser 8083 port , As shown in the figure below ,dubbo-admin It's already started :
     Insert picture description here

  3. Click on the red box below 1 Service query menu in , You can see all the exposed services in the entire distributed environment ( That's the red box 2), At this point, click on the right DETAIL Button , You can see the details of this service :
     Insert picture description here

  4. The service details are shown in the figure below , Basic information 、 Provider 、 Consumers have , Unfortunately, metadata cannot be displayed properly :
     Insert picture description here

  5. The above is the official version of the experience , Let's have a basic understanding of the management console , But it's just a mirror image of the experience , In the actual production environment , First of all, you may not be able to use docker, And may need to have the corresponding source code in order to learn and analyze the problem , It's even possible to do further customization with the source code , So the docker The version doesn't fit , Let's download it together dubbo-admin Self compilation and construction of source code ;

  6. Start up docker The container's console executes Ctrl+C, The container you just created will be destroyed automatically ;

Download the source code and build it yourself

  1. Download the official source code :
git clone https://github.com/apache/dubbo-admin.git
  1. Modify the configuration file dubbo-admin/dubbo-admin-server/src/main/resources/application.properties , As shown below , Configure only admin.registry.address Value , take admin.registry.address and admin.metadata-report.address Comment out , If you want to modify the port , Also add here server.port Configuration of , What I have here is 8083 port :
server.port=8083
# centers in dubbo2.7
#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
  1. stay dubbo-admin The directory executes the following commands , Start compilation :
mvn clean compile -U
  1. If there is no accident, it will compile successfully , as follows :
[INFO] --- maven-compiler-plugin:3.7.0:compile (default-compile) @ dubbo-admin-test ---
[INFO] Changes detected - recompiling the module!
[INFO] Compiling 6 source files to /Users/zhaoqin/temp/202010/24/dubbo-admin/dubbo-admin-test/target/classes
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Summary for dubbo-admin 0.2.0-SNAPSHOT:
[INFO]
[INFO] dubbo-admin ........................................ SUCCESS [  1.997 s]
[INFO] dubbo-admin-ui ..................................... SUCCESS [ 44.322 s]
[INFO] dubbo-admin-server ................................. SUCCESS [  4.731 s]
[INFO] dubbo-admin-distribution ........................... SUCCESS [  0.850 s]
[INFO] dubbo-admin-test ................................... SUCCESS [  0.815 s]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  53.105 s
[INFO] Finished at: 2020-10-25T16:24:27+08:00
[INFO] ------------------------------------------------------------------------
[WARNING] The requested profile "nexus" could not be activated because it does not exist.
  1. Start the service :
mvn --projects dubbo-admin-server spring-boot:run
  1. After successful startup , Visit the login page in the browser :http://localhost:8083/#/login ,( Be sure to log in first ), Here's the picture , The account and password are root, This is a application.properties Configured in the file :
     Insert picture description here
  2. After login, you can see the home page , Here's the picture , And before docker The experience version is still a little different :
     Insert picture description here
  3. Click the test button in the figure above , You can test the service on the page :
     Insert picture description here
  4. Go back to the service details page again , The metadata can also be displayed normally :
     Insert picture description here

Summary

thus , Administrative console dubbo-admin Compilation of 、 Deploy 、 The basic operations have been completed , More features on the web page you can try ,( It is recommended to deploy more services and instances ), Looking back on the whole process is actually very simple , The only thing to pay attention to is the configuration of the service , Local only configuration center address , Other information is in the configuration center ;

Welcome to the official account : Xinchen, programmer

WeChat search 「 Xinchen, programmer 」, I'm Xinchen , Looking forward to traveling with you Java The world …

版权声明
本文为[osc_cxi2ewsx]所创,转载请带上原文链接,感谢

Scroll to Top