久久久精品一区ed2k-女人被男人叉到高潮的视频-中文字幕乱码一区久久麻豆樱花-俄罗斯熟妇真实视频

SpringCloud怎么將EurekaServer集群化

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

十多年的武漢網(wǎng)站建設(shè)經(jīng)驗(yàn),針對(duì)設(shè)計(jì)、前端、開發(fā)、售后、文案、推廣等六對(duì)一服務(wù),響應(yīng)快,48小時(shí)及時(shí)工作處理。成都全網(wǎng)營(yíng)銷推廣的優(yōu)勢(shì)是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動(dòng)調(diào)整武漢建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無(wú)論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計(jì),從而大程度地提升瀏覽體驗(yàn)。創(chuàng)新互聯(lián)從事“武漢網(wǎng)站設(shè)計(jì)”,“武漢網(wǎng)站推廣”以來(lái),每個(gè)客戶項(xiàng)目都認(rèn)真落實(shí)執(zhí)行。

一、準(zhǔn)備工作

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通過(guò)運(yùn)行多個(gè)實(shí)例,使其更具有高可用性。事實(shí)上,這是它默認(rèn)的熟性,你需要做的就是給對(duì)等的實(shí)例一個(gè)合法的關(guān)聯(lián)serviceurl。

這篇文章我們基于第一篇文章的工程,來(lái)做修改。

二、改造工作

在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)建另外一個(gè)配置文件application-peer2.yml:

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

這時(shí)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)通過(guò)vim /etc/hosts ,加上:

127.0.0.1 peer1
127.0.0.1 peer2

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

這時(shí)需要改造下service-hi:

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

三、啟動(dòng)工程
啟動(dòng)eureka-server:

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

SpringCloud怎么將Eureka Server集群化

啟動(dòng)service-hi:

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

訪問(wèn):localhost:8761,如圖:

SpringCloud怎么將Eureka Server集群化

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

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

個(gè)人感受:這是通過(guò)看官方文檔的寫的demo ,但是需要手動(dòng)改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是通過(guò)設(shè)置ip讓eureka讓其他服務(wù)注冊(cè)它。也許能通過(guò)去改變?nèi)ネㄟ^(guò)改變host的方式。

此時(shí)的架構(gòu)圖:

SpringCloud怎么將Eureka Server集群化

Eureka-eserver peer1 8761,Eureka-eserver peer2 8769相互感應(yīng),當(dāng)有服務(wù)注冊(cè)時(shí),兩個(gè)Eureka-eserver是對(duì)等的,它們都存有相同的信息,這就是通過(guò)服務(wù)器的冗余來(lái)增加可靠性,當(dāng)有一臺(tái)服務(wù)器宕機(jī)了,服務(wù)并不會(huì)終止,因?yàn)榱硪慌_(tái)服務(wù)存有相同的數(shù)據(jù)。

到此,關(guān)于“SpringCloud怎么將Eureka Server集群化”的學(xué)習(xí)就結(jié)束了,希望能夠解決大家的疑惑。理論與實(shí)踐的搭配能更好的幫助大家學(xué)習(xí),快去試試吧!若想繼續(xù)學(xué)習(xí)更多相關(guān)知識(shí),請(qǐng)繼續(xù)關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編會(huì)繼續(xù)努力為大家?guī)?lái)更多實(shí)用的文章!

網(wǎng)站標(biāo)題:SpringCloud怎么將EurekaServer集群化
轉(zhuǎn)載來(lái)源:http://sd-ha.com/article8/popsip.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供手機(jī)網(wǎng)站建設(shè)、網(wǎng)站制作、網(wǎng)站排名、全網(wǎng)營(yíng)銷推廣、網(wǎng)站設(shè)計(jì)、用戶體驗(yàn)

廣告

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

搜索引擎優(yōu)化