Manager Handbook for Distributed AntDB-T - P5
Tags: database
Published: 2023-08-01 06:54:38

#### monitor

---


**Command function:**

View the operational status of a specified node name or a specified node type in an AntDB cluster. The Monitor command returns two kinds of values.

running: means the node is running and accepting new connections; not running: means the node is not running.

The specific function can be viewed by the help command \\h monitor.

**Command format:**

View the running status of the node

```
MONITOR [ ALL ] 
MONITOR GTMCOORD [ ALL ] 
MONITOR GTMCOORD { MASTER | SLAVE } [ ALL | node_name ] 
MONITOR COORDINATOR { MASTER | SLAVE } [ ALL | node_name [, ...] ] 
MONITOR DATANODE [ ALL ] 
MONITOR DATANODE { MASTER | SLAVE } [ ALL | node_name [, ...] ] 
MONITOR ZONE zonename 
```

View the operational status of the agent

```
MONITOR AGENT [ ALL | host_name [, ...] ] 
```

View the status of primary and secondary stream replication

```
MONITOR HA 
MONITOR HA [ ( option ) ] [ node_name [, ...] ] 
MONITOR HA ZONE zonename 
```

**Command example:**

```sql
-- View the current running status of all nodes in the ADB cluster: 
MONITOR ALL; 
-- View the current running status of all coordinator nodes in the cluster: 
MONITOR COORDINATOR ALL; 
-- View the current running status of the nodes in the cluster with node type datanode master and node names db1 and db2: 
MONITOR DATANODE MASTER db1,db2; 
-- View the status of the cluster agent: 
MONITOR agent ; 
-- View the stream replication status of the cluster: 
MONITOR ha; 
```

#### start

**Command function:**

Starts a cluster node with the specified node name, or starts all cluster nodes of the specified node type. The specific functions can be viewed through the help command `\h start`.

**Command format:**

Start the nodes in the cluster: 

```sql
START ALL 
START GTMCOORD ALL 
START GTMCOORD { MASTER | SLAVE } node_name 
START COORDINATOR [ MASTER | SLAVE ] ALL 
START COORDINATOR { MASTER | SLAVE } node_name [, ...] 
START DATANODE ALL 
START DATANODE { MASTER | SLAVE } { ALL | node_name [, ...] } 
START ZONE zonename 
```

Start agent: 

```
START AGENT { ALL | host_name [, ...] } [ PASSWORD passwd ] 
```

**Command example:**

```sql
-- Start all nodes in the cluster: 
START ALL; 
-- Start the gtmcoord master node: 
START GTMCOORD MASTER gc; 
-- Start the nodes in the current cluster with node type datanode master and names db1 and db2: 
START DATANODE MASTER db1,db2; 
-- Start the agent on the host in the cluster: 
START AGENT all; 
```

#### stop

---


**Command function:**

This command is the opposite of the start command and stops the node with the specified name or stops all cluster nodes of the specified node type. The stop command uses the smart mode by default if no MODE is specified. There are three stop modes: smart, fast and intermediate.

- Smart: rejects new connections and waits for old connections to finish executing.
- Fast: rejects new connections and disconnects old ones, which is a safer mode to stop nodes.
- Immediate: All database connections are interrupted, used to stop the node in case of emergency.

The specific functions can be viewed through the help command `\h stop`.

**Command format:**

```sql
STOP ALL [ stop_mode ] 
STOP AGENT { ALL | host_name [, ...] } 
STOP COORDINATOR [ MASTER | SLAVE ] ALL [ stop_mode ] 
STOP COORDINATOR { MASTER | SLAVE } { node_name [, ...] } [ stop_mode ] 
STOP DATANODE ALL [ stop_mode ] 
STOP DATANODE { MASTER | SLAVE } { ALL | node_name [, ...] } [ stop_mode ] 
STOP GTMCOORD ALL [ stop_mode ] 
STOP GTMCOORD { MASTER | SLAVE } node_name [ stop_mode ] 
STOP ZONE zonename [ stop_mode ] 
where stop_mode can be one of: 
 
    MODE SMART     | MODE S 
    MODE FAST      | MODE F 
    MODE IMMEDIATE | MODE I 
```

**Command example:**

```sql
-- Use fast mode to stop all nodes in the cluster: 
STOP ALL MODE FAST; 
-- Use IMMEDIATE mode to stop all coordinator nodes: 
STOP COORDINATOR ALL MODE IMMEDIATE; 
-- Use smart mode to stop the nodes in the current cluster whose node type is datanode master and whose names are db1 and db2: 
STOP DATANODE MASTER db1,db2; or 
STOP DATANODE MASTER db1,db2 MODE SMART;	 
-- Stop the agent on the host in the cluster: 
STOP AGENT all; 
```