eureka peering (여기서 하나씩 지우면서 확인해 볼 차례)

This commit is contained in:
assu10
2020-10-24 19:18:27 +09:00
parent 95c5794c3a
commit 6911072862
9 changed files with 252 additions and 11 deletions

View File

@@ -206,8 +206,8 @@ HOW TO RUN
***- Spring Cloud Stream (EDA, 비동기 마이크로서비스 구성)***<br />
자세한 설명은 [Spring Cloud - Stream, 분산 캐싱 (1/2)](https://assu10.github.io/dev/2020/10/01/spring-cloud-stream/) 와
[Spring Cloud - Stream, 분산 캐싱 (2/2)](https://assu10.github.io/dev/2020/10/02/spring-cloud-stream-2/) 를 참고
자세한 설명은 [Spring Cloud Stream, 분산 캐싱 (1/2)](https://assu10.github.io/dev/2020/10/01/spring-cloud-stream/) 와
[Spring Cloud Stream, 분산 캐싱 (2/2)](https://assu10.github.io/dev/2020/10/02/spring-cloud-stream-2/) 를 참고
```shell script
HOW TO RUN

View File

@@ -35,6 +35,10 @@
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-server</artifactId>
</dependency>
<!--<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-bus-amqp</artifactId>

View File

@@ -2,6 +2,8 @@ package com.assu.cloud.eurekaserver;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
@EnableEurekaServer

View File

@@ -0,0 +1,41 @@
spring:
application:
name: eurekaserver-peer1 # 서비스 ID (컨피그 클라이언트가 어떤 서비스를 조회하는지 매핑)
profiles: peer1
server:
port: 8762 # 유레카 서버가 수신 대기할 포트
your.name: "EUREKA peer-1"
#spring:
# rabbitmq:
# host: localhost
# port: 5672
# username: guest
# password: '{cipher}17b3128621cb4e71fbb5a85ef726b44951b62fac541e1de6c2728c6e9d3594ec'
management:
endpoints:
web:
exposure:
include: "*"
endpoint:
shutdown:
enabled: true
eureka:
instance:
hostname: peer1
metadataMap:
instanceId: peer1_${spring.application.name}:${spring.application.instance_id:${random.value}}
client:
register-with-eureka: true # 유레카 서비스에 (자신을) 등록하지 않는다. (클러스터 모드가 아니므로)
fetch-registry: true # 레지스트리 정보를 로컬에 캐싱하지 않는다. (클러스터 모드가 아니므로)
serviceUrl:
defaultZone: http://peer2:8763/eureka/,http://peer1:8762/eureka/
#server:
#wait-time-in-ms-when-sync-empty: 5 # 서버가 요청을 받기 전 대기할 초기 시간 (5ms, 운영 환경에선 삭제 필요)
# 일시적인 네트워크 장애로 인한 서비스 해제 막기 위한 보호모드 해제 (디폴트 60초, 운영에선 삭제 필요)
# 원래는 해당 시간안에 하트비트가 일정 횟수 이상 들어오지 않아야 서비스 해제하는데 false 설정 시 하트비트 들어오지 않으면 바로 서비스 제거
#enable-self-preservation: false
logging:
level:
com.netflix: WARN
org.springframework.web: WARN
com.assu.cloud: DEBUG

View File

@@ -0,0 +1,41 @@
spring:
application:
name: eurekaserver-peer2 # 서비스 ID (컨피그 클라이언트가 어떤 서비스를 조회하는지 매핑)
profiles: peer2
server:
port: 8763 # 유레카 서버가 수신 대기할 포트
your.name: "EUREKA peer-2"
#spring:
# rabbitmq:
# host: localhost
# port: 5672
# username: guest
# password: '{cipher}17b3128621cb4e71fbb5a85ef726b44951b62fac541e1de6c2728c6e9d3594ec'
management:
endpoints:
web:
exposure:
include: "*"
endpoint:
shutdown:
enabled: true
eureka:
instance:
hostname: peer2
metadataMap:
instanceId: peer2_${spring.application.name}:${spring.application.instance_id:${random.value}}
client:
register-with-eureka: true # 유레카 서비스에 (자신을) 등록하지 않는다. (클러스터 모드가 아니므로)
fetch-registry: true # 레지스트리 정보를 로컬에 캐싱하지 않는다. (클러스터 모드가 아니므로)
serviceUrl:
defaultZone: http://peer1:8762/eureka/,http://peer2:8763/eureka/
#server:
#wait-time-in-ms-when-sync-empty: 5 # 서버가 요청을 받기 전 대기할 초기 시간 (5ms, 운영 환경에선 삭제 필요)
# 일시적인 네트워크 장애로 인한 서비스 해제 막기 위한 보호모드 해제 (디폴트 60초, 운영에선 삭제 필요)
# 원래는 해당 시간안에 하트비트가 일정 횟수 이상 들어오지 않아야 서비스 해제하는데 false 설정 시 하트비트 들어오지 않으면 바로 서비스 제거
#enable-self-preservation: false
logging:
level:
com.netflix: WARN
org.springframework.web: WARN
com.assu.cloud: DEBUG

View File

@@ -1,2 +1,78 @@
spring:
application:
name: eurekaserver-peer1 # 서비스 ID (컨피그 클라이언트가 어떤 서비스를 조회하는지 매핑)
profiles: peer1
server:
port: 8761 # 유레카 서버가 수신 대기할 포트
port: 8762 # 유레카 서버가 수신 대기할 포트
your.name: "EUREKA peer-1"
#spring:
# rabbitmq:
# host: localhost
# port: 5672
# username: guest
# password: '{cipher}17b3128621cb4e71fbb5a85ef726b44951b62fac541e1de6c2728c6e9d3594ec'
management:
endpoints:
web:
exposure:
include: "*"
endpoint:
shutdown:
enabled: true
eureka:
instance:
hostname: peer1
metadataMap:
instanceId: peer1_${spring.application.name}:${spring.application.instance_id:${random.value}}
client:
register-with-eureka: true # 유레카 서비스에 (자신을) 등록하지 않는다. (클러스터 모드가 아니므로)
fetch-registry: true # 레지스트리 정보를 로컬에 캐싱하지 않는다. (클러스터 모드가 아니므로)
serviceUrl:
dafaultZone: http://peer2:8763/eureka/,http://peer1:8762/eureka/
#server:
#wait-time-in-ms-when-sync-empty: 5 # 서버가 요청을 받기 전 대기할 초기 시간 (5ms, 운영 환경에선 삭제 필요)
# 일시적인 네트워크 장애로 인한 서비스 해제 막기 위한 보호모드 해제 (디폴트 60초, 운영에선 삭제 필요)
# 원래는 해당 시간안에 하트비트가 일정 횟수 이상 들어오지 않아야 서비스 해제하는데 false 설정 시 하트비트 들어오지 않으면 바로 서비스 제거
#enable-self-preservation: false
logging:
level:
com.netflix: WARN
org.springframework.web: WARN
com.assu.cloud: DEBUG
#server:
# port: 8761 # 유레카 서버가 수신 대기할 포트
#
#your.name: "EUREKA DEFAULT"
##spring:
## rabbitmq:
## host: localhost
## port: 5672
## username: guest
## password: '{cipher}17b3128621cb4e71fbb5a85ef726b44951b62fac541e1de6c2728c6e9d3594ec'
#management:
# endpoints:
# web:
# exposure:
# include: "*"
# endpoint:
# shutdown:
# enabled: true
#eureka:
# client:
# register-with-eureka: false # 유레카 서비스에 (자신을) 등록하지 않는다. (클러스터 모드가 아니므로)
# fetch-registry: false # 레지스트리 정보를 로컬에 캐싱하지 않는다. (클러스터 모드가 아니므로)
# service-url:
# # dafaultZone: http://peer2:8762/eureka/
# dafaultZone: http://localhost:8761/eureka/
# server:
# wait-time-in-ms-when-sync-empty: 5 # 서버가 요청을 받기 전 대기할 초기 시간 (5ms, 운영 환경에선 삭제 필요)
# # 일시적인 네트워크 장애로 인한 서비스 해제 막기 위한 보호모드 해제 (디폴트 60초, 운영에선 삭제 필요)
# # 원래는 해당 시간안에 하트비트가 일정 횟수 이상 들어오지 않아야 서비스 해제하는데 false 설정 시 하트비트 들어오지 않으면 바로 서비스 제거
# enable-self-preservation: false
#logging:
# level:
# com.netflix: WARN
# org.springframework.web: WARN
# com.assu.cloud: DEBUG

View File

@@ -1,8 +1,6 @@
spring:
application:
name: eurekaserver # 서비스 ID (컨피그 클라이언트가 어떤 서비스를 조회하는지 매핑)
profiles:
active: default # 서비스가 실행할 기본 프로파일
cloud:
config:
uri: http://localhost:8889 # 컨피그 서버 위치
#spring:
# application:
# name: eurekaserver # 서비스 ID (컨피그 클라이언트가 어떤 서비스를 조회하는지 매핑)
# cloud:
# config:
# uri: http://localhost:8889 # 컨피그 서버 위치

View File

@@ -1,2 +1,72 @@
server:
port: 8070
your.name: "EVENT DEFAULT."
#spring:
# rabbitmq:
# host: localhost
# port: 5672
# username: guest
# password: '{cipher}17b3128621cb4e71fbb5a85ef726b44951b62fac541e1de6c2728c6e9d3594ec'
management:
endpoints:
web:
exposure:
include: "*"
endpoint:
shutdown:
enabled: true
eureka:
#instance:
# prefer-ip-address: true # 서비스 이름 대신 IP 주소 등록
# lease-renewal-interval-in-seconds: 3 # 디스커버리한테 1초마다 하트비트 전송 (디폴트 30초)
# lease-expiration-duration-in-seconds: 2 # 디스커버리는 서비스 등록 해제 하기 전에 마지막 하트비트에서부터 2초 기다림 (디폴트 90초)
client:
serviceUrl:
defaultZone: http://peer1:8762/eureka/
register-with-eureka: true # 유레카 서버에 서비스 등록
fetch-registry: true # 레지스트리 정보를 로컬에 캐싱
# registry-fetch-interval-seconds: 3 # 서비스 목록을 3초마다 캐싱
logging:
level:
com.netflix: WARN
org.springframework.web: WARN
com.assu.cloud: DEBUG
service:
id:
member: member-service
zuul: zuulserver
security:
oauth2:
resource:
user-info-uri: http://localhost:8901/auth/user # OAuth2 콜백 URL
signing:
key: assusingkey
# 스프링 클라우드 스트림 설정
spring:
cloud:
stream:
bindings:
inboundMemberChanges: # inboundMemberChanges 은 채널명, EventServiceApplication 의 Sink.INPUT 채널에 매핑되고, input 채널을 mgChangeTopic 큐에 매핑함
destination: mbChangeTopic # 메시지를 넣은 메시지 큐(토픽) 이름
content-type: application/json
group: eventGroup # 메시지를 소비할 소비자 그룹의 이름
kafka: # stream.kafka 는 해당 서비스를 카프카에 바인딩
binder:
zkNodes: localhost # zkNodes, brokers 는 스트림에게 카프카와 주키퍼의 네트워크 위치 전달
brokers: localhost
#spring:
# cloud:
# stream:
# bindings:
# input: # input 은 채널명, EventServiceApplication 의 Sink.INPUT 채널에 매핑되고, input 채널을 mgChangeTopic 큐에 매핑함
# destination: mbChangeTopic # 메시지를 넣은 메시지 큐(토픽) 이름
# content-type: application/json
# group: eventGroup # 메시지를 소비할 소비자 그룹의 이름
# kafka: # stream.kafka 는 해당 서비스를 카프카에 바인딩
# binder:
# zkNodes: localhost # zkNodes, brokers 는 스트림에게 카프카와 주키퍼의 네트워크 위치 전달
# brokers: localhost
#redis
redis:
server: localhost
port: 6379

View File

@@ -1,2 +1,11 @@
server:
port: 5555
eureka:
instance:
prefer-ip-address: true # 서비스 이름 대신 IP 주소 등록
client:
serviceUrl:
defaultZone: http://peer1:8762/eureka/
register-with-eureka: true # 유레카 서버에 서비스 등록
fetch-registry: true # 레지스트리 정보를 로컬에 캐싱
registry-fetch-interval-seconds: 3 # 서비스 목록을 3초마다 캐싱