Eureka多機高可用


線上Eureka高可用集群,至少三個節點組成一個集群,推薦部署在不同的服務器上,IP用域名綁定,端口保持一致。

10.1.22.26:8762
10.1.22.27:8762
10.1.22.28:8762

1、Eureka服務端集群配置文件

#多服務器HA
spring:
  application:
    name: mima-cloud-eureka-ha
management:
  security:
    enabled: false
---
#啟動命令nohup java -jar mima-cloud-eureka-ha.jar --spring.profiles.active=peer1 &
server:
  port: 8762
spring:
  profiles: peer1
eureka:
  instance:
    hostname: localhost
    prefer-ip-address: true
    instance-id: ${spring.application.name}:${server.port}
  client:
    serviceUrl:
      defaultZone: http://10.1.22.27:8762/eureka/,http://10.1.22.28:8762/eureka/
---
#啟動命令nohup java -jar mima-cloud-eureka-ha.jar --spring.profiles.active=peer2 &
server:
  port: 8762
spring:
  profiles: peer2
eureka:
  instance:
    hostname: localhost
    prefer-ip-address: true
    instance-id: ${spring.application.name}:${server.port}
  client:
    serviceUrl:
      defaultZone: http://10.1.22.26:8762/eureka/,http://10.1.22.28:8762/eureka/
---
#啟動命令nohup java -jar mima-cloud-eureka-ha.jar --spring.profiles.active=peer3 &
server:
  port: 8762
spring:
  profiles: peer3
eureka:
  instance:
    hostname: localhost
    prefer-ip-address: true
    instance-id: ${spring.application.name}:${server.port}
  client:
    serviceUrl:
      defaultZone: http://10.1.22.26:8762/eureka/,http://10.1.22.27:8762/eureka/

 如何打包mima-cloud-eureka-ha.jar可執行文件,點擊此處查看

2、Eureka客戶端集群配置文件

debug: true
spring:
  application:
    name: mima-cloud-producer
server:
  port: 9906
eureka:
  instance:
    prefer-ip-address: true
    instance-id: ${spring.application.name}:${spring.cloud.client.ipAddress}:${server.port}
  client: 
    serviceUrl: 
      #如果需要使用主機名,則需要配置服務器的/etc/hosts文件
      defaultZone: http://10.1.22.26:8762/eureka/,http://10.1.22.27:8762/eureka/,http://10.1.22.28:8762/eureka/

 


免責聲明!

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



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