Dubbo的应用
导语:Dubbo是阿里巴巴的一个分布式服务的开源框架,致力于提供高性能和透明化的RPC远程服务调用方案,是阿里巴巴SOA服务化治理方案的核心框架,每天为2,000+个服务提供3,000,000,000+次访问量支持,并被广泛应用于阿里巴巴集团的各成员站点。
- dubbo.registry.address=zookeeper://127.0.0.1:2181
- dubbo.admin.root.password=root
- dubbo.admin.guest.password=guest
| # 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=/home/xudan/zookeeper-3.4.6/data #myid文件存放的路径 dataLogDir=/home/xudan/zookeeper-3.4.6/logs #日志存放路径 # 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 server.1=Master:2555:3555 server.2=Slave1:2556:3556 server.3=Slave2:2557:3557 |
mkdir data
mkdir logs
touch /data/myid
echo 1 > /home/lgp/ zookeeper-3.4.6/data/myid //设置myid的值为1
yum -y install openssh-clients
修改对应 myid ,etc/hosts
scp /home/lgp/zookeeper-3.4.6 192.168.1.81:/home/lgp //跨机器复制
启动服务:
service iptables stop:分别关闭对应机器的 iptables
cd /home/lgp/zookeeper-3.4.6/bin
./bin/zkServer.sh start :开启zookeeper
./bin/zkServer.sh status :状态查询
./bin/zkServer.sh stop :关闭zookeeper
vi dubbo.properties
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
<version>2.5.3</version>
</dependency>
<!-- Zookeeper 用于分布式服务管理 -->
<dependency>
<groupId>org.apache.zookeeper</groupId>
<artifactId>zookeeper</artifactId>
<version>3.4.5</version>
</dependency>
<dependency>
<groupId>com.101tec</groupId>
<artifactId>zkclient</artifactId>
<version>0.3</version>
</dependency>
<!-- Zookeeper 用于分布式服务管理 end -->

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns: dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://code.alibabatech.com/schema/dubbo
http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
<dubbo:application name="guduo-service-user" />
<!-- 使用zookeeper注册中心暴露服务地址 -->
<dubbo:registry protocol="zookeeper" address="${dubbo.registry.address}" />
<!—本机 -->
<dubbo:protocol name="dubbo" port="20823" />
<!-- 监控中心配置,protocol="registry",表示从注册中心发现监控中心地址 -->
<dubbo:monitor protocol="registry"/>
<!-- 当ProtocolConfig和ServiceConfig某属性没有配置时,采用此缺省值 -->
<dubbo:provider timeout="30000" threadpool="fixed" threads="100" accepts="1000" />
<!-- 服务接口 -->
<dubbo:service retries="0" interface="com.guduo.service.system.UserReportService" ref="userReportService" />
<dubbo:service retries="0" interface="com.guduo.service.system.UserSuggestionService" ref="userSuggestionService" />
</beans>

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo="http://code.alibabatech.com/schema/dubbo"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://code.alibabatech.com/schema/dubbo
http://code.alibabatech.com/schema/dubbo/dubbo.xsd">
<!-- 消费方应用名,用于计算依赖关系,不是匹配条件,不要与提供方一样 -->
<dubbo:application name="guduo-web-publish" />
<!-- 使用zookeeper注册中心暴露服务地址 -->
<!-- 注册中心地址 -->
<dubbo:registry protocol="zookeeper" address="${dubbo.registry.address}" />
<!-- 用户服务接口 -->
<dubbo:reference interface="com.guduo.service.user.PmsActionService" id="pmsActionService" check="false"/>
<dubbo:reference interface="com.guduo.service.user.PmsMenuService" id="pmsMenuService" check="false"/>
</beans>
import org.apache.commons.logging.LogFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
*
* @描述: 启动Dubbo服务用的MainClass.
* @作者: 刘广平
* @创建时间: 2016-9-5,下午9:47:55 .
* @版本: 1.0 .
*/
public class DubboProvider {
private static final Log log = LogFactory.getLog(DubboProvider.class);
public static void main(String[] args) {
try {
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("classpath:spring/spring-context.xml");
context.start();
} catch (Exception e) {
log.error("== DubboProvider context start error:",e);
}
synchronized (DubboProvider.class) {
while (true) {
try {
DubboProvider.class.wait();
} catch (InterruptedException e) {
log.error("== synchronized error:",e);
}
}
}
}
}
Dubbo的应用的更多相关文章
- 用dubbo时遇到的一个序列化的坑
首先,这是标题党,问题并不是出现在序列化上,这是报错的一部分: Caused by: com.alibaba.dubbo.remoting.RemotingException: Failed to s ...
- dubbo服务提供与消费
一.前言 项目中用到了Dubbo,临时抱大腿,学习了dubbo的简单实用方法.现在就来总结一下dubbo如何提供服务,如何消费服务,并做了一个简单的demo作为参考. 二.Dubbo是什么 Dubbo ...
- 分布式学习系列【dubbo入门实践】
分布式学习系列[dubbo入门实践] dubbo架构 组成部分:provider,consumer,registry,monitor: provider,consumer注册,订阅类似于消息队列的注册 ...
- Maven多模块,Dubbo分布式服务框架,SpringMVC,前后端分离项目,基础搭建,搭建过程出现的问题
现互联网公司后端架构常用到Spring+SpringMVC+MyBatis,通过Maven来构建.通过学习,我已经掌握了基本的搭建过程,写下基础文章为而后的深入学习奠定基础. 首先说一下这篇文章的主要 ...
- Dubbo 备注
Dubbo是阿里开源的一款服务治理中间件,主要包含如下节点: Provider: 暴露服务的服务提供方. Consumer: 调用远程服务的服务消费方. Registry: 服务注册与发现的注册中心. ...
- Dubbo学习小记
前言 周一入职的新公司,到了公司第一件事自然是要熟悉新公司使用的各种技术,搭建本地的环境. 熟悉新公司技术的过程中,首先就是Maven,这个前面已经写过文章了,然后就是Dubbo----公司的服务都是 ...
- Running Dubbo On Spring Boot
Dubbo(http://dubbo.io/) 是阿里的开源的一款分布式服务框架.而Spring Boot则是Spring社区这两年致力于打造的简化Java配置的微服务框架. 利用他们各自优势,配置到 ...
- 【转】Dubbo使用例子并且和Spring集成使用
一.编写客户端和服务器端共用接口类1.登录接口类public interface LoginService { public User login(String name, String psw ...
- 基于SOA分布式架构的dubbo框架基础学习篇
以需求用例为基,抽象接口,Case&Coding两条线并行,服务(M)&消费(VC)分离,单元.接口.功能.集成四层质量管理,自动化集成.测试.交付全程支持. 3个大阶段(需求分析阶段 ...
- dubbo连接zookeeper注册中心因为断网导致线程无限等待问题【转】
最近维护的系统切换了网络环境,由联通换成了电信网络,因为某些过滤规则导致系统连不上zookeeper服务器(应用系统机器在深圳,网络为电信线路,zookeeper服务器在北京,网络为联通线路),因为我 ...
随机推荐
- Asp.net内置对象用途说明
Asp.net 内置对象 1.Session当客户第一次请求网页,session创建.当客户最后一次请求页面,一段时间后,session销毁.默认30分钟. 一般存用户信息,即登陆成功后,在sessi ...
- [BZOJ2392][HAOI2011]Problem c
Description 给n个人安排座位,先给每个人一个1~n的编号,设第i个人的编号为ai(不同人的编号可以相同),接着从第一个人开始,大家依次入座,第i个人来了以后尝试坐到ai,如果ai被占据了, ...
- linux-scp命令及如何设置免密登录
部署测试环境时经常在两台服务器间copy文件,那么如何设置免密登录? 场景:源服务器A(如172) -> 目标服务器B(如71) 实现将服务器A的文件copy到服务器B 实现方式有两种: 在源 ...
- robotframework+ride+python3环境搭建
一.windows下安装python3.6 1.官网下载安装包https://www.python.org/downloads/windows/ 2.进行安装,接下来步骤一直next即可 二.cmd下 ...
- python编程系列---tcp服务端的简单实现
流程如下: """tcp服务端创建流程1. 创建服务端的tcp socket : server_socket 用于监听客户端的请求2. 绑定端口3. server_soc ...
- leetcode 刷500道题,笔试/面试稳过吗?谈一谈这些年来算法的学习
想要学习算法.应付笔试或者应付面试手撕算法题,相信大部分人都会去刷 Leetcode,有读者问?如果我在 leetcode 坚持刷它个 500 道题,以后笔试/面试稳吗? 这里我说下我的个人看法,我认 ...
- 使用Jersey构建图片服务器
使用Jersey构建图片服务器 前台页面代码 <form id="jvForm" action="add.do" method="post&qu ...
- WebStorm 使用过程中出现的一些问题以及解决方案
标签: WebStorm 配置 描述: 有关 WebStorm 使用过程中出现的一些问题以及其解决方案的汇总 "unresolved function or method" 问题描 ...
- MongoDB系列---入门安装操作
MongoDB 学习大纲: 1.MongoDB简介与其它数据库对比以及数据类型 2.MongoDB安装 3.MongoDB简单操作 环境要求: Linux 一.MongoDB简介 1 什么是Mongo ...
- codeforce -14A A. Letter
A. Letter time limit per test 1 second memory limit per test 64 megabytes input standard input outpu ...