Manager Handbook for Distributed AntDB-T - P9
Tags: database
Published: 2023-08-07 07:07:52

#### zone

**Command function:**

zone init initializes the nodes in the secondary center. The prerequisite for executing this command is that all the nodes in the primary center have been init.

zone switchover switches user master and standby center, that is, the secondary center upgraded to the master center, the node upgraded to master node, the node of the master center down to standby. The temporary switch of user master and standby center can also be switched back later.

zone failover backup center upgraded to master, the original master node is no longer working, for the master center down and not recoverable, the vice center needs to replace the master center work scenario.

**Command format:**

```
ZONE INIT zone_name              						#Initialize all nodes in the sub-center 
ZONE SWITCHOVER zonename [FORCE] [maxTrys]  #Switchover between the primary and backup center 
ZONE FAILOVER zonename [ FORCE ]   					#Promote the backup center to the primary center 
```

Command example:

```
zone init zone2; 
zone switchover zone2 force 30; 
zone failover zone2; 
```

### Introduction to adbmgr built-in jobs

adbmgr can create a number of timed tasks, of which two types are built in: 

- Data collection tasks
- Node monitoring tasks

These two kinds of timing tasks are used when using DBOPS (an AntDB monitoring operation and maintenance tool).

The two types of tasks are described below.

Help information for adding built-in jobs can be obtained through `\h add job`.

```
postgres=# \h add job 
Command:     ADD JOB 
Description: add one row job information in the job table. The column of "interval" requires an integer value, unit is "second"; The input string of "command" column should be in single quote. If using user-defined monitor item, the input of sql string format likes 'insert into tb_name select adbmonitor_job(''host_name'', ''item_name'')', the item_name in job item table. 
 
 the common used functions for monitor are: 
 for tps qps 'select monitor_databasetps_insert_data()' 
 for database summary 'select monitor_databaseitem_insert_data()' 
 for host 'select monitor_get_hostinfo()' 
 for slow log 'select monitor_slowlog_insert_data()' 
 for gtmcoord handle 'select monitor_handle_gtmcoord( 
        name 'nodename' default '''', 
        bool bforce default true, 
        int reconnect_attempts default 3, 
        int reconnect_interval default 2, 
        int select_timeout default 15)' 
 for coordinator handle 'select monitor_handle_coordinator()' 
 for datanode handle 'select monitor_handle_datanode( 
        name 'nodename' default '''', 
        bool bforce default true, 
        int reconnect_attempts default 3, 
        int reconnect_interval default 2, 
        int select_timeout default 15) 
 
 the limit of monitor_handle_gtmcoord and monitor_handle_datanode functions: 
 2<=reconnect_attempts<=60, 2<=reconnect_interval<120, 2<=select_timeout<120 
 reconnect_interval and select_timeout unit: "second". 
Syntax: 
ADD JOB [IF NOT EXISTS] job_name ( option ) 
 
where option must be the following: 
 
    NEXTTIME = next_time, 
    INTERVAL = interval, 
    STATUS = status, 
    COMMAND = sql_string, 
    DESC = description 
```