eureka高可用性配置

1 .单机的profile 配置application.yml

spring:
  application:
    name: eureka-server
    
server:
  port: 2001
  
eureka:
  server:
    enable-self-preservation: false
  instance:
    hostname: eureka
  client:          #这个配置是集群互相获取注册信息的配置。
    register-with-eureka: false
    fetch-registry: false
    service-url: 
     defaultZone: http://localhost:2001/eureka

 

2.如果是双机配置的话.

 

spring:
  application:
    name: eureka-server
    
#server:
#  port: 2001
  
eureka:
  server:
    enable-self-preservation: false instance: prefer-ip-address: true # instance: # hostname: eureka1 # client: # register-with-eureka: false # fetch-registry: false --- spring: profiles: eureka1 server: port: 2001 eureka: instance: hostname: eureka1 client: service-url: defaultZone: http://eureka2:2002/eureka --- spring: profiles: eureka2 server: port: 2002 eureka: instance: hostname: eureka2 client: service-url: defaultZone: http://eureka1:2001/eureka 

 

2.配置启动项1

eureka高可用性配置_第1张图片

 

 2. 第二台的启动项

eureka高可用性配置_第2张图片

 

 eureka高可用性配置_第3张图片

 

 

Itemservice 高可用性.

单机模式

spring:
  application:
    name: user-service
    
server:
  port: 8101
  
eureka:
  client:
    service-url: 
      defaultZone: http://eureka1:2001/eureka, http://eureka2:2002/eureka
  

 

双机模式

spring:
  application:
    name: item-service

    
#server:
#  port: 8001
  
eureka:
  client:
    service-url: 
      defaultZone: http://eureka1:2001/eureka, http://eureka2:2002/eureka
      
---
spring:
  profiles: item1
  
server:
  port: 8001

---
spring:
  profiles: item2
  
server:
  port: 8002
  

 

 

规范

你可能感兴趣的:(eureka高可用性配置)