我试图让Eureka客户端的故障转移行为正常工作并收到以下异常。 Eureka server1已关闭,我希望它能够故障转移到Eureka server2。应用程序意识到服务器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)
我的bootstrap.yml
eureka:
client:
fetchRegistry: true
service-url:
defaultZone: https://server1/eureka/,https://server2/eureka/
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) {
答案 0 :(得分:0)
您可以尝试以下配置:
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/