Spring Boot Eureka 服务器不会发现同一客户端的多个示例

pwuypxnk  于 7个月前  发布在  Spring
关注(0)|答案(2)|浏览(128)

我有非常基本的EurekaServer

@SpringBootApplication
@EnableEurekaServer
public class DiscoveryServerApplication {

    public static void main(String[] args) {
        SpringApplication.run(DiscoveryServerApplication.class, args);
    }

}

字符串
application.properties:

server.port=8761
eureka.instance.hostname=localhost
eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
eureka.server.renewal-percent-threshold=0.85
eureka.server.renewal-threshold-update-interval-ms=900000


然后我设置多个Eureka 客户端,标记为**@EnableDiscoveryClient**。所有客户端都设置为随机端口0,并具有唯一的应用程序名称,如下所示:

server.port=0
eureka.client.service-url.defaultZone=http://localhost:8761/eureka
# unique name of the service
spring.application.name=product-service


我 Boot 了EurekaServer和我所有的客户端。我还允许运行同一服务的多个示例。它看起来像这样:
x1c 0d1x的数据
问题是当我运行Eureka 服务器 Jmeter 板时,它显示所有服务都在端口0上运行,并且它没有注册正在运行的多个InventoryServiceApplication示例。



更大的问题是,当我删除InventoryServiceApplication的第一个示例时,它会显示为“down”,但仍有两个示例在运行。我是否缺少某种配置来修复Eureka 服务器?如何修复Eureka 服务器,使其能够注册多个示例并开始显示正确的端口?

vaj7vani

vaj7vani1#

我认为它不识别随机端口,相反,我们可以通过“添加VM选项”在不同的端口上故意运行应用程序示例。
1.转到应用程序的“编辑配置设置”。
1.点击“修改选项”,然后选择“添加VM选项”
1.输入命令“-Dserver.port= portnumber”例如- -Dserver.port=9091。
1.点击运行,然后刷新Eureka 服务器。
x1c 0d1x的数据

u5i3ibmn

u5i3ibmn2#

我遇到了同样的问题,并通过为Eureka 示例配置示例ID来修复它。下面是我的配置文件。

server.port=0
eureka.instance.instance-id=${spring.application.name}:${spring.application.instance_id:${random.value}}
eureka.client.service-url.default-zone=http://localhost:8761/eureka
spring.application.name=inventory-service

字符串

相关问题