zgdy 发表于 2019-1-31 12:35:54

自动化运维

  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' &
  # 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
  # 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
  # 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
  # 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:
  # 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值:
  # 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
  欢迎交流



页: [1]
查看完整版本: 自动化运维