studybook
  • Introduction
  • 실무 하며 깨닫는 부분 정리
    • 옵션에 대해서
    • 코드 작성의 순서
    • 자바 프로그램에 문제가 생겼다면
    • 장애 대처법
  • Logstash, Beats 정리
  • Zookeeper 정리
  • Message Queue 정리
    • RabbitMQ 삽질
  • Java 관련 정리
    • Java Primitive Wrapper class
    • Java NIO
    • Java8 Double colon operator
    • Effective Java
      • 4장
      • 5장
      • 6장 - Enum, Annotation
      • 7장 - Method
      • 8장 - 프로그래밍 일반
      • 9장 - Exception
    • Java8 Lambda expression
    • JDBC
    • Linux에서 WatchService 이상동작
  • Spring 관련 정리
    • Spring Bean init, destroy 순서
    • Spring Async Controller
    • Spring Executable jar 웹 개발 및 배포
    • Spring Boot Font 배포 에러
    • Spring AOP
      • Spring AOP로 모든 Request 로그 남기기
    • Spring Cache
    • Spring Cloud
      • Consul로 spring 설정 관리하기
    • Spring Test
      • Spring Test DirtiesContext
      • Spring Test MockBean, SpyBean
      • Spring Test Dynamic @Scheduled
    • Spring JDBC
    • Spring Validation
    • Spring Transaction Management
      • Spring with JTA 삽질
    • Spring에서 효율적으로 Static resource 관리하기
    • Zuul을 사용해서 Spring Reverse proxy 만들기
    • Spring Security
    • 스프링 어노테이션이 안 먹힐 때 의심해볼만한 것
    • Spring Data
    • Spring Webflux
      • Tobi 강연
  • 코드 리팩토링
    • 한번에 하나씩
  • 지속적 통합 (CI)
    • Jenkins pipeline 삽질기
  • Log Aggregator 정리
    • Flume 테스트
    • Fluentd 테스트
  • Web Socket 정리
  • Akka
    • Actor 모델
    • Supervision
  • IE 8 대응 정리
  • 함수형 프로그래밍
    • 모나드
  • Netty
    • Netty 기본 예제
    • Netty 주요 특징
    • Netty 부트스트랩
    • Netty 채널 파이프라인, 코덱
    • Netty 이벤트 모델
    • Netty 바이트 버퍼
  • 스칼라 관련 정리
    • Maven으로 컴파일하기
    • Scala def 괄호 여부의 차이
    • 스칼라 function, method 차이점
    • ScalaTest와 Spring 연동하기
    • Programming in Scala
  • J2S 컨퍼런스
  • Android
    • 테스트
    • NDK
  • DDOS
  • HTTP
  • HttpClient
  • Container
    • Image 개요
    • cri-o
    • kata containers
    • Open Container Initiative Image
    • Buildkit
  • Github pages
  • Static Website
  • Webhook
  • Service Discovery Tools
    • Etcd
    • Eureka
    • Consul
      • ACL
    • 비교
  • React
    • JSX
    • React Element
    • Components, Props
    • State, Lifecycle
    • Handling Event
    • Flux
  • Vagrant
    • SSH 접속
  • Linux
    • Systemd
    • Alternatives
  • Messaging protocols
    • XMPP
    • AMQP
  • Windows
    • Windows10 내장 우분투에 ssh 클라이언트로 접속하기
    • Windows10 Hyper-V와 Virtual Box가 충돌을 일으켰을 때
    • Hyper-V 기반 docker에서 Shared Drives 설정 실패할 때
    • 윈도우 개발환경 설정
    • Docker desktop 없이 docker 환경 세팅하기
    • UWP 앱을 항상 관리자권한으로 실행하는 바로가기 만들기
  • Spring camp 2017
    • Project Reactive
    • 이벤트 소싱
    • CQRS
  • Spring webflux
  • 리액티브 프로그래밍
  • Linux Settings
    • 홈서버 백업 및 복구기
    • 홈서버 트러블슈팅
  • Kubernetes
    • k3s 설치 및 삽질
    • pod resources
    • Argo workflow
    • 트러블 슈팅
      • Kubernetes namespace의 phase가 Terminating에서 멈춰있을 때
    • 쿠버네티스 마스터
    • Knative
    • Knative Pipeline
    • Aggrerated API server
    • Accessing the API
      • Authenticating
  • Sonarqube
  • HTTP/2
  • Go
    • Go Module
    • Go dependency injection
    • Go Error handling
    • Go in Action
      • 3장 패키지
      • 4장 배열, 슬라이스, 맵
      • 5장 GO의 타입 시스템
      • 6장 동시성
      • 7장 동시성 패턴
      • 8장 표준 라이브러리
      • 9장 테스트와 벤치마킹
    • Go Channel 사용법
  • Cloud Native
Powered by GitBook
On this page
  • 설치
  • 릴리즈 바이너리 받기
  • 직접 빌드
  • 실행
  • 서버 실행
  • 클라이언트 접속
  • 클러스터링
  • Static
  • etcd Discovery
  • DNS Discovery
  • Runtime Reconfiguration
  1. Service Discovery Tools

Etcd

PreviousService Discovery ToolsNextEureka

