2017-03-25 2 views
0

나는 내 자신의 유레카 서버를 로컬에 설치할 수 있으며 문제없이 서비스를 등록 할 수 있습니다. 그러나 Pivotal Cloud Foundry의 "서비스 레지스트리"서비스를 사용하여 유레카 서버를 만들 때 내 응용 프로그램이 "등록 된 응용 프로그램"아래 나타나지 않습니다.Cloud Foundry Service Registry (Netflix Eureka) 서비스를 사용하기위한 Spring Boot 구성은 무엇입니까?

  1. 만든 서비스 레지스트리 클라우드를 통해 파운드리 마켓 플레이스 :

    가 나는 다음 완료했습니다.

  2. 내 서비스를 서비스에 바인딩합니다.
  3. 내 응용 프로그램을 서비스에 등록했습니다.

로그 :

2017-03-25T11:32:26.994-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:26.994 INFO 13 --- [ main] o.s.j.e.a.AnnotationMBeanExporter : Located managed bean 'refreshEndpoint': registering with JMX server as MBean [org.springframework.cloud.endpoint:name=refreshEndpoint,type=RefreshEndpoint] 
2017-03-25T11:32:27.426-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:27.424 INFO 13 --- [ main] o.s.c.support.DefaultLifecycleProcessor : Starting beans in phase 0 
2017-03-25T11:32:27.444-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:27.443 INFO 13 --- [ main] o.s.c.n.eureka.InstanceInfoFactory : Setting initial instance status as: STARTING 
2017-03-25T11:32:27.758-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:27.755 INFO 13 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON encoding codec LegacyJacksonJson 
2017-03-25T11:32:27.758-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:27.758 INFO 13 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using JSON decoding codec LegacyJacksonJson 
2017-03-25T11:32:28.114-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:28.113 INFO 13 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML decoding codec XStreamXml 
2017-03-25T11:32:28.114-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:28.113 INFO 13 --- [ main] c.n.d.provider.DiscoveryJerseyProvider : Using XML encoding codec XStreamXml 
2017-03-25T11:32:28.682-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:28.678 INFO 13 --- [ main] c.n.d.s.r.aws.ConfigClusterResolver : Resolving eureka endpoints via configuration 
2017-03-25T11:32:28.745-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:28.745 INFO 13 --- [ main] com.netflix.discovery.DiscoveryClient : Disable delta property : false 
2017-03-25T11:32:28.745-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:28.745 INFO 13 --- [ main] com.netflix.discovery.DiscoveryClient : Single vip registry refresh property : null 
2017-03-25T11:32:28.745-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:28.745 INFO 13 --- [ main] com.netflix.discovery.DiscoveryClient : Force full registry fetch : false 
2017-03-25T11:32:28.746-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:28.745 INFO 13 --- [ main] com.netflix.discovery.DiscoveryClient : Application is null : false 
2017-03-25T11:32:28.746-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:28.745 INFO 13 --- [ main] com.netflix.discovery.DiscoveryClient : Registered Applications size is zero : true 
2017-03-25T11:32:28.747-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:28.745 INFO 13 --- [ main] com.netflix.discovery.DiscoveryClient : Application version is -1: true 
2017-03-25T11:32:28.761-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:28.747 INFO 13 --- [ main] com.netflix.discovery.DiscoveryClient : Getting all instance registry info from the eureka server 
2017-03-25T11:32:29.156-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:29.155 INFO 13 --- [ main] com.netflix.discovery.DiscoveryClient : The response status is 200 
2017-03-25T11:32:29.160-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:29.160 INFO 13 --- [ main] com.netflix.discovery.DiscoveryClient : Starting heartbeat executor: renew interval is: 30 
2017-03-25T11:32:29.165-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:29.164 INFO 13 --- [ main] c.n.discovery.InstanceInfoReplicator : InstanceInfoReplicator onDemand update allowed rate per min is 4 
2017-03-25T11:32:29.170-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:29.169 INFO 13 --- [ main] com.netflix.discovery.DiscoveryClient : Discovery Client initialized at timestamp 1490455949169 with initial instances count: 23 
2017-03-25T11:32:29.227-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:29.227 INFO 13 --- [ main] c.n.e.EurekaDiscoveryClientConfiguration : Registering application gym-service with eureka with status UP 
2017-03-25T11:32:29.230-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:29.229 INFO 13 --- [ main] com.netflix.discovery.DiscoveryClient : Saw local status change event StatusChangeEvent [timestamp=1490455949229, current=UP, previous=STARTING] 
2017-03-25T11:32:29.236-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:29.236 INFO 13 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_GYM-SERVICE/3a2f6286-096c-4a2a-782a-03bab8f020a9: registering service... 
2017-03-25T11:32:29.349-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:29.348 INFO 13 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_GYM-SERVICE/3a2f6286-096c-4a2a-782a-03bab8f020a9 - registration status: 204 
2017-03-25T11:32:29.570-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:29.569 INFO 13 --- [ main] s.b.c.e.t.TomcatEmbeddedServletContainer : Tomcat started on port(s): 8080 (http) 
2017-03-25T11:32:29.575-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:29.574 INFO 13 --- [ main] c.n.e.EurekaDiscoveryClientConfiguration : Updating port to 8080 
2017-03-25T11:32:29.582-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:32:29.582 INFO 13 --- [ main] com.campbellonsoftware.orka.GymServer : Started GymServer in 22.159 seconds (JVM running for 24.923) 
2017-03-25T11:32:31.135-04:00 [CELL/0] [OUT] Container became healthy 
2017-03-25T11:37:28.751-04:00 [APP/PROC/WEB/0] [OUT] 2017-03-25 15:37:28.751 INFO 13 --- [trap-executor-0] c.n.d.s.r.aws.ConfigClusterResolver : Resolving eureka endpoints via configuration 

