简体   繁体   English

Spring Eureka客户端故障转移

[英]Spring Eureka Client Failover

I'm trying to get the failover behavior of the Eureka Client working and am receiving the below exception. 我正在尝试使Eureka Client运行的故障转移行为,并收到以下异常。 Eureka server1 is shutdown and I want it to failover to Eureka server2. Eureka server1已关闭,我希望它故障转移到Eureka server2。 The application realizes server 1 is down and tries to use the failover, but gets to this place in the code and throws an exception because the backup registry isn't defined. 该应用程序意识到服务器1已关闭并尝试使用故障转移,但是由于未定义备份注册表,因此到达了代码中的此位置并引发异常。

2016-07-08T14:25:41.369Z WARN 0 [main] com.netflix.discovery.DiscoveryClient: Using default backup registry implementation which does not do anything. 2016-07-08T14:25:41.370Z WARN 0 [main] com.netflix.discovery.DiscoveryClient: Cannot fetch applications from apps although backup registry was specified java.lang.UnsupportedOperationException: Backup registry not implemented. at com.netflix.discovery.NotImplementedRegistryImpl.fetchRegistry(NotImplementedRegistryImpl.java:15) at com.netflix.discovery.DiscoveryClient.fetchRegistryFromBackup(DiscoveryClient.java:1811)

My bootstrap.yml 我的bootstrap.yml

eureka:
  client:  
    fetchRegistry: true
    service-url:
      defaultZone: https://server1/eureka/,https://server2/eureka/

This the line in the Eureka Client the failure is occurring. 此行在Eureka Client中发生故障。

private void fetchRegistryFromBackup() {
    try {
        @SuppressWarnings("deprecation")
        BackupRegistry backupRegistryInstance = newBackupRegistryInstance();
        if (null == backupRegistryInstance) { // backward compatibility with the old protected method, in case it is being used.
            backupRegistryInstance = backupRegistryProvider.get();
        }

        if (null != backupRegistryInstance) {

You may try the following configuration: 您可以尝试以下配置:

eureka:
  client:
    register-with-eureka: true
    fetch-registry: true
    availability-zones:
      us-east-1: us-east-1a,us-east-1b
    region: us-east-1
    service-url:
      us-east-1a: http://<server1>/eureka/
      us-east-1b: http://<server2>/eureka/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM