[Spring] Discovery Server (Eureka Server) 란 ?
by 코박7discovery server 의 흐름.
- Eureka Client 서비스가 시작 될 때 Eureka Server에 자신의 정보를 등록한다.
- Eureka Client는 Eureka Server로 부터 다른 Client의 연결정보가 등록되어 있는 Registry를 받고 자신의 Local에 저장하게 된다.
- 30초 마다 Eureka Server로 부터 변경 사항을 갱신받는다.
- 30초 마다 ping을 통하여 자신이 동작하고 있다는 신호를 보낸다. 신호를 보내지 못하면 Eureka Server가 보내지 못한 Client를 Registry에서 제외시킨다.
- Eureka Server 는 Eureka Client를 관리하는 서버이다.
의존성 추가 및 설정
buildscript {
ext {
set('springCloudVersion', "2021.0.4")
}
}
plugins {
id 'java'
id 'org.springframework.boot' version '2.7.12'
id 'io.spring.dependency-management' version '1.0.15.RELEASE'
}
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
configurations {
compileOnly {
extendsFrom annotationProcessor
}
}
repositories {
mavenCentral()
}
dependencyManagement {
imports {
mavenBom "org.springframework.cloud:spring-cloud-dependencies:${springCloudVersion}"
}
}
dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
implementation 'org.springframework.cloud:spring-cloud-starter-netflix-eureka-server'
}
tasks.named('test') {
useJUnitPlatform()
}
jar {
enabled = false
}
// application 에 @EnableEurekaServer 어노테이션 등록
@SpringBootApplication
@EnableEurekaServer
public class DiscoveryApplication {
public static void main(String[] args) {
SpringApplication.run(DiscoveryApplication.class, args);
}
}
server.port=8761
# register-with-eureka: eureka에 등록여부를 정한다. 이 서버는 본인 자신이기에 등록하지 않는다.
eureka.client.register-with-eureka=false
# fetch-registry: registry의 항목을 로컬로 캐시할것인지 정한다.
eureka.client.fetch-registry=false
# eureka service 의 인스턴스 호스트 이름을 설정.
eureka.instance.hostname= eurekaserver
# 일시적인 네트워크 장애로 인한 서비스 해제 막기 위한 자기 보호 모드
# false 설정 시 하트비트가 들어오지 않으면 바로 서비스를 제거한다.
eureka.server.enable-self-preservation=true
- properties 추가.
'spring' 카테고리의 다른 글
[Spring] spring cloud Gateway 란 ? (0) | 2023.09.10 |
---|---|
[Spring] Discovery Eureka Client 란 (0) | 2023.09.10 |
[Spring] @NoArgsConstructor, @RequiredArgsConstructor, @AllArgsConstructor (0) | 2023.07.31 |
[Spring] 간단하게 POST 요청 보내기 (2) | 2023.07.25 |
[Spring] CORS 란? CORS 해결 (0) | 2023.07.13 |
블로그의 정보
코딩박스
코박7