当前位置: 首页>后端>正文

微服务与 dubbo

生产者消费者都要安装java
apt -y install openjdk-8-jdk

部署节点10.0.0.114
生产者示例,填写zookeeper的地址
root@provider:opt# mkdir /apps
root@provider:opt# cd /apps/
root@provider:apps# ls
dubbo-demo-provider-2.1.5-assembly.tar.gz
root@provider:apps# tar xf dubbo-demo-provider-2.1.5-assembly.tar.gz
root@provider:apps# cd dubbo-demo-provider-2.1.5/
root@provider:dubbo-demo-provider-2.1.5# egrep -v "#|^$" conf/dubbo.properties
dubbo.container=log4j,spring
dubbo.application.name=demo-provider
dubbo.application.owner=
dubbo.registry.address=zookeeper://10.0.0.111:2181 | zookeeper://10.0.0.112:2181 | zookeeper://10.0.0.113:2181
dubbo.monitor.protocol=registry
dubbo.protocol.name=dubbo
dubbo.protocol.port=20880
dubbo.log4j.file=logs/dubbo-demo-provider.log
dubbo.log4j.level=WARN

启动 provider

root@provider:dubbo-demo-provider-2.1.5# ./bin/start.sh

部署节点10.0.0.115
消费者示例
root@consumer:~# mkdir /apps
root@consumer:~# cd /apps/
root@consumer:apps# ls
dubbo-demo-consumer-2.1.5-assembly.tar.gz
root@consumer:apps# tar xf dubbo-demo-consumer-2.1.5-assembly.tar.gz
root@consumer:apps# cd dubbo-demo-consumer-2.1.5/
root@consumer:dubbo-demo-consumer-2.1.5# egrep -v "#|^$" conf/dubbo.properties
dubbo.container=log4j,spring
dubbo.application.name=demo-consumer
dubbo.application.owner=
dubbo.registry.address=zookeeper://10.0.0.111:2181 | zookeeper://10.0.0.112:2181 | zookeeper://10.0.0.113:2181
dubbo.monitor.protocol=registry
dubbo.log4j.file=logs/dubbo-demo-consumer.log
dubbo.log4j.level=WARN

启动 consumer

root@consumer:dubbo-demo-consumer-2.1.5# ./bin/start.sh

部署节点复用zookeeper10.0.0.111节点
dubbo admin:
基于 zookeeper 发现并管理 provider 和 consumer。
先部署tomcat,把dubboadmin.war包传进tomcat
root@mq-server1:~# mkdir /apps
root@mq-server1:~# cd /apps/
root@mq-server1:apps# ls
apache-tomcat-9.0.59.tar.gz install_tomcat.sh kafka kafka_2.13-2.8.2 zookeeper zookeeper-3.4.13 zookeeper-3.4.13.tar.gz
root@mq-server1:apps# tar xf apache-tomcat-9.0.59.tar.gz
root@mq-server1:apache-tomcat-9.0.59# cd /apps/apache-tomcat-9.0.59/webapps/
root@mq-server1:webapps# ls
docs dubboadmin.war examples host-manager manager ROOT
root@mq-server1:webapps# unzip dubboadmin.war
root@mq-server1:webapps# cat ./dubboadmin/WEB-INF/dubbo.properties
dubbo.registry.address=zookeeper://10.0.0.111:2181 | zookeeper://10.0.0.112:2181 | zookeeper://10.0.0.113:2181
dubbo.admin.root.password=root
dubbo.admin.guest.password=guest
启动tomcat
root@mq-server1:webapps# /apps/apache-tomcat-9.0.59/bin/catalina.sh start
访问账号密码都是root
http://10.0.0.111:8080/dubboadmin/


https://www.xamrdz.com/backend/3qx1929102.html

相关文章: