您的位置:首页 > 运维架构

自动化运维-自动化扩容介绍加etcd部署

2015-11-18 16:09 531 查看
saltstack ----- haproxy ------jinja
cd /usr/local/src/
rz -y
tar xf etcd-v2.2.1-linux-amd64.tar.gz
cd etcd-v2.2.1-linux-amd64
cp etcd etcdctl /usr/local/bin/
etcd --version
mkdir -p /data/etcd
nohup etcd --name auto_scale --data-dir /data/etcd/ --listen-peer-urls 'http://10.0.0.7:2380,http://10.0.0.7:7001' --listen-client-urls 'http://10.0.0.7:2379,http://10.0.0.7:4001' --

advertise-client-urls 'http://10.0.0.7:2379,http://10.0.0.7:4001' &
[root@linux-node1 etcd-v2.2.1-linux-amd64]# netstat -ntlp | grep etcd
tcp 0 0 10.0.0.7:4001 0.0.0.0:* LISTEN 8680/etcd
tcp 0 0 10.0.0.7:2379 0.0.0.0:* LISTEN 8680/etcd ========>交互端口
tcp 0 0 10.0.0.7:2380 0.0.0.0:* LISTEN 8680/etcd
tcp 0 0 10.0.0.7:7001 0.0.0.0:* LISTEN 8680/etcd

设置一个key: set
[root@linux-node1 /]# curl -s http://10.0.0.7:2379/v2/keys/message -XPUT -d value="Hello world" | python -m json.tool
{
"action": "set",
"node": {
"createdIndex": 5,
"key": "/message",
"modifiedIndex": 5,
"value": "Hello world"
}
}

-d post的数据

获取一个key: get
[root@linux-node1 /]# curl -s http://10.0.0.7:2379/v2/keys/message | python -m json.tool {
"action": "get",
"node": {
"createdIndex": 5,
"key": "/message",
"modifiedIndex": 5,
"value": "Hello world"
}
}

删除一个key: delete
[root@linux-node1 /]# curl -s http://10.0.0.7:2379/v2/keys/message -XDELETE | python -m json.tool
{
"action": "delete",
"node": {
"createdIndex": 5,
"key": "/message",
"modifiedIndex": 6
},
"prevNode": {
"createdIndex": 5,
"key": "/message",
"modifiedIndex": 5,
"value": "Hello world"
}
}

设置一个时间key:
[root@linux-node1 /]# curl -s http://10.0.0.7:2379/v2/keys/ttl_use -XPUT -d value="Hello world 1" -d ttl=30 | python -m json.tool
key名称为:ttl_use
key的value值为:Hello world 1
ttl时间为:30s
{
"action": "set",
"node": {
"createdIndex": 13,
"expiration": "2015-11-18T02:25:08.727313182Z",
"key": "/ttl_use",
"modifiedIndex": 13,
"ttl": 30,
"value": "Hello world 1"
}
}

获取key值:
[root@linux-node1 /]# curl -s http://10.0.0.7:2379/v2/keys/ttl_use| python -m json.tool
{
"action": "get",
"node": {
"createdIndex": 13,
"expiration": "2015-11-18T02:25:08.727313182Z",
"key": "/ttl_use",
"modifiedIndex": 13,
"ttl": 4,
"value": "Hello world 1"
}
}
老男孩网址:http://www.etiantian.org
qq:406564728
欢迎交流
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  saltstack   自动