
文章插圖
通過(guò)瀏覽器再次訪問(wèn):http://localhost:8761/,出現(xiàn)兩個(gè)實(shí)例

文章插圖
在線擴(kuò)充到三個(gè) Eureka 實(shí)例同理,維持上述運(yùn)行實(shí)例,先不要做任何重啟動(dòng)作,修改 eureka-client.yml 配置,讓客戶端感知到三個(gè)實(shí)例
server:port: 8081spring:application:name: eureka-client1eureka:client:serviceUrl:defaultZone: http://localhost:8761/eureka/,http://localhost:8762/eureka/,http://localhost:8763/eureka/修改 peer1 的配置server:port: 8761spring:application:name: eureka-servereureka:instance:hostname: localhostpreferIpAddress: trueclient:registerWithEureka: truefetchRegistry: trueserviceUrl:defaultZone: http://localhost:8762/eureka/,http://localhost:8763/eureka/server:waitTimeInMsWhenSyncEmpty: 0enableSelfPreservation: false使得 peer1 可以感知到另外兩個(gè)實(shí)例,同理,修改 peer2 實(shí)例配置server:port: 8762eureka:instance:hostname: localhostpreferIpAddress: trueclient:registerWithEureka: truefetchRegistry: trueserviceUrl:defaultZone: http://localhost:8761/eureka/,http://localhost:8763/eureka/server:waitTimeInMsWhenSyncEmpty: 0enableSelfPreservation: false修改 peer3 實(shí)例配置server:port: 8763eureka:instance:hostname: localhostpreferIpAddress: trueclient:registerWithEureka: truefetchRegistry: trueserviceUrl:defaultZone: http://localhost:8761/eureka/,http://localhost:8762/eureka/server:waitTimeInMsWhenSyncEmpty: 0enableSelfPreservation: false接下來(lái),重啟配置中,即 config 模塊然后,啟動(dòng)第三個(gè)實(shí)例,profile 指定 peer3

文章插圖
然后,使用 Eureka 的管理 API,刷新 peer1,peer2 的配置信息

文章插圖

文章插圖
再次通過(guò)瀏覽器訪問(wèn):http://localhost:8761/

文章插圖
出現(xiàn)三個(gè)實(shí)例,擴(kuò)容成功 。
完整代碼見:Github
參考資料重新定義 Spring Cloud 實(shí)戰(zhàn)
經(jīng)驗(yàn)總結(jié)擴(kuò)展閱讀
- React實(shí)現(xiàn)一個(gè)簡(jiǎn)易版Swiper
- 四十七 SpringCloud微服務(wù)實(shí)戰(zhàn)——搭建企業(yè)級(jí)開發(fā)框架:【移動(dòng)開發(fā)】整合uni-app搭建移動(dòng)端快速開發(fā)框架-添加Axios并實(shí)現(xiàn)登錄功能
- 二 SpringCloud - Eureka注冊(cè)中心,feign遠(yuǎn)程調(diào)用,hystrix降級(jí)和熔斷
- 【Serverless】云函數(shù)微信小程序
- 二 京東云開發(fā)者| Redis數(shù)據(jù)結(jié)構(gòu)-List、Hash、Set及Sorted Set的結(jié)構(gòu)實(shí)現(xiàn)
- 一 Redis數(shù)據(jù)結(jié)構(gòu)-Redis的數(shù)據(jù)存儲(chǔ)及String類型的實(shí)現(xiàn)
- Springboot 一行代碼實(shí)現(xiàn)文件上傳 20個(gè)平臺(tái)!少寫代碼到極致
- C#實(shí)現(xiàn)生成Markdown文檔目錄樹
- 利用inotify和rsync服務(wù)實(shí)現(xiàn)數(shù)據(jù)實(shí)時(shí)同步
- OpenAPI 接口冪等實(shí)現(xiàn)
