Skip to content

minority opinions

Menu
  • Home
  • 꿀팁정리 & 자기계발
  • 기술 정보 & 테크 소식
  • 이슈 뉴스 정리
  • 주식 경제
  • Tags
Menu
consul 서비스

consul 서비스 설치 및 TIP

Posted on 3월 25, 20177월 9, 2023 by Daniel J.

Hashicorp 에서 제공하는 devops 툴중 하나 consul 

https://www.consul.io/

– service discovery 기능

– key / value 저장소

– 오류(장애) 감지

 Terraform, nomad, Vagrant 등과 잘 조합하여 사용하면 devops 구현이 가능…

서버 설치

# consul keygen

   zWxxxxxxxxxxxxxxxxxxxxxx  (키생성)

# cat /etc/consul.d/server/config.json

{  “bootstrap”: true,  “server”: true,  “datacenter”: “test”,  “ui_dir”: “/data/consul-ui”,  “data_dir”: “/data/consul”,  “encrypt”: “key 값”,  “addresses”: {      “http”: “x.x.x.x”  }}

Consul 임시 실행 및 확인

nohup consul agent –server -config-dir=/etc/consul.d/server -bind=x.x.x.x &

Consul server Service 스크립트 만들기 (ubuntu 기준)

vi /etc/init/consul.conf

description “Consul server process”
start on local-filesystems and net-device-up IFACE=eth0stop on runlevel [!12345]
respawn
setuid ubuntusetgid ubuntu
exec consul agent –server -config-dir=/etc/consul.d/server -bind=[Consul 서버 IP]

# start consul

# tail -f /var/log/upstart/consul.log

# stop consul

———————————————————————————————————————–—————–

에이전트 설치

config.json

{  “server”: false,  “datacenter”: “DZHOST”,  “data_dir”: “c:\\consul\\data\\”,  “encrypt”: “key 값”,  “start_join”: [“consul server IP”]}

에이전트 (클라이언트) 실행 및 확인

# nohup consul agent -config-dir /etc/consul.d/agent -bind=[Consul agent IP] &

예: consul.exe agent -config-dir “C:\consul\config” -data-dir “C:\Consul\data” -config-file=”c:\consul\config\config.json” -bind=:: 

특정 서버만 (list file로) 일괄 등록하기 (saltstack 사용) 윈도우 버전 (리눅스 가능)

# salt -L `awk -vORS=, ‘{ print $1 }’ minions.list | sed ‘s/,$/\n/’` cp.get_dir salt://windows/consul ‘C:\’

# salt -L `awk -vORS=, ‘{ print $1 }’ minions.list | sed ‘s/,$/\n/’` cmd.run ‘cmd /c c:\consul\consul-service-up.bat’

consul-service-up.bat

@ECHO OFF
set IP=”netsh interface ip show addresses | findstr 10.20.x. | findstr IP”   (agent IP binding 하기 위함)
FOR /f “tokens=3” %%I IN (‘%IP%’) DO SET ipAddress=%%I
cmd /c “c:\consul\nssm install consul consul.exe agent -config-dir “C:\consul\config” -data-dir “C:\Consul\data” -config-file=”c:\consul\config\config.json” -bind=%ipAddress%”

###  기타 config sample ###

##ping 체크

# ping.json

{  “check”:   {   “name”: “ping”,   “script”: “ping -c 1 x.x.x.x”,    “interval”: “30s”  }}

##윈도우 특정 서비스 check

# service.json

{  “check”:     {        “id”: “W32Time”,        “name”: “w32time”,         “script”: “PowerShell -ExecutionPolicy Bypass -NoProfile -File c:\\Temp\\consul\\conf\\ServiceCheck.ps1”,         “interval”: “30s”    }}

# ServiceCheck.ps1 

$Service = Get-Service w32Timeif ($Service.Status -ne ‘Running’)     {        $Service | Write-Output        exit 2    } else     {        $Service | Write-Output        exit 0    }

Consul WEB UI 화면 (UI 설치는 구글링 …)

http://1x.x.x.x:8500/

이 글 공유하기:

  • 페이스북에 공유하려면 클릭하세요. (새 창에서 열림) Facebook
  • 클릭하여 X에서 공유 (새 창에서 열림) X
  • 인쇄하기 (새 창에서 열림) 인쇄
  • 클릭하여 친구에게 이메일로 링크 보내기 (새 창에서 열림) 전자우편
  • Telegram에 공유하려면 클릭하세요. (새 창에서 열림) Telegram
  • WhatsApp에 공유하려면 클릭하세요. (새 창에서 열림) WhatsApp

이것이 좋아요:

좋아하기 가져오는 중...

관련

답글 남기기 응답 취소

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다

Category

  • Article (66)
  • Uncategorized (178)
  • 게임 소식 (13)
  • 기술 정보 & 테크 소식 (260)
  • 꿀팁정리 & 자기계발 (317)
  • 블로그 (26)
  • 사건 사고 (64)
  • 역사 (35)
  • 영화 & 드라마 & 애니메이션 (27)
  • 이슈 뉴스 정리 (207)
  • 정치 인물 사회 (122)
  • 주식 경제 (119)

Recent Posts

  • 위고비(Wegovy) 효능과 가격(1펜) 정리

    위고비(Wegovy) 효능과 가격(1펜) 정리

    2월 16, 2025
  • 도메인 URL 주소 단축하는 사이트 모음

    도메인 URL 주소 단축하는 사이트 모음

    1월 30, 2025
  • 5년전 정혜수 MBC 기상캐스터가 해고당하면서 올린 글

    5년전 정혜수 MBC 기상캐스터가 해고당하면서 올린 글

    1월 28, 2025
  • MBC 기상캐스터 오요안나 자살과 집단 괴롭힘 가해자

    MBC 기상캐스터 오요안나 자살과 집단 괴롭힘 가해자

    1월 27, 2025
  • 홍장원 전 국정원 1차장 좌파이력 정리

    홍장원 전 국정원 1차장 좌파이력 정리

    1월 22, 2025

Popular Posts

©2025 minority opinions | Design: Newspaperly WordPress Theme
%d