DEV Community

Michael
Michael

Posted on • Originally published at gbase8.cn

How to Identify the gcware Leader Node in GBase 8a

In a GBase 8a cluster, the gcware service maintains state and consistency across nodes. It operates as a quorum with one elected Leader and the rest as Followers. Under normal operation, you rarely need to know which node is the Leader. However, in disaster recovery scenarios where gcware data must be repaired manually, pinpointing the current Leader becomes critical. This article shows how to find it using the gcware logs.

The Key Indicator

The gcware log (default: <install_dir>/gcware/log/gcware.log) records role transitions. When a node becomes the Leader, you will see a line like:

switch to leader with term:XXXXX
Enter fullscreen mode Exit fullscreen mode

Here XXXXX is a monotonically increasing term number. By comparing the most recent switch to leader entries across all gcware nodes, the node with the highest term and the latest timestamp is the current Leader.

A Practical Example

Below are log excerpts from two gcware nodes: node 103 and node 104.

Node 103 log:

[gbase@gbase_rh7_003 ~]$ grep "switch to" /opt/gbase/*/gcware/log/gcware.log | tail
...
Feb 07 17:29:50.320778 INFO  [GCWARE] node 1728184330 switch to leader with term:123
...
Feb 10 09:56:41.279513 INFO  [GCWARE] node 1728184330 switch to follower with term:205 leader:0
Enter fullscreen mode Exit fullscreen mode

Node 103's last switch to leader occurred on Feb 7 with term 123. On Feb 10 at 09:56:41 it transitioned to follower.

Node 104 log:

[gbase@gbase_rh7_004 log]$ grep "switch to " /opt/gbase/*/gcware/log/gcware.log | tail
...
Feb 10 09:56:41.519532 INFO  [GCWARE] node 1744961546 switch to leader with term:205
Enter fullscreen mode Exit fullscreen mode

Node 104's last switch to leader happened on Feb 10 at 09:56:41 with term 205.

Conclusion: Node 104 has the newer Leader mark and a larger term. Therefore, the current gcware Leader is node 104.

When This Matters

This method is intended for emergency situations where the gcware data is corrupted and must be manually repaired. In a healthy gbase database cluster, leader election happens automatically and there is no need to intervene.

Use grep "switch to" on each gcware node, check the latest switch to leader timestamp and term, and you can confidently identify the authoritative Leader node.

Top comments (0)