内射老阿姨1区2区3区4区_久久精品人人做人人爽电影蜜月_久久国产精品亚洲77777_99精品又大又爽又粗少妇毛片

SpringCloud怎么將EurekaServer集群化-創(chuàng)新互聯(lián)

這篇文章主要介紹“SpringCloud怎么將Eureka Server集群化”,在日常操作中,相信很多人在SpringCloud怎么將Eureka Server集群化問題上存在疑惑,小編查閱了各式資料,整理出簡單好用的操作方法,希望對大家解答”SpringCloud怎么將Eureka Server集群化”的疑惑有所幫助!接下來,請跟著小編一起來學習吧!

成都創(chuàng)新互聯(lián)公司專注于企業(yè)網(wǎng)絡營銷推廣、網(wǎng)站重做改版、偏關網(wǎng)站定制設計、自適應品牌網(wǎng)站建設、H5響應式網(wǎng)站、電子商務商城網(wǎng)站建設、集團公司官網(wǎng)建設、外貿(mào)網(wǎng)站建設、高端網(wǎng)站制作、響應式網(wǎng)頁設計等建站業(yè)務,價格優(yōu)惠性價比高,為偏關等各大城市提供網(wǎng)站開發(fā)制作服務。

一、準備工作

Eureka can be made even more resilient and available by running multiple instances and asking them to register with each other. Infact, this is the default behaviour, so all you need to do to make it work is add a valid serviceUrl to a peer, e.g.——摘自官網(wǎng)

Eureka通過運行多個實例,使其更具有高可用性。事實上,這是它默認的熟性,你需要做的就是給對等的實例一個合法的關聯(lián)serviceurl。

這篇文章我們基于第一篇文章的工程,來做修改。

二、改造工作

在eureka-server工程中resources文件夾下,創(chuàng)建配置文件application-peer1.yml:

server:
  port: 8761
spring:
  profiles: peer1
eureka:
  instance:
    hostname: peer1
  client:
    serviceUrl:
      defaultZone: http://peer2:8769/eureka/

并且創(chuàng)建另外一個配置文件application-peer2.yml:

server:
  port: 8769
spring:
  profiles: peer2
eureka:
  instance:
    hostname: peer2
  client:
    serviceUrl:
      defaultZone: http://peer1:8761/eureka/

這時eureka-server就已經(jīng)改造完畢。

ou could use this configuration to test the peer awareness on a single host (there’s not much value in doing that in production) by manipulating /etc/hosts to resolve the host names.

按照官方文檔的指示,需要改變etc/hosts,linux系統(tǒng)通過vim /etc/hosts ,加上:

127.0.0.1 peer1
127.0.0.1 peer2

windows電腦,在c:/windows/systems/drivers/etc/hosts 修改。

這時需要改造下service-hi:

eureka:
  client:
    serviceUrl:
      defaultZone: http://peer1:8761/eureka/
server:
  port: 8762
spring:
  application:
    name: service-hi

三、啟動工程
啟動eureka-server:

java -jar eureka-server-0.0.1-SNAPSHOT.jar --spring.profiles.active=peer1

SpringCloud怎么將Eureka Server集群化

啟動service-hi:

java -jar service-hi-0.0.1-SNAPSHOT.jar

訪問:localhost:8761,如圖:

SpringCloud怎么將Eureka Server集群化

你會發(fā)現(xiàn)注冊了service-hi,并且有個peer2節(jié)點,同理訪問localhost:8769你會發(fā)現(xiàn)有個peer1節(jié)點。

client只向8761注冊,但是你打開8769,你也會發(fā)現(xiàn),8769也有 client的注冊信息。

個人感受:這是通過看官方文檔的寫的demo ,但是需要手動改host是不是不符合Spring Cloud 的高上大?

Prefer IP Address

In some cases, it is preferable for Eureka to advertise the IP Adresses of services rather than the hostname. Set eureka.instance.preferIpAddress to true and when the application hostname.——摘自官網(wǎng)

eureka.instance.preferIpAddress=true是通過設置ip讓eureka讓其他服務注冊它。也許能通過去改變?nèi)ネㄟ^改變host的方式。

此時的架構圖:

SpringCloud怎么將Eureka Server集群化

Eureka-eserver peer1 8761,Eureka-eserver peer2 8769相互感應,當有服務注冊時,兩個Eureka-eserver是對等的,它們都存有相同的信息,這就是通過服務器的冗余來增加可靠性,當有一臺服務器宕機了,服務并不會終止,因為另一臺服務存有相同的數(shù)據(jù)。

到此,關于“SpringCloud怎么將Eureka Server集群化”的學習就結束了,希望能夠解決大家的疑惑。理論與實踐的搭配能更好的幫助大家學習,快去試試吧!若想繼續(xù)學習更多相關知識,請繼續(xù)關注創(chuàng)新互聯(lián)-成都網(wǎng)站建設公司網(wǎng)站,小編會繼續(xù)努力為大家?guī)砀鄬嵱玫奈恼拢?/p>

本文名稱:SpringCloud怎么將EurekaServer集群化-創(chuàng)新互聯(lián)
URL鏈接:http://www.rwnh.cn/article16/dosigg.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供移動網(wǎng)站建設、網(wǎng)站營銷、App設計標簽優(yōu)化、微信公眾號、動態(tài)網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯(lián)

網(wǎng)站建設網(wǎng)站維護公司
嵩明县| 潮州市| 丁青县| 宜都市| 昌图县| 通化县| 嘉禾县| 达尔| 河津市| 陈巴尔虎旗| 中阳县| 安顺市| 青阳县| 胶南市| 临安市| 吉木萨尔县| 扬中市| 孟津县| 建始县| 彭泽县| 丹东市| 太和县| 高雄市| 曲水县| 罗定市| 尼玛县| 高唐县| 北辰区| 视频| 慈溪市| 眉山市| 洛隆县| 永善县| 罗源县| 文昌市| 吉安市| 泊头市| 尼勒克县| 红原县| 裕民县| 西和县|