etcd 실행(2.2.5 기준)




$ curl -L  https://github.com/coreos/etcd/releases/download/v2.2.5/etcd-v2.2.5-darwin-amd64.zip -o etcd-v2.2.5-darwin-amd64.zip


$ unzip etcd-v2.2.5-darwin-amd64.zip



$ cd etcd-v2.2.5-darwin-amd64

$ ./etcd




커맨드 사용 방법


$ ./etcdctl ls -h

NAME:

   ./etcdctl ls - retrieve a directory


USAGE:

   ./etcdctl ls [command options] [arguments...]


OPTIONS:

   --sort returns result in sorted order

   --recursive returns all key names recursively for the given path

   -p append slash (/) to directories





간단한 dml 작업들 예제이다.

(ls, mkdir, set, get)



$ ./etcdctl ls


$ ./etcdctl mkdir /a/b

$ ./etcdctl ls /a

/a/b


$ ./etcdctl set /a/b/os ubuntu-16.04

ubuntu-16.04



$ ./etcdctl mkdir /a/b

$ ./etcdctl ls /a

/a/b

$ ./etcdctl set /a/b/os ubuntu-16.04

ubuntu-16.04

$ ./etcdctl get /a/b/os

ubuntu-16.04


$ ./etcdctl set /a/b/test samuel


$ ./etcdctl ls /a --recursive

/a/b

/a/b/os

/a/b/test




변경 방법이다. 


$ ./etcdctl update /a/b/os centos7


$ ./etcdctl get /a/b/os

centos6



간단한 노드 삭제 방법이다.


$ ./etcdtl rm /a/b/test


$ ./etcdctl rm /a/b/test

PrevNode.Value: samuel

$ ./etcdctl ls /a --recursive

/a/b

/a/b/os



구 zk(3.2.x 이전 버전)처럼 디렉토리를 지우기 전에 먼저 노드를 삭제해야 한다. 



$ ./etcdctl rmdir /a

Error:  108: Directory not empty (/a) [16540]

$ ./etcdctl rmdir /a/b

Error:  108: Directory not empty (/a/b) [16540]

$ ./etcdctl rm /a/b/os

PrevNode.Value: centos7

$ ./etcdctl rmdir /a/b/

$ ./etcdctl rmdir /a





모든 노드를 모두 보기


$ ./etcdctl ls --recursive



ttl 를 줄 수 있다.


$ ./etcdctl mkdir /a --ttl 3


3초 뒤에는 a가 사라져 있다.



http 관련 메소드는 따로 둔다. 


$ curl http://localhost:2379/xxx -XGET

404 page not found




백업하기


$ ps -ef | grep etcd

/opt/etcd/current/etcd --name master --data-dir /opt/etcd/data ...


$ ./etcdctl backup --data-dir /opt/etcd/data --backup-dir=/tmp/backup


$ ls -R /tmp/backup/

/tmp/backup/:

member


/tmp/backup/member:

snap  wal


/tmp/backup/member/snap:

000000000000022b-00000000062b232c.snap


/tmp/backup/member/wal:

0000000000000000-0000000000000000.wal





Posted by '김용환'
,