查看linux中etcd的状态
在 Linux 上安装了 etcd
后,可以通过以下几种方式查看它的状态:
方法一:使用 etcdctl
工具
etcdctl
是 etcd 的命令行工具,可以用于查看集群状态、成员信息等。
1. 查看 etcd 版本
etcdctl version
2. 设置环境变量(如果你是使用默认配置)
export ETCDCTL_API=3
3. 查看健康状态
etcdctl endpoint health
如果 etcd 正常运行,会返回类似:
127.0.0.1:2379 is healthy: successfully committed proposal: took = 1.233ms
4. 查看成员列表
etcdctl member list
5. 查看集群状态
etcdctl endpoint status --write-out=table
方法二:使用 systemd 查看服务状态
如果你是使用 systemd 安装/启动的 etcd,可以使用:
systemctl status etcd
也可以用:
journalctl -u etcd -f
实时查看日志输出。
方法三:查看进程和监听端口
查看是否有 etcd 进程运行:
ps aux | grep etcd
查看 etcd 是否监听了默认端口 2379:
ss -tunlp | grep 2379
方法四:通过 HTTP API(如果你开放了接口)
例如:
curl http://localhost:2379/health
返回:
{"health":"true"}
说明服务正常。