环境配置

  • 创建etcdctl别名,指定监听地址(IP及证书请按实际环境修改)
cat <<EOF >> ~/.bashrc
# Set etcdctl alias for etcd cluster
alias etcdctl='etcdctl --write-out=table --endpoints=https://192.168.233.12:2379,https://192.168.233.13:2379,https://192.168.233.14:2379 --cacert=/etc/etcd/cert/etcd-ca.pem --cert=/etc/etcd/cert/etcd.pem --key=/etc/etcd/cert/etcd-key.pem'
EOF
  • 重载bashrc
source ~/.bashrc

查询

  • 查看 etcd 集群的状态
etcdctl --write-out=table --endpoints=$ENDPOINTS endpoint status
  • 查看 etcd 集群的健康
etcdctl --endpoints=$ENDPOINTS endpoint health
  • 查看 etcd 集群的成员信息
etcdctl member list -w table
  • 查看 etcd 集群的版本信息
etcdctl version -w table
  • 查看 etcd 集群的健康状态
etcdctl endpoint health -w table
  • 查看 etcd 集群的成员数
etcdctl endpoint status -w table
  • 列出 etcd 集群的键值对
etcdctl get --prefix / -w table