前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >etcd 集群9

etcd 集群9

作者头像
franket
发布2022-01-19 11:21:56
1680
发布2022-01-19 11:21:56
举报
文章被收录于专栏:技术杂记

使用环境变量运行新节点,将节点加入集群

代码语言:javascript
复制
[root@h102 etcd-v2.2.4-linux-amd64]# ETCD_NAME="new-h102" ETCD_INITIAL_CLUSTER="h104=http://192.168.100.104:2380,docker=http://192.168.100.103:2380,new-h102=http://192.168.100.102:2380"   ETCD_INITIAL_CLUSTER_STATE="existing"   /usr/local/src/etcd/etcd-v2.2.4-linux-amd64/etcd -listen-client-urls http://192.168.100.102:2379,http://127.0.0.1:2379   -advertise-client-urls http://192.168.100.102:2379 -listen-peer-urls http://192.168.100.102:2380   -initial-advertise-peer-urls http://192.168.100.102:2380
2016-02-16 18:46:13.884181 I | flags: recognized and used environment variable ETCD_INITIAL_CLUSTER=h104=http://192.168.100.104:2380,docker=http://192.168.100.103:2380,new-h102=http://192.168.100.102:2380
2016-02-16 18:46:13.884325 I | flags: recognized and used environment variable ETCD_INITIAL_CLUSTER_STATE=existing
2016-02-16 18:46:13.884363 I | flags: recognized and used environment variable ETCD_NAME=new-h102
2016-02-16 18:46:13.884512 I | etcdmain: etcd Version: 2.2.4
2016-02-16 18:46:13.884528 I | etcdmain: Git SHA: bdee27b
2016-02-16 18:46:13.884541 I | etcdmain: Go Version: go1.5.3
2016-02-16 18:46:13.884554 I | etcdmain: Go OS/Arch: linux/amd64
...
...
...

节点可以正常工作

代码语言:javascript
复制
[root@h102 etcd-v2.2.4-linux-amd64]# curl http://127.0.0.1:2379/v2/keys/message
{"action":"get","node":{"key":"/message","value":"set by h104","modifiedIndex":11,"createdIndex":11}}
[root@h102 etcd-v2.2.4-linux-amd64]# 

再次查看成员状态

代码语言:javascript
复制
[root@h102 etcd-v2.2.4-linux-amd64]# ./etcdctl  member list
1b80a88a471eb4b8: name=h104 peerURLs=http://192.168.100.104:2380 clientURLs=http://192.168.100.104:2379
940f6e83e019a03f: name=docker peerURLs=http://192.168.100.103:2380 clientURLs=http://192.168.100.103:2379
cdc1e5e338e27adc: name=new-h102 peerURLs=http://192.168.100.102:2380 clientURLs=http://192.168.100.102:2379
[root@h102 etcd-v2.2.4-linux-amd64]# 

Note: 如果要添加多个节点,建议一次只添加一个,然后检查节点和集群运行状态正常后再依次逐个添加其它节点


命令汇总

  • hostnamectl
  • cd etcd-v2.2.4-linux-amd64/
  • ./etcd --version
  • firewall-cmd --add-port=2379/tcp
  • firewall-cmd --add-port=2380/tcp
  • firewall-cmd --list-all
  • ./etcd -name docker -initial-advertise-peer-urls http://192.168.100.103:2380 \
  • ./etcd -name h104 -initial-advertise-peer-urls http://192.168.100.104:2380 \
  • ./etcd -name h102 -initial-advertise-peer-urls http://192.168.100.102:2380 -listen-peer-urls http://192.168.100.102:2380 -listen-client-urls http://192.168.100.102:2379,http://127.0.0.1:2379 -advertise-client-urls http://192.168.100.102:2379 -initial-cluster-token etcd-cluster-test -initial-cluster docker=http://192.168.100.103:2380,h102=http://192.168.100.102:2380,h104=http://192.168.100.104:2380 -initial-cluster-state new
  • date
  • date +%s
  • curl http://127.0.0.1:2379/v2/keys/message -XPUT -d value="set by h104"
  • curl http://127.0.0.1:2379/v2/keys/message
  • ./etcdctl member --help
  • ./etcdctl member remove 84099faad6d56427
  • curl http://localhost:2379/v2/members
  • ./etcdctl member add new-h102 http://192.168.100.102:2380
  • ./etcdctl member list
  • ETCD_NAME="new-h102" ETCD_INITIAL_CLUSTER="h104=http://192.168.100.104:2380,docker=http://192.168.100.103:2380,new-h102=http://192.168.100.102:2380" ETCD_INITIAL_CLUSTER_STATE="existing" /usr/local/src/etcd/etcd-v2.2.4-linux-amd64/etcd -listen-client-urls http://192.168.100.102:2379,http://127.0.0.1:2379 -advertise-client-urls http://192.168.100.102:2379 -listen-peer-urls http://192.168.100.102:2380 -initial-advertise-peer-urls http://192.168.100.102:2380
  • curl http://127.0.0.1:2379/v2/keys/message

原文地址

本文系转载,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文系转载前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • 命令汇总
相关产品与服务
容器镜像服务
容器镜像服务(Tencent Container Registry,TCR)为您提供安全独享、高性能的容器镜像托管分发服务。您可同时在全球多个地域创建独享实例,以实现容器镜像的就近拉取,降低拉取时间,节约带宽成本。TCR 提供细颗粒度的权限管理及访问控制,保障您的数据安全。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档