dosubot[bot] commented on issue #3001: URL: https://github.com/apache/hugegraph/issues/3001#issuecomment-4275198371
<!-- Answer --> @mywgl 有以下几种方法可以获取当前 PD 集群的 leader 节点信息: **方法一:通过 REST API 查询** 最直接的方式是调用 PD 的 `/v1/members` 接口,返回结果中包含 `pdLeader` 字段,标识当前 leader 节点 [[1]](https://github.com/apache/hugegraph/blob/9126c80e414c073b60fc074361b211cfb409e0eb/hugegraph-pd/hg-pd-service/src/main/java/org/apache/hugegraph/pd/rest/MemberAPI.java#L89-L91): ```bash curl -u admin:password http://<pd_host>:<pd_port>/v1/members ``` 也可以用 `/v1/cluster` 接口获取更完整的集群信息,同样包含 `pdLeader` 字段 [[2]](https://github.com/apache/hugegraph/blob/9126c80e414c073b60fc074361b211cfb409e0eb/hugegraph-pd/hg-pd-service/src/main/java/org/apache/hugegraph/pd/rest/IndexAPI.java#L102-L103): ```bash curl -u admin:password http://<pd_host>:<pd_port>/v1/cluster ``` > **注意**:1.7.0 版本开启了认证,需要带上用户名密码 [[3]](https://github.com/apache/incubator-hugegraph/issues/2946#L117-L158)。如果不确定凭据,可以尝试 `-u store:admin` 或 `-u admin:admin`。 **方法二:查看 PD 日志** 在 PD 节点的日志中搜索以下关键字: - `Raft becomes leader` — 表示该节点成为了 leader [[4]](https://github.com/apache/hugegraph/blob/9126c80e414c073b60fc074361b211cfb409e0eb/hugegraph-pd/hg-pd-core/src/main/java/org/apache/hugegraph/pd/raft/RaftStateMachine.java#L121) - `Raft lost leader` — 表示该节点失去了 leader 角色 [[5]](https://github.com/apache/hugegraph/blob/9126c80e414c073b60fc074361b211cfb409e0eb/hugegraph-pd/hg-pd-core/src/main/java/org/apache/hugegraph/pd/raft/RaftStateMachine.java#L133) 每个 PD 节点分别执行: ```bash grep "becomes leader" /path/to/hugegraph-pd/logs/hugegraph-pd-stdout.log ``` **关于你的场景**:由于当前的 leader 转移后 `getLeaderGrpcAddress()` 会抛出 NPE(如我之前提到的 [#2959](https://github.com/apache/hugegraph/issues/2959) 中的 bug),你可以先通过上面的 API 或日志确认当前哪个节点是 leader,然后尝试重启非 leader 的 PD 节点,迫使原来的节点重新赢得选举,作为临时的 workaround。 <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=reply-with-mention&utm_term=apache%2Fhugegraph).* --- Docs are dead. Just use [Dosu](https://dosu.dev?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-tagline&utm_term=apache%2Fhugegraph). [](https://app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-feedback&utm_term=apache%2Fhugegraph#message_id=4242b8f0-89bd-4143-85d7-5c91d2fd1c6f) [](https://github.dosu.com/apache/hugegraph?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-ask-repo&utm_term=apache%2Fhugegraph) [](https://app.dosu.dev/signup?referrer=openSource&source=github-footer&utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-share-team&utm_term=apache%2Fhugegraph) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
