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


 總結:

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM