
Dubbo提供的注册中心
- Multicast注册中心
- Zookeeper注册中心
- Redis注册中心
- Simple注册中心
Zookeeper注册中心
简介
安装
步骤一:上传zookeeper-3.3.6.tar.gz
步骤二:解压到指定的文件夹中(本人解压到/usr/local/soft下)
步骤三:安装目录下conf/zoo_sample.cfg重命名zoo.cfg
# The number of milliseconds of each tick
tickTime=2000
# The number of ticks that the initial
# synchronization phase can take
initLimit=10
# The number of ticks that can pass between
# sending a request and getting an acknowledgement
syncLimit=5
# the directory where the snapshot is stored.
# do not use /tmp for storage, /tmp here is just
# example sakes.
dataDir=/usr/local/soft/zookeeper-3.3.6/data
dataLogDir=/usr/local/soft/zookeeper-3.3.6/log
# the port at which the clients will connect
clientPort=2181
# the maximum number of client connections.
# increase this if you need to handle more clients
#maxClientCnxns=60
#
# Be sure to read the maintenance section of the
# administrator guide before turning on autopurge.
#
# http://zookeeper.apache.org/doc/current/zookeeperAdmin.html#sc_maintenance
#
# The number of snapshots to retain in dataDir
#autopurge.snapRetainCount=3
# Purge task interval in hours
# Set to "0" to disable auto purge feature
#autopurge.purgeInterval=1
启动
- 启动ZK服务: sh bin/zkServer.sh start
- 停止ZK服务: sh bin/zkServer.sh stop
- 重启ZK服务: sh bin/zkServer.sh restart
- 查看ZK服务状态: sh bin/zkServer.sh status
验证
[root@iz2ze0h59yk0rf0sem4w0pz ~]# jps
27819 QuorumPeerMain
28603 Jps
dubbo-admin
简介
配置
步骤一:下载dubbo地址
步骤二:进入下载源码的dubbo-admin下,进行打包处理
mvn package -Dmaven.skip.test=true
注意:此处有可能打包失败,我的解决方式是翻墙重新打包!
步骤三:修改tomcat的端口,记得一定要改!!!
步骤四:将第二步中打的dubbo-admin-2.5.8.war放入到tomcat的webapps目录中。
步骤五:启动tomcat服务器(此时如果不是本地的zookeeper,会报错)
步骤六:修改\webapps\dubbo-admin-2.5.8\WEB-INF文件夹下的dubbo.properties文件。
dubbo.registry.address=zookeeper://39.106.44.170:2181 (注意:此处是zookeeper协议)
dubbo.admin.root.password=root
dubbo.admin.guest.password=guest
步骤七:重新启动tomcat服务器
步骤八:访问地址:http://localhost:9080/dubbo-admin-2.5.8/

applications.properties 配置清单
Dubbo基础配置
服务提供者常用配置
添加maven依赖
<dependency>
<groupId>io.dubbo.springboot</groupId>
<artifactId>spring-boot-starter-dubbo</artifactId>
<version>1.0.0</version>
</dependency>
配置dubbo
server.port=3333
spring.dubbo.application.name=provider
spring.dubbo.registry.address=zookeeper://192.168.99.100:32770
spring.dubbo.protocol.name=dubbo
spring.dubbo.protocol.port=20880
spring.dubbo.scan=com.top.guod.dubbo
编写Dubbo服务
@Service(version = "1.0.0")
public class UserServiceImpl implements UserServcieI{
}
服务消费者常用配置
添加maven依赖
<dependency>
<groupId>io.dubbo.springboot</groupId>
<artifactId>spring-boot-starter-dubbo</artifactId>
<version>1.0.0</version>
</dependency>
配置dubbo
spring.dubbo.application.name=consumer
spring.dubbo.registry.address=zookeeper://192.168.99.100:32770
spring.dubbo.scan=cn.teaey.sprintboot.test
引用Dubbo服务
@Component
public class AbcService {
@Reference(version = "1.0.0")
public EchoService echoService;
}
项目源码地址
- GitHub地址:https://github.com/s121528
- 码云地址:https://gitee.com/sunguo
网友评论