Last updated 7 years ago

  • 일관성을 유지하는 분산 Key-Value 저장소

  • Go로 작성됨

  • CoreOS 용으로 작성됨

설치

릴리즈 바이너리 받기

  • 링크에서 필요한 버전을 찾아 다운로드

직접 빌드

  1. go 1.6 이상 설치

  2. $GOPATH 환경변수 제대로 지정되어있는지 확인

  3. master 브랜치 clone 후 들어가서 build 스크립트 실행

실행

서버 실행

etcd
  • 기본적으로 2379 포트에서 클라이언트 통신을 받고 2380 포트에서 서버간 통신을 진행

클라이언트 접속

etcdctl set test "hello world"
etcdctl get test

클러스터링

Static

  • --inital-cluster 옵션에 모든 클러스터 노드의 이름과 peer-url을 넣어서 클러스터를 시작하는 방법

  • --initial-cluster-token 옵션을 통해 같은 설정을 가진 고유한 클러스터들을 구분 가능하게 생성할 수 있음

etcd Discovery

  • --discovery 옵션에 특정 etcd 클러스터나 노드의 URL을 넣어서 그 URL에서 얻은 정보를 바탕으로 클러스터를 시작하는 방법

  • 처음에 시작할 때 지정한 노드 갯수를 충족하지 않으면 전체 클러스터가 동작하지 않고, 노드 갯수를 넘어가게 추가하면 추가된 노드는 proxy 노드로 동작

  • reconfiguration을 통해서 클러스터에 새로운 노드를 추가하거나 제거했을 경우엔 discovery에 적용되지 않음

로컬 테스트 클러스터 구축

# Discovery 생성
./etcd --name discovery >discovery.log 2>&1 &

## 노드 갯수 지정
curl -X PUT http://localhost:2379/v2/keys/_etcd/registry/test/_config/size -d value=5

## discovery 정보 확인
curl -X GET http://localhost:2379/v2/keys/_etcd/registry/test

# 새로운 클러스터 생성
# 노드 갯수를 충족하지 않으면 동작하지 않음
# 노드 갯수를 넘어가면 proxy 노드로 추가됨

## 1번 노드
./etcd --name test1 --initial-advertise-peer-urls http://localhost:12380 \
--listen-peer-urls http://localhost:12380 \
--listen-client-urls http://localhost:12379 \
--advertise-client-urls http://localhost:12379 \
--discovery http://localhost:2379/v2/keys/_etcd/registry/test >test1.log 2>&1 &

## 2번 노드
./etcd --name test2 --initial-advertise-peer-urls http://localhost:22380 \
--listen-peer-urls http://localhost:22380 \
--listen-client-urls http://localhost:22379 \
--advertise-client-urls http://localhost:22379 \
--discovery http://localhost:2379/v2/keys/_etcd/registry/test >test2.log 2>&1 &

## 3번 노드
./etcd --name test3 --initial-advertise-peer-urls http://localhost:32380 \
--listen-peer-urls http://localhost:32380 \
--listen-client-urls http://localhost:32379 \
--advertise-client-urls http://localhost:32379 \
--discovery http://localhost:2379/v2/keys/_etcd/registry/test >test3.log 2>&1 &

## 4번 노드
./etcd --name test4 --initial-advertise-peer-urls http://localhost:42380 \
--listen-peer-urls http://localhost:42380 \
--listen-client-urls http://localhost:42379 \
--advertise-client-urls http://localhost:42379 \
--discovery http://localhost:2379/v2/keys/_etcd/registry/test >test4.log 2>&1 &

## 5번 노드
./etcd --name test5 --initial-advertise-peer-urls http://localhost:52380 \
--listen-peer-urls http://localhost:52380 \
--listen-client-urls http://localhost:52379 \
--advertise-client-urls http://localhost:52379 \
--discovery http://localhost:2379/v2/keys/_etcd/registry/test >test5.log 2>&1 &

## 현재 클러스터 확인
./etcdctl --endpoint http://localhost:12379 member list

DNS Discovery

  • DNS SRV record를 사용하여 discovery

  • -discovery-srv 옵션에 URL 등록

Runtime Reconfiguration

  • 클라이언트 명령어를 사용해서 클러스터에 노드의 추가 및 삭제 가능

  • 이 방법을 통해 추가하거나 삭제한 노드는 discovery 사용 불가

# 노드 추가
## discovery에 반영되지 않음
## etcdctl member add 이후 가능
./etcdctl --endpoint http://localhost:12379 member add test6 http://localhost:62380

## discovery를 쓸 수 없고 대신에 --initial-cluster 필요
## 6번 노드
./etcd --name test6 --initial-advertise-peer-urls http://localhost:62380 \
--listen-peer-urls http://localhost:62380 \
--listen-client-urls http://localhost:62379 \
--advertise-client-urls http://localhost:62379 \
--initial-cluster-token test-cluster \
--initial-cluster test6=http://localhost:62380,test1=http://localhost:12380,test5=http://localhost:52380,test3=http://localhost:32380,test4=http://localhost:42380,test2=http://localhost:22380 \
--initial-cluster-state existing >test6.log 2>&1 &
https://github.com/coreos/etcd/releases/
https://github.com/coreos/etcd.git