暂无图片
暂无图片
暂无图片
暂无图片
暂无图片

ETCD集群搭建

一把尺子 2017-12-28
198

etcd架构及原理
etcd官网
参考启动配置网址

mkdir -p data1/test/etcd
cd data1/test/etcd
wget https://github.com/coreos/etcd/releases/download/v3.2.12/etcd-v3.2.12-linux-amd64.tar.gz
tar zxvf etcd-v3.2.12-linux-amd64.tar.gz
cd etcd-v3.2.12-linux-amd64/
./etcd

复制

启动节点

cd data1/test/etcd/etcd-v3.2.12-linux-amd64

nohup ./etcd --name ucads1 --initial-advertise-peer-urls http://10.101.175.176:2380 \
 --listen-peer-urls http://10.101.175.176:2380 \
 --listen-client-urls http://10.101.175.176:2379,http://127.0.0.1:2379 \
 --advertise-client-urls http://10.101.175.176:2379 \
 --initial-cluster-token ucads-cluster \
 --initial-cluster ucads1=http://10.101.175.176:2380,ucads2=http://10.101.175.176:2390,ucads3=http://10.101.175.176:2400 \
 --initial-cluster-state new \
 --data-dir data1/test/etcd/data1 &

nohup ./etcd --name ucads2 --initial-advertise-peer-urls http://10.101.175.176:2390 \
 --listen-peer-urls http://10.101.175.176:2390 \
 --listen-client-urls http://10.101.175.176:2389,http://127.0.0.1:2389 \
 --advertise-client-urls http://10.101.175.176:2389 \
 --initial-cluster-token ucads-cluster \
 --initial-cluster ucads1=http://10.101.175.176:2380,ucads2=http://10.101.175.176:2390,ucads3=http://10.101.175.176:2400 \
 --initial-cluster-state new \
 --data-dir data1/test/etcd/data2 &

nohup ./etcd --name ucads3 --initial-advertise-peer-urls http://10.101.175.176:2400 \
 --listen-peer-urls http://10.101.175.176:2400 \
 --listen-client-urls http://10.101.175.176:2399,http://127.0.0.1:2399 \
 --advertise-client-urls http://10.101.175.176:2399 \
 --initial-cluster-token ucads-cluster \
 --initial-cluster ucads1=http://10.101.175.176:2380,ucads2=http://10.101.175.176:2390,ucads3=http://10.101.175.176:2400 \
 --initial-cluster-state new \
 --data-dir data1/test/etcd/data3 &

复制

测试节点

cd data1/test/etcd/etcd-v3.2.12-linux-amd64
#查看集群成员
./etcdctl  member list
#检查集群健康状况
./etcdctl cluster-health
#设置某个值
./etcdctl set foo/bar "hello world"
#列出某个路径下的目录
./etcdctl ls
#为某个key设置值及其过期时间
#注意 测试了下 设置存活时间是60  不像redis一样 有访问的就进行重新设置存活时间。只要到60 key就被删除
./etcdctl set /foo/bar "hello world" --ttl 60
#获取某个key的值  
./etcdctl get /foo/bar
#监控某个键的变化
./etcdctl watch /foo/bar
#删除某个key
./etcdctl rm test

复制



文章转载自一把尺子,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论