1,下载,解压,安装
推荐把解压的etcd文件夹放在 /usr/local/bin/ 目录
2,启动单机etcd服务
nohup ./etcd --listen-client-urls 'http://0.0.0.0:2379' --advertise-client-urls 'http://0.0.0.0:2379' > ./log/etcd.log 2>&1 &
-listen-client-urls 用于指定etcd和客户端的连接端口
-advertise-client-urls 用于指定etcd服务器之间通讯的端口
etcd有要求,如果-listen-client-urls被设置了,那么就必须同时设置-advertise-client-urls,所以即使设置和默认相同,也必须显式设置.
3,etcd简单客户端操作
可以使用[root@VM_centos etcd]# ETCDCTL_API=3 ./etcdctl get -h 获取帮助
[root@VM_centos etcd]# ETCDCTL_API=3 ./etcdctl put name mingming
OK
[root@VM_centos etcd]# ETCDCTL_API=3 ./etcdctl get name
name
mingming
[root@VM_centos etcd]# ETCDCTL_API=3 ./etcdctl del name
1
[root@VM_centos etcd]# ETCDCTL_API=3 ./etcdctl put "/cron/work1" "case1"
OK
[root@VM_centos etcd]# ETCDCTL_API=3 ./etcdctl put "/cron/work2" "case2"
OK
[root@VM_centos etcd]# ETCDCTL_API=3 ./etcdctl get "/cron/" --prefix
/cron/work1
case1
/cron/work2
case2
[root@VM_centos etcd]# ETCDCTL_API=3 ./etcdctl del "/cron/" --prefix
2
4,watch的使用
[root@VM_centos etcd]# ETCDCTL_API=3 ./etcdctl watch "/cron/" --prefix
PUT
/cron/work1
case1
PUT
/cron/work2
case2
DELETE
/cron/work1
DELETE
/cron/work2