Manager Handbook for Distributed AntDB-T - P2
Tags: database
Published: 2023-07-26 07:44:38

#### stop agent

---


**Command function:**

Stops the agent process on the specified host. The specified host needs to be in the host table, and the specific function can be viewed with the help command :\\h stop agent.

**Command format:**

```
STOP AGENT { ALL | host_name [, ...] } 
```

**Command example:**

```sql
-- Stop the agent process on all hosts in the host table: 
STOP AGENT ALL ; 
-- Stop the agent process on host1, host2 in the host table: 
STOP AGENT host1, host2 ; 
```

#### cmonitor agent

---


Command function: View the running status of the agent process on the specified host in the host table. The agent process has two running states: running and not running. The specific functions can be viewed with the help command \\h stop agent.

**Command format:**

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

**Command example:**

```sql
-- View the running status of the agent process on all hosts in the host table: 
MONITOR AGENT ALL ; 
-- View the running status of the agent process on host1, host2 hosts in the host table: 
MONITOR AGENT host1, host2 ; 
```

### host table related commands

---


Host table stores information about hosts, and host information is related to node nodes, so you must add agents to the host table before adding nodes, and you must start agent before init all cluster, and this host table is used to manage hosts and agents. The commands to manage the host table are add host, alter host, drop host, and list host, which are described below.

#### add host

---


**Command function:**

Add a new host to the host table. Parameters can be added optionally, but at least one. Default parameters will be added with default values. The specific function can be viewed by the help command \\h add host.

**Command format:**

```sql
ADD HOST [IF NOT EXISTS] host_name ( option ) 
 
where option must be the following: 
 
    ADDRESS = host_address, 
    AGENTPORT = agent_port_number, 
    ADBHOME = adb_home_path, 
    PORT = port_number, 
    PROTOCOL = protocol_type, 
    USER = user_name 
Parameter Description: 
host_address：The IP address corresponding to the hostname; hostname is not supported. 
agentport_number:The port number that the agent process listens on. 
adb_home_path：The path where the database cluster installation package is stored. 
host_name：Hostname. 
user_name：Database cluster installation user. 
protocol_type：The protocol used for database cluster installation package transfer can be telnet, ssh. only ssh is supported now. 
port_number：the port number of the protocol used by protocol_type, now only ssh is supported, the default port number is 22. 
```

**Command example:**

```sql
-- Add host_name1 information: antdb is database installation user, ssh protocol is used for database installation package transfer, the ip of host_name1 is "10.1.226.202", agent listens on port 5660, the installation package storage path is set to "/opt/antdb/app": 
ADD HOST host_name1(USER=antdb, PROTOCOL=ssh, ADDRESS='10.1.226.202', AGENTPORT=5660, adbhome='/opt/antdb/app'); 
```

#### alter host

**Command function:**

Modify the parameters in the host table, either one or more. The specific function can be viewed by the help command \\h alter host.

**Note:** After the cluster is initialized, the alter host command cannot be operated.

**Command format:**

```sql
ADD HOST [IF NOT EXISTS] host_name ( option ) 
 
where option must be the following: 
 
    ADDRESS = host_address, 
    AGENTPORT = agent_port_number, 
    ADBHOME = adb_home_path, 
    PORT = port_number, 
    PROTOCOL = protocol_type, 
    USER = user_name 
Parameter Description: 
host_name：Hostname. 
user_name：Database cluster installation user. 
protocol_type：The protocol used for database cluster installation package transfer can be telnet, ssh. only ssh is supported now. 
port_number：the port number of the protocol used by protocol_type, now only ssh is supported, the default port number is 22.  
agentport_number:The port number that the agent process listens on. 
host_address：The IP address corresponding to the hostname; hostname is not supported. 
adb_home_path：The path where the database cluster installation package is stored. 
```

**Command example:**

```sql
--Modify the agent port used by the host_name1 to 5610: 
ALTER host_name1 (AGENTPORT=5610); 
--Modify the agent port used by host_name1 to 5610, and the path to the installation package is /home/data/antdbhome ： 
ALTER host_name1 (AGENTPORT=5610, ADBHOME=’/home/data/antdbhome’); 
```

#### drop host

Command function: Drop the specified host from the host table, but the host should not be used by a dependency, or an error will be reported. The specific function can be viewed by the help command \\h drop host.

**Command format:**

```
DROP HOST [ IF EXISTS ] host_name [, … ] 
```

**Command example:**

```sql
--Consecutively deletes members of the host table with host names localhost1 and localhost2: 
DROP  HOST  localhost1, localhost2; 
--Deletes the member of the host table whose host name is localhost: 
DROP  HOST  localhost1; 
```

#### list host

**Command function:**

Display the member variables in the host table, you can display some parameters of the specified host, or all of them, or you can display the contents of all host parameters in the host table.

**Command format:**

```sql
LIST HOST  [ ( option [, ...]) ] [ host_name [, ...] ] 
where option can be one of: 
    NAME 
    USER 
    PORT 
    PROTOCOL 
    AGENTPORT 
    ADDRESS 
    ADBHOME 
Parameter Description: 
NAME：Hostname. 
USER：Database cluster installation user. 
PORT：The port number of the protocol used by protocol_type, now only ssh is supported, the default port number is 22. 
PROTOCOL：The protocol used for database cluster installation package transfer can be telnet, ssh. only ssh is supported now. 
AGENTPORT: The port number that the agent process listens on. 
ADDRESS：The IP address corresponding to the hostname. 
ADBHOME：The path where the database cluster installation package is stored. 
```

**Command example:**

```sql
--Displays information about all host members in the host table: 
LIST  host; 
--Displays information about the specified host in the host table: 
LIST  host  localhost1; 
--Displays information about the specified parameters of the specified host in the host table: 
LIST  host  (user, agentport, address)  localhost1; 
```

#### flush host

Command function: After cluster initialization, when the IP address of the machine is changed, first modify the IP addresses corresponding to all the host names in the host table through alter host, and then update the IP address information corresponding to all the database nodes through flush host.

**Command format:**

```
FLUSH HOST 
```

**Command example:**

```sql
--After the initialization of the cluster, the IP of the machine is changed, the content modification in the host table has been completed, and the IP address information of each database node needs to be refreshed: 
FLUSH HOST; 
```

> The flush host operation will reboot the slave type node because it needs to modify the primary\_conninfo information in recovery.conf.