我正在尝试在us-east-1地区设置尤里卡集群。有2个可用区(区域b和d),并且在每个区域上运行一个eureka服务器实例。我们设置DNS文本记录,该文本记录引用每个区域中服务器的ENI。
春季启动版本-2.0.5.RELEASE
以下是有关环境的更多信息:
b区:
IP Address - XX.XXX.XXX.250
Hostname - ip-XX-XXX-XXX-250.ec2.internal
ENI IP Address - XX.XXX.XXX.133
ENI hostname - ip-XX-XXX-XXX-133.ec2.internal
d区:
IP Address - XX.XXX.XXX.176
Hostname - ip-XX-XXX-XXX-176.ec2.internal
ENI IP Address - XX.XXX.XXX.161
ENI hostname - ip-XX-XXX-XXX-161.ec2.internal
DNS配置:
dig -t txt txt.us-east-1.dev-aws.XXXXX.com
;; ANSWER SECTION:
txt.us-east-1.dev-aws.XXXXX.com. 300 IN TXT "us-east-1b.dev-aws.XXXXX.com"
txt.us-east-1.dev-aws.XXXXX.com. 300 IN TXT "us-east-1d.dev-aws.XXXXX.com"
nslookup -q=txt txt.us-east-1b.dev-aws.XXXXX.com
Non-authoritative answer:
txt.us-east-1b.dev-aws.XXXXX.com text = "ip-XX-XXX-XXX-133.ec2.internal"
nslookup -q=txt txt.us-east-1d.dev-aws.XXXXX.com
Non-authoritative answer:
txt.us-east-1d.dev-aws.XXXXX.com text = "ip-XX-XXX-XXX-161.ec2.internal"
application.properties
server.port=8761
eureka.client.fetch-registry=true
eureka.client.eureka-server-u-r-l-context=eureka
eureka.client.region=us-east-1
eureka.client.eureka-server-port=8761
eureka.client.use-dns-for-fetching-service-urls=true
eureka.client.eureka-server-d-n-s-name=dev-aws.XXXXX.com
eureka.client.register-with-eureka=true
eureka.server.binding-strategy=ENI
eureka.datacenter=cloud
eureka.environment=AWS-DEV
SpringEurekaServerAwsApplication.java
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@SpringBootApplication
@EnableEurekaServer
public class SpringEurekaServerAwsApplication {
public static void main(String[] args) {
SpringApplication.run(SpringEurekaServerAwsApplication.class, args);
}
@Bean
public EurekaInstanceConfigBean eurekaInstanceConfig(InetUtils inetUtils) {
EurekaInstanceConfigBean eurekaInstanceConfigBean = new EurekaInstanceConfigBean(inetUtils);
AmazonInfo info = AmazonInfo.Builder.newBuilder().autoBuild("eureka");
eurekaInstanceConfigBean.setDataCenterInfo(info);
eurekaInstanceConfigBean.setHostname(info.get(AmazonInfo.MetaDataKey.localHostname));
eurekaInstanceConfigBean.setIpAddress(info.get(AmazonInfo.MetaDataKey.localIpv4));
return eurekaInstanceConfigBean;
}
}
我能够看到两个实例上当前在eureka中注册的所有实例,但是可用副本始终为空白。看起来像是Spring Cloud Eureka服务器中的问题。有人可以帮忙研究这个问题吗?
以下是eureka仪表板的屏幕截图:
添加到github
@RyanBaxter Ryan-我可以在“当前在Eureka中注册的实例”中看到复制的实例,但是“ available-replicas”为空。而且,要花费时间(不一致,大约30-50分钟)来反映副本中已注册的实例。我还可以在eureka服务器日志中关注,看起来某些配置不正确,但是找不到它。
2018-10-12 15:46:52.624 INFO 26564 --- [Eureka-PeerNodesUpdater] c.n.eureka.cluster.PeerEurekaNodes : Removing no longer available peer nodes [http://ip-XX-XXX-XXX-161.ec2.internal:8761/eureka/]
2018-10-12 15:46:52.624 INFO 26564 --- [Eureka-PeerNodesUpdater] c.n.eureka.cluster.PeerEurekaNodes : Adding new peer nodes [http://ip-XX-XXX-XXX-133.ec2.internal:8761/eureka/]
2018-10-12 16:16:52.730 INFO 26564 --- [Eureka-PeerNodesUpdater] c.n.eureka.cluster.PeerEurekaNodes : Removing no longer available peer nodes [http://ip-XX-XXX-XXX-133.ec2.internal:8761/eureka/]
2018-10-12 16:16:52.731 INFO 26564 --- [Eureka-PeerNodesUpdater] c.n.eureka.cluster.PeerEurekaNodes : Adding new peer nodes [http://ip-XX-XXX-XXX-161.ec2.internal:8761/eureka/]
另一个问题-由于以下异常,Eureka在关闭期间未解除绑定ENI:
2018-10-17 14:26:34.756 INFO 2389 --- [Thread-16] com.netflix.discovery.DiscoveryClient : Shutting down DiscoveryClient ...
2018-10-17 14:26:34.758 WARN 2389 --- [Thread-16] .s.c.a.CommonAnnotationBeanPostProcessor : Invocation of destroy method failed on bean with name 'scopedTarget.eurekaClient': org.springframework.beans.factory.BeanCreationNotAllowedException: Error creating bean with name 'eurekaInstanceConfig': Singleton bean creation not allowed while singletons of this factory are in destruction (Do not request a bean from a BeanFactory in a destroy method implementation!)