Eureka集群搭建配置,如:
[root@centos7 discovery]# cat bootstrap-s1.yml
server:
port: 9000
spring:
application:
name: eureka-server
cloud:
inetutils:
preferredNetworks:
- 192.168
eureka:
instance:
hostname: s1
preferIpAddress: true
client:
serviceUrl:
defaultZone: http://s2:9001/eureka/,http://s3:9002/eureka/
[root@centos7 discovery]#
主要原理是交叉注册,最好3个以上(奇数个)实例。如果Eureka服务在同一台机器则会被认为非集群环境,可以通过在/etc/hosts中定义不同的主机模拟多主机环境,如:[root@centos7 discovery]# cat /etc/hosts
127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
::1 localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.10.76 s1
192.168.10.76 s2
192.168.10.76 s3
[root@centos7 discovery]#
分别运行三个实例,效果图如下:
