0


eureka.instance.hostname,instance-id,prefer-ip-address的作用及区别

eureka.instance下hostname,instance-id,prefer-ip-address的作用及区别

eureka.instance

下的

hostname

即主机名不配置的话默认为电脑名,

instanceID

不配置的话默认值为主机名+服务名+端口,

prefer-ip-address

表示猜测主机名(hostname)为ip形式,不配置的话默认为false

eureka:

​ instance:

​ hostname:

​ instance-id:

​ prefer-ip-address:

以下三点为前提
在这里插入图片描述

如上图所示

1.Application下的名字对应spring.application.name

2.status下的是状态+instanceID , instanceID默认值为主机名+服务名+端口

3.鼠标移到status下的instanceID那里,左下角显示的是主机名:端口/actuaor/info

通过在代码中配置hostname,instance-id,prefer-ip-address进而改变eureka面板的显示

有两个服务,cloud-gateway,cloud-payment-service

cloud-gateway服务设置了hostname为cloud-gateway-service,没有设置instanceID,没有设置prefer-ip-address

所以instanceID为默认值,status下显示的是localhost:cloud-gateway:9527(具体的主机名需要鼠标移到instanceID那里)

由于配置了hostname为cloud-gateway-service,所以鼠标移到instanceID那里,左下角显示的是cloud-gateway-service:9527/actuaor/info

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

cloud-payment-service没有设置hostname,设置了instanceID为payment8001,设置了prefer-ip-address为true

所以instanceID为payment8001,status下显示的是payment8001(具体的主机名需要鼠标移到instanceID那里)

但是它配置了prefer-ip-address为true,主机名用ip表示,所以鼠标移到instanceID那里,左下角显示的是192.168.74.1:9527/actuaor/info

在这里插入图片描述
在这里插入图片描述

在这里插入图片描述

标签: eureka

本文转载自: https://blog.csdn.net/m0_37959155/article/details/122521406
版权归原作者 座上客 所有, 如有侵权,请联系我们删除。

“eureka.instance.hostname,instance-id,prefer-ip-address的作用及区别”的评论:

还没有评论