线上Eureka高可用集群,至少三个节点组成一个集群,推荐部署在不同的服务器上,IP用域名绑定,端口保持一致。
10.1.22.26:876210.1.22.27:876210.1.22.28:8762
1、Eureka服务端集群配置文件
#多服务器HAspring: application: name: mima-cloud-eureka-hamanagement: security: enabled: false---#启动命令nohup java -jar mima-cloud-eureka-ha.jar --spring.profiles.active=peer1 &server: port: 8762spring: profiles: peer1eureka: 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: 8762spring: profiles: peer2eureka: 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: 8762spring: profiles: peer3eureka: 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: truespring: application: name: mima-cloud-producerserver: port: 9906eureka: 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/