9.1.3  基于Host的高可用Eureka

更新于 2026年10月13日 版权声明
9.1.3 基于Host的高可用Eureka

基于Host进行Eureka的高可用配置,需要提供多个可以解析的Host地址,在Eureka集群中的不同Eureka实例中使用不同的Host地址作为hostname,并且在各自服务的defaultZone中配置其他Eureka服务的地址。

例如配置两台Eureka服务的集群,其中服务A的hostname为eureka-serverA,defaultZone地址为http://eureka-serverB:18002/eureka/;服务B的hostname为eureka-serverB,defaultZone地址为http://eureka-serverA:18001/eureka/。然后在业务服务的defaultZone中配置两台Eureka服务的地址即可。

(1)配置Host解析

在服务器的hosts文件中,使用正确的IP地址配置host解析。

172.17.238.237 eureka-serverA

172.17.238.237 eureka-serverB

(2)Eureka A中的配置(https://www.daowen.com)

图示

(3)Eureka B中的配置

图示

(4)业务服务的配置

图示

这样访问其中任意一台Eureka,即可看到业务服务SERVICE-PROVIDER。由于开启了Eureka服务的自注册功能,所以还能看到两台Eureka服务。

✍AI写作