Dubbo+zookeeper build environment study notes

Dubbo Background and Introduction

Dubbo started with the e-commerce system, so let's start with the evolution of the e-commerce system.

1. Single application framework (ORM) 
When the website traffic is very small, only one application is needed, and all functions such as order payment are deployed together to reduce deployment nodes and costs. 
Disadvantages: The single system architecture makes more and more resources occupied during the development process, and becomes more and more difficult to maintain as the traffic increases 

2. Vertical Application Framework (MVC) The 
vertical application architecture solves the expansion problem faced by a single application architecture. The traffic can be dispersed among various subsystems, and the volume of the system is controllable, which reduces the collaboration and maintenance between developers to a certain extent. cost and improve development efficiency. 
Disadvantages: But in the vertical architecture, the same logic code needs to be copied continuously and cannot be reused.

3. Distributed application architecture (RPC) 
When there are more and more vertical applications, the interaction between applications is inevitable. The core business is extracted as an independent service, and a stable service center is gradually formed. 

4. 
With the further development of service-oriented architecture (SOA), there are more and more services, and the invocation and dependencies between services are becoming more and more complex. The service-oriented architecture system (SOA) was born, and thus derived A series of corresponding technologies have been developed, such as service frameworks that encapsulate behaviors such as service provision, service invocation, connection processing, communication protocols, serialization methods, service discovery, service routing, and log output.

 

    • single application architecture

      • When the website traffic is small, only one application is needed, and all functions are deployed together to reduce deployment nodes and costs.
      • At this point, a data access framework (ORM) that simplifies the CRUD workload is key.
    • Vertical Application Architecture

      • When the number of visits gradually increases, the acceleration brought by adding a single application to the machine is getting smaller and smaller, and the application is divided into several applications that are not related to each other to improve efficiency.
      • At this point, a web framework (MVC) for accelerating front-end page development is key.
    • Distributed Service Architecture 
      • When there are more and more vertical applications, the interaction between applications is inevitable. The core business is extracted as an independent service, and a stable service center is gradually formed, so that front-end applications can respond more quickly to changing market demands.
      • 此时,用于提高业务复用及整合的 分布式服务框架(RPC) 是关键。
    • 流动计算架构 
      • 当服务越来越多,容量的评估,小服务资源的浪费等问题逐渐显现,此时需增加一个调度中心基于访问压力实时管理集群容量,提高集群利用率。
      • 此时,用于提高机器利用率的 资源调度和治理中心(SOA) 是关键。

在这里插播一条关于RPC的简介: 
RPC(Remote Procedure Call Protocol):远程过程调用: 
两台服务器A、B,分别部署不同的应用a,b。当A服务器想要调用B服务器上应用b提供的函数或方法的时候,由于不在一个内存空间,不能直接调用,需要通过网络来表达调用的语义传达调用的数据。 
说白了,就是你在你的机器上写了一个程序,我这边是无法直接调用的,这个时候就出现了一个远程服务调用的概念。

RPC是一种通过网络从远程计算机程序上请求服务,而不需要了解底层网络技术的协议。RPC协议假定某些传输协议的存在,如TCP或UDP,为通信程序之间携带信息数据。在OSI网络通信模型中,RPC跨越了传输层和应用层。<br>RPC使得开发包括网络分布式多程序在内的应用程序更加容易。 RPC采用客户机/服务器模式。请求程序就是一个客户机,而服务提供程序就是一个服务器。首先,客户机调用进程发送一个有进程参数的调用信息到服务进程,然后等待应答信息。<br>在服务器端,进程保持睡眠状态直到调用信息到达为止。当一个调用信息到达,服务器获得进程参数,计算结果,发送答复信息,然后等待下一个调用信息,最后,客户端调用进程接收答复信息,获得进程结果,然后调用执行继续进行。

RPC需要解决的问题: 
(可以稍作了解,详情可查看别的博文)

    • 通讯问题 : 主要是通过在客户端和服务器之间建立TCP连接,远程过程调用的所有交换的数据都在这个连接里传输。连接可以是按需连接,调用结束后就断掉,也可以是长连接,多个远程过程调用共享同一个连接。
    • 寻址问题 : A服务器上的应用怎么告诉底层的RPC框架,如何连接到B服务器(如主机或IP地址)以及特定的端口,方法的名称名称是什么,这样才能完成调用。比如基于Web服务协议栈的RPC,就要提供一个endpoint URI,或者是从UDDI服务上查找。如果是RMI调用的话,还需要一个RMI Registry来注册服务的地址。
    • 序列化 与 反序列化 : 当A服务器上的应用发起远程过程调用时,方法的参数需要通过底层的网络协议如TCP传递到B服务器,由于网络协议是基于二进制的,内存中的参数的值要序列化成二进制的形式,也就是序列化(Serialize)或编组(marshal),通过寻址和传输将序列化的二进制发送给B服务器。 
      同理,B服务器接收参数要将参数反序列化。B服务器应用调用自己的方法处理后返回的结果也要序列化给A服务器,A服务器接收也要经过反序列化的过程。

以上理论都来自  http://blog.csdn.net/noaman_wgs/article/details/70214612 

 

正式安装步骤

一.zookeeper安装

1.下载zookeeper

  路径为http://www-eu.apache.org/dist/zookeeper/zookeeper-3.5.3-beta/

2.解压到指定目录下

3.解压后,将con文件夹下的zoo_sample.cfg拷贝一份,重命名为zoo.cfg

红色路径需要真实存在,不然可能报错。没有的话就去新建对应的文件路径

4.windows系统下会使用zkServer.cmd开启,所以在bin目录下找到zkServer.cmd,双击开启,我们可以看到他的端口为2181

注意这里还有一个端口8088被启用。

1
2
3
4
发现一个问题。
zookeeper最近的版本中有个内嵌的管理控制台是通过jetty启动,也会占用8080 端口。可能会跟你的Tomcat冲突。
修改端口的方法有两种,一种是在启动脚本中增加 -Dzookeeper.admin.serverPort=你的端口号.一种是在zoo.cfg中增加admin.serverPort=没有被占用的端口号。
也可以停用这个服务,在启动脚本中增加 "-Dzookeeper.admin.enableServer=false"

 插播一个查询端口占用情况,清除端口的方法

1
2
3
1. win + R,输入cmd回车进入dos界面
2. 输入netstat -ano|findstr 8080 查看占用8080端口的进程
3. 输入taskkill /pid 10148 /f 将显示的进程号(我的是10148)结束掉

二.dubbo安装  

1.下载dubbo源码

    源码地址为github上的地址,可以使用git或者直接下载压缩包.https://github.com/alibaba/dubbo/tree/2.5.x

2.下载完之后的目录结构,若是压缩包,就将压缩包解压

3.在当前目录下打开命令窗口,使用命令mvn clean install -Dmaven.test.skip=true构建dubbo源码(要安装maven哟)

4.构建完成之后,找到上图中dubbo-admin下target文件夹中的war包,将其拷贝到本地的tomcat的webapps下

 

测试环境搭建是否成功

     先启动zk,然后启动tomcat,此时会看到两个dos窗口中信息滚动特快,特炫酷.待tomcat启动完毕之后,在浏览器中输入地址.提前说明,

我拷贝到tomcat-->webapps下的dubbo-admin的war包我改名为了dubbo-admin.war,如下图所示,我的tomcat端口号是8080,在浏览其中输入地址http://localhost:8080/dubbo-admin/回车,

输入用户名和密码,用户名和密码均为root,这时候就会看到dubbo控制台,如下图.

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325935973&siteId=291194637