Spring Cloud Eureka - Server
유래는 넷플릭스 OSS에서 유래 되었다.
유레카는 자가등록(self-registration), 동적 탐색 및 부하분산(내부적으로 Ribbon을 사용)에 주로 사용된다.
유레카 서버 설치
SpringBoot 를 이용하여 설치 할것이다.
아래와 같이 패키지를 선택 해준다.
필자는 Actuator와 설정 파일 분리를 위해 spring cloud의 config-client를 설치하였지만, 반드시 필요한것은 아니니, 설치 하지 않아도 좋다.
이후, application.properties를 수정 할것이다.
spring.application.name=eureka-server1
eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka/
eureka.client.registerWithEureka=false
eureka.client.fetchRegistry=false
server.port=8761
위와 같이 넣어 주면 된다.
만약 필자와 같이 spring cloud config를 사용중이라면 다음과 같이 한다.
application.properties를 bootstrap.properties로 변경하고,
spring.application.name=eureka-server1
server.port=8761
spring.cloud.config.uri=http://localhost:8888
라고 입력한다.
또, config.repo에는 eureka-server1.properties 를 생성하고, 아래와 같이 입력한다.
spring.application.name=eureka-server1
eureka.client.serviceUrl.defaultZone=http://localhost:8761/eureka/
eureka.client.registerWithEureka=false
eureka.client.fetchRegistry=false
eureka.client.serviceUrl.defaultZone
속성 값은 클러스터 모드에서 다른 유레카 클라이언트와 동료 관계를 형성 할때 사용된다. 하지만 지금은 독립 설치형이므로 자기 자신을 가리킨다.
Application.java 파일을 수정한다.
@SpringBootApplication
@EnableEurekaServer
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
config server를 사용중이라면 config server를 구동후, 유레카 서버를 기동하고 http://localhost:8761/을 열어서 유레카 콘솔을 확인한다.