在 Linux 上安装了 etcd 后,可以通过以下几种方式查看它的状态:
方法一:使用 etcdctl 工具
etcdctl 是 etcd 的命令行工具,可以用于查看集群状态、成员信息等。
1. 查看 etcd 版本
etcdctl version2. 设置环境变量(如果你是使用默认配置)
export ETCDCTL_API=33. 查看健康状态
etcdctl endpoint health如果 etcd 正常运行,会返回类似:
127.0.0.1:2379 is healthy: successfully committed proposal: took = 1.233ms4. 查看成员列表
etcdctl member list5. 查看集群状态
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"}说明服务正常。