Cluster Commands

GET LEADER

In a cluster environment, the GET LEADER command returns the IP address and port of the Raft leader node. If the ID parameter is specified, then the nodeID of the leader node is returned.

Syntax

GET LEADER [ID]

Privileges

CLUSTERADMIN, CLUSTERMONITOR

Return

A String containing the IP address and port of the leader. If the ID parameter is specified then the Integer nodeID of the leader node is returned.

Example

> GET LEADER
192.168.1.1:8860

> GET LEADER ID
3

LIST NODES

The LIST NODES command returns a rowset with information about all the nodes that compose the cluster environment. In addition to static information, this command also reports up-to-date information about the Raft status of each node.

Syntax

LIST NODES

Privileges

CLUSTERADMIN, CLUSTERMONITOR

Return

A Rowset with the following columns:

  • id: node ID
  • node: public node DNS name and port
  • cluster: DNS name and port used for Raft intra-node communication
  • status: Follower or Leader
  • progress: Probe, Replicate, Snapshot or Unknown
  • match: Raft log ID
  • last_activity: last activity date and time

Example

> LIST NODES
----|--------------------------|---------------------------|----------|-----------|-------|---------------------|
 id | node                     | cluster                   | status   | progress  | match | last_activity       |
----|--------------------------|---------------------------|----------|-----------|-------|---------------------|
 1  | dev1.sqlitecloud.io:9960 | dev1.sqlitecloud.io:10960 | Follower | Replicate | 13463 | 2023-02-08 08:17:08 |
 2  | dev2.sqlitecloud.io:9960 | dev2.sqlitecloud.io:10960 | Leader   | Replicate | 13463 | 2023-02-08 08:17:08 |
 3  | dev3.sqlitecloud.io:9960 | dev3.sqlitecloud.io:10960 | Follower | Replicate | 13463 | 2023-02-08 08:17:08 |
----|--------------------------|---------------------------|----------|-----------|-------|---------------------|

TRANSFER LEADERSHIP TO NODE

The TRANSFER LEADERSHIP TO NODE command is rarely used (primarily for debugging purposes), but it can force Raft to change its leader node to a specific nodeid. The leader node is responsible for all the write operations, so it is wise to force the most powerful node to be the leader of a Raft cluster.

Syntax

TRANSFER LEADERSHIP TO NODE nodeid

Privileges

CLUSTERADMIN

Return

OK string or error value (see SCSP protocol).

Example

> GET LEADER ID
1

> TRANSFER LEADERSHIP TO NODE 3
OK

> GET LEADER ID
3