【发布时间】:2018-02-05 21:10:01
【问题描述】:
我正在尝试向 Eureka 注册我的 Java 服务 - 没有运气。我有一个使用 Spark-Java 框架的现有代码库,因此“只添加 2 行 Spring 注释,瞧!”不幸的是,示例对我没有帮助。
我阅读了Eureka Configuration的文档,创建了一个eureka-conf目录并将以下两个文件放入eureka-conf:
- eureka-client.properties
- eureka-service.properties
我使用 export CLASSPATH=.:${CLASSPATH}:${EUREKA_CONF}/eureka-client.properties:${EUREKA_CONF}/eureka-service.properties 将 eureka_conf 路径添加到我的 $CLASSPATH 变量中
我从here 复制粘贴了属性文件的内容。所以,它们看起来像这样:
#eureka-client.properties
eureka.registration.enabled=false
eureka.preferSameZone=true
eureka.shouldUseDns=false
eureka.serviceUrl.default=http://localhost:8080/eureka/v2/
eureka.decoderName=JacksonJson
#eureka-service.properties
eureka.region=us-west-1
eureka.name=qb-acm
eureka.vipAddress=mysampleservice.mydomain.net
eureka.port=8001
eureka.preferSameZone=true
eureka.shouldUseDns=false
eureka.serviceUrl.default=http://localhost:8080/eureka/v2/
您可以看到,我更改了 eureka.name 和 eureka.region 以在日志中查看是否找到了属性。找不到它们。
当我启动我的服务时,我看到 com.netflix.discovery.internal.util.Archaius1Utils 抛出以下警告:
Cannot find the properties specified : eureka-client. This may be okay if there are other environment specific properties or the configuration is installed with a different mechanism.
紧随其后的是:INFO com.netflix.discovery.DiscoveryClient - Initializing Eureka in region us-east-1。
我创建了一个示例 Eureka 服务器和客户端(使用 Spring)只是为了做一个示例,并且注册了 Spring 客户端。现在,我试图让我的非 Spring Java 服务注册到本地 Eureka 服务器。我的最终目标是设置此服务以注册并向我们托管在 Pivotal 上的远程 Eureka 服务器发送心跳。
其他错误可能对读者有用:
[main] ERROR com.netflix.discovery.shared.resolver.aws.ConfigClusterResolver - Cannot resolve to any endpoints from provided configuration: {defaultZone=[]}
[main] ERROR com.netflix.discovery.shared.transport.EurekaHttpClients - Initial resolution of Eureka server endpoints failed. Check ConfigClusterResolver logs for more info
所以,我的问题是:
我做错了什么设置属性?
我在很多例子中看到他们有一个
application.yml或manifest.yml文件。 .yaml 文件是什么 在尤里卡配置中?它是财产的替代品吗 文件?
编辑:我发现 this answer 解释了 yaml 文件。 Spring boot 使用 Application.yml,Cloud Foundry CLI 使用 Manifest.yml。
- 我的本地环境和 Pivotal 上的 eureka.vipAddress 应该是什么?
**edit:经过反复试验,我发现在本地设置为http://localhost:yourport,对于 PCF,它应该是应用程序名称。 localhost 和 service-name 都不对应于物理网络接口。哦,好吧,我终于知道什么是虚拟IP了**
如果需要更多信息,请告诉我。提前感谢您的帮助。
【问题讨论】:
标签: java netflix-eureka spark-java