我正在嘗試向Eureka註冊我的Java服務 - 沒有運氣。我有一個使用Spark-Java框架的現有代碼庫,因此'只添加兩行Spring註釋,瞧!不幸的是,這些例子對我沒有幫助。如何配置Eureka客戶端和服務屬性?
我讀了Eureka Configuration文檔,創建靈光一現,conf目錄下,並把下面兩個文件尤里卡-conf的:
- eureka-client.properties
- eureka-service.properties
我添加了eureka_conf路徑到我的$ CLASSPATH變量與export CLASSPATH=.:${CLASSPATH}:${EUREKA_CONF}/eureka-client.properties:${EUREKA_CONF}/eureka-service.properties
我複製粘貼的內容屬性文件從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
。
我創建了一個示例尤里卡服務器和客戶端(與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
文件。在Eureka配置中,.yaml文件 是什麼?它是 文件的替代品嗎?
編輯:我發現this answer解釋了yaml文件。 Application.yml被Spring引導使用,Manifest.yml被雲代工CLI使用。
- 什麼應該是我的本地環境和Pivotal上的eureka.vipAddress?
**編輯:我發現,與試驗和錯誤,在本地這設置爲http://localhost:yourport和PCF它應該是應用程序名稱。 localhost
和service-name
都不對應於物理網絡接口。哦,我終於知道虛擬ip是什麼**
讓我知道是否需要更多信息。預先感謝您的幫助。