관리-gym.yml 파일 :

# Spring properties 
spring: 
    application: 
    name: gym-service # Service registers under this name 
    freemarker: 
    enabled: false   # Ignore Eureka dashboard FreeMarker templates 
    thymeleaf: 
    cache: false    # Allow Thymeleaf templates to be reloaded at runtime 
    prefix: classpath:/manage-gym/templates/ # Trailing/mandatory 
          # Template location for this application only 

# Map the error path to error template (for Thymeleaf) 
error: 
    path: /error 

# HTTP Server 
server: 
    port: 2222 # HTTP (Tomcat) port 

# Discovery Server Access 
# 1. DEV ONLY: Reduce the lease renewal interval to speed up registration 
# 2. Define URL of registration server (defaultZone) 
eureka: 
    client: 
    serviceUrl: 
     defaultZone: ${vcap.services.${PREFIX:}eureka.credentials.uri:http://user:${eureka.password:}@${PREFIX:}eureka.${application.domain:cfapps.io}}/eureka/ 
    instance: 
    hostname: ${vcap.application.uris[0]} 
    leaseRenewalIntervalInSeconds: 30 # DO NOT DO THIS IN PRODUCTION 

메인 클래스 :

package com.campbellonsoftware.orka; 

import java.util.logging.Logger; 
import org.springframework.boot.SpringApplication; 
import org.springframework.boot.autoconfigure.EnableAutoConfiguration; 
import org.springframework.boot.autoconfigure.SpringBootApplication; 
import org.springframework.cloud.client.discovery.EnableDiscoveryClient; 


@SpringBootApplication 
@EnableAutoConfiguration 
@EnableDiscoveryClient 
public class GymServer { 


    protected Logger logger = Logger.getLogger(GymServer.class.getName()); 

    public static void main(String[] args) { 
     System.setProperty("spring.config.name", "manage-gym"); 
     SpringApplication.run(GymServer.class, args); 
    } 
} 

서비스 레지스트리 : Service Registry config

을3210

답변

1

나는 서비스 레지스트리가 내가 로컬에서 실행중인 것과 같은 사전 설정 유레카 서버라고 생각했지만 그렇지 않았습니다.

이것은 백그라운드에서 유레카를 사용하지만 별도의 프로세스이므로 아래의 종속성을 추가해야합니다.

의 pom.xml :

<dependencyManagement> 
    <dependencies> 
     <dependency> 
      <groupId>io.pivotal.spring.cloud</groupId> 
      <artifactId>spring-cloud-services-dependencies</artifactId> 
      <version>1.2.0.RELEASE</version> 
      <type>pom</type> 
      <scope>import</scope> 
     </dependency> 
     ... 
    </dependencies> 
</dependencyManagement> 
<dependencies> 
    ... 
    <dependency> 
     <groupId>io.pivotal.spring.cloud</groupId> 
     <artifactId>spring-cloud-services-starter-service-registry</artifactId> 
    </dependency> 
    ... 
</dependencies> 

결과 : enter image description here

+0

중추 CF에 봄 클라우드 서비스가 제공하는 서비스 레지스트리가 미리 설정 유레카이지만, SCS는 외설 보안 계층을 제공한다 ' 오픈 소스 Spring Cloud에서 제공됩니다. 여기 세부 정보 : http://docs.pivotal.io/spring-cloud-services/1-3/common/security-overview.html#service-registry-service-instances. 발견하고 추가 한 종속성은 클라이언트 응용 프로그램이이 보안을 협상하는 데 도움이됩니다. 올바른 OAuth 설정으로 앱에서 직접 할 수는 있지만 'spring-cloud-services-starter-service-registry' lib는 모든 것을 수행합니다. –

+0

잘 알고 있습니다. 감사합니다 스콧 –