zoukankan      html  css  js  c++  java
  • dubbo服务治理中间件,zookeeper注册中心 安装配置

    对传统项目架构进行拆分:


     集群概念:


    面向服务分布式架构:

    服务层提供被注册的对象需要实现序列化接口Serializable;


    配置表现层和服务层:

      依赖包:

      服务层:

     1 <!-- 定义dubbo服务名称,此名称可以自定义,用于监控中心监控服务关系 -->
     2     <dubbo:application name="content-service" />
     3     <!-- 使用dubbo通过Zookeeper协议注册服务 -->
     4     <dubbo:registry protocol="zookeeper" address="192.168.74.132:2181" />
     5     <!-- 用dubbo协议在20880端口暴露服务 -->
     6     <dubbo:protocol name="dubbo" port="20881" />
     7     <!-- 声明需要暴露的服务接口 -->
     8     <!-- 创建需要发布对象 -->
     9     <bean id="contentCategoryServiceImpl" class="cn.e3.content.service.impl.ContentCategoryServiceImpl"></bean>
    10     <!-- 发布服务 -->
    11     <dubbo:service interface="cn.e3.content.service.ContentCategoryService"
    12         ref="contentCategoryServiceImpl" />
    13     <!-- 发布内容对象 -->
    14     <bean id="contentServiceImpl" class="cn.e3.content.service.impl.ContentServiceImpl"></bean>
    15     <!-- 发布服务 -->
    16     <dubbo:service interface="cn.e3.content.service.ContentService"
    17         ref="contentServiceImpl" />

      表现层:

     1 <!-- 消费方应用名,用于计算依赖关系,不是匹配条件,不要与提供方一样 -->
     2     <dubbo:application name="manager-web" />
     3     <!-- 使用multicast广播注册中心暴露发现服务地址 -->
     4     <dubbo:registry address="zookeeper://192.168.74.132:2181" />
     5     <!-- 生成远程服务代理,可以和本地bean一样使用demoService -->
     6     <dubbo:reference id="itemService"
     7         interface="cn.e3.manager.service.ItemService" timeout="1000000" retries="2"/>
     8     <!-- 商品类别服务 -->
     9     <dubbo:reference id="itemCatService"
    10         interface="cn.e3.manager.service.ItemCatService" timeout="1000000" retries="2"/>
    11     <!-- 广告分类服务 -->
    12     <dubbo:reference id="contentCategoryService"
    13         interface="cn.e3.content.service.ContentCategoryService" timeout="1000000" retries="2"/>
    14     <!-- 广告内容服务 -->
    15     <dubbo:reference id="contentService"
    16         interface="cn.e3.content.service.ContentService" timeout="1000000" retries="2"/>
    17     <!-- 规格模板服务 -->
    18     <dubbo:reference id="itemParamService"
    19         interface="cn.e3.manager.service.ItemParamService" timeout="1000000" retries="2"/>
    20     <dubbo:reference id="searchItemService"
    21         interface="cn.e3.search.service.SearchItemService" timeout="1000000" retries="2"/>

     安装zookeeper注册中心服务器:cd zookeeper/conf,mv zoo_sample.cfg zoo.cfg

    配置:vim zoo.cfg

    cd ./data ; vi myid (内容为各个节点server后的数字)

    启动和登录:

    查看节点状态:./zkServer.sh status 同时检测zookeeper是否启动成功

    日志查看:cat ./zookeeper.out

    查看启动:jps

     查看节点信息:ls /      ls /dubbo     ls /zookeeper


    Monitor 监控中心,dubbo-admin-2.5.4.war部署在linux上的tomcat即可;

    访问:ip:8080/dubbo/
    root root


     总结:

     

  • 相关阅读:
    HUST第八届程序设计竞赛-G小乐乐打游戏(双bfs)
    HDU-1575-Tr A(矩阵快速幂模板)
    HDU-1061-Rightmost Digit (快速幂模板)
    HihoCoder 1142-三分求极值(三分模板)
    Aizu ITP2_6_A(二分模板)
    Codeforces-938D-Buy a Ticket(最短路设虚拟节点+Dijk优先队列优化)
    POJ-1797-Heavy Transportation(最短路变形)
    HDU-5137-How Many Maos Does the Guanxi Worth(最短路删点)
    POJ-1094-Sorting It All Out (拓扑排序)(判断环和排名是否唯一)
    HDU-1869-六度分离(多源到多源最短路)
  • 原文地址:https://www.cnblogs.com/mryangbo/p/8046168.html
Copyright © 2011-2022 走看看