| title | Cluster Commands |
|---|---|
| description | Cluster commands are used to manage the cluster environment, such as listing nodes, getting the leader node, and transferring leadership to a specific node. |
| category | reference |
| status | publish |
| slug | cluster-commands |
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.
GET LEADER [ID]
CLUSTERADMIN, CLUSTERMONITOR
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.
> GET LEADER
192.168.1.1:8860
> GET LEADER ID
3The 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.
LIST NODES
CLUSTERADMIN, CLUSTERMONITOR
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
> 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 |
----|--------------------------|---------------------------|----------|-----------|-------|---------------------|
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.
TRANSFER LEADERSHIP TO NODE nodeid
CLUSTERADMIN
OK string or error value (see SCSP protocol).
> GET LEADER ID
1
> TRANSFER LEADERSHIP TO NODE 3
OK
> GET LEADER ID
3