21-node.md 5.0 KB
Newer Older
1
---
2 3
sidebar_label: Cluster
title: Cluster
4 5
---

6
The physical entities that form TDengine clusters are known as data nodes (dnodes). Each dnode is a process running on the operating system of the physical machine. Dnodes can contain virtual nodes (vnodes), which store time-series data. Virtual nodes are formed into vgroups, which have 1 or 3 vnodes depending on the replica setting. If you want to enable replication on your cluster, it must contain at least three nodes. Dnodes can also contain management nodes (mnodes). Each cluster has up to three mnodes. Finally, dnodes can contain query nodes (qnodes), which compute time-series data, thus separating compute from storage. A single dnode can contain a vnode, qnode, and mnode.
7

8
## Create a Dnode
9 10 11 12 13

```sql
CREATE DNODE {dnode_endpoint | dnode_host_name PORT port_val}
```

14
Enter the dnode_endpoint in hostname:port format. You can also specify the hostname and port as separate parameters.
15

16
Create the dnode before starting the corresponding dnode process. The dnode can then join the cluster based on the value of the firstEp parameter. Each dnode is assigned an ID after it joins a cluster.
17

18
## View Dnodes
19 20 21 22 23

```sql
SHOW DNODES;
```

24
The preceding SQL command shows all dnodes in the cluster with the ID, endpoint, and status.
25

26
## Delete a DNODE
27 28 29 30 31

```sql
DROP DNODE {dnode_id | dnode_endpoint}
```

32
You can delete a dnode by its ID or by its endpoint. Note that deleting a dnode does not stop its process. You must stop the process after the dnode is deleted.
33

34
## Modify Dnode Configuration
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64

```sql
ALTER DNODE dnode_id dnode_option

ALTER ALL DNODES dnode_option

dnode_option: {
    'resetLog'
  | 'balance' value
  | 'monitor' value
  | 'debugFlag' value
  | 'monDebugFlag' value
  | 'vDebugFlag' value
  | 'mDebugFlag' value
  | 'cDebugFlag' value
  | 'httpDebugFlag' value
  | 'qDebugflag' value
  | 'sdbDebugFlag' value
  | 'uDebugFlag' value
  | 'tsdbDebugFlag' value
  | 'sDebugflag' value
  | 'rpcDebugFlag' value
  | 'dDebugFlag' value
  | 'mqttDebugFlag' value
  | 'wDebugFlag' value
  | 'tmrDebugFlag' value
  | 'cqDebugFlag' value
}
```

65
The parameters that you can modify through this statement are the same as those located in the dnode configuration file. Modifications that you make through this statement take effect immediately, while modifications to the configuration file take effect when the dnode restarts.
66

67
## Add an Mnode
68 69 70 71 72

```sql
CREATE MNODE ON DNODE dnode_id
```

73
TDengine automatically creates an mnode on the firstEp node. You can use this statement to create more mnodes for higher system availability. A cluster can have a maximum of three mnodes. Each dnode can contain only one mnode.
74

75
## View Mnodes
76 77 78 79 80

```sql
SHOW MNODES;
```

81
This statement shows all mnodes in the cluster with the ID, dnode, and status.
82

83
## Delete an Mnode
84 85 86 87 88

```sql
DROP MNODE ON DNODE dnode_id;
```

89
This statement deletes the mnode located on the specified dnode.
90

91
## Create a Qnode
92 93 94 95 96

```sql
CREATE QNODE ON DNODE dnode_id;
```

97
TDengine does not automatically create qnodes on startup. You can create qnodes as necessary for compute/storage separation. Each dnode can contain only one qnode. If a qnode is created on a dnode whose supportVnodes parameter is not 0, a vnode and qnode may coexist on the dnode. Each dnode can have a maximum of one vnode, one qnode, and one mnode. However, you can configure your cluster so that vnodes, qnodes, and mnodes are located on separate dnodes. If you set supportVnodes to 0 for a dnode, you can then decide whether to deploy an mnode or a qnode on it. In this way you can physically separate virtual node types.
98

99
## View Qnodes
100 101 102 103 104

```sql
SHOW QNODES;
```

105
This statement shows all qnodes in the cluster with the ID and dnode.
106

107
## Delete a Qnode
108 109 110 111 112

```sql
DROP QNODE ON DNODE dnode_id;
```

113
This statement deletes the mnode located on the specified dnode. This does not affect the status of the dnode.
114

115
## Modify Client Configuration
116

117
The client configuration can also be modified in a similar way to other cluster components.
118 119 120 121 122 123 124 125 126 127 128 129 130 131

```sql
ALTER LOCAL local_option

local_option: {
    'resetLog'
  | 'rpcDebugFlag' value
  | 'tmrDebugFlag' value
  | 'cDebugFlag' value
  | 'uDebugFlag' value
  | 'debugFlag' value
}
```

132
The parameters that you can modify through this statement are the same as those located in the client configuration file. Modifications that you make through this statement take effect immediately, while modifications to the configuration file take effect when the client restarts.
133

134
## View Client Configuration
135 136 137 138 139

```sql
SHOW LOCAL VARIABLES;
```

140
## Combine Vgroups
141 142 143 144 145

```sql
MERGE VGROUP vgroup_no1 vgroup_no2;
```

146
If load and data are not properly balanced among vgroups due to the data in different tim lines having different characteristics, you can combine or separate vgroups.
147

148
## Separate Vgroups
149 150 151 152 153

```sql
SPLIT VGROUP vgroup_no;
```

154
This statement creates a new vgroup and migrates part of the data from the original vgroup to the new vgroup with consistent hashing. During this process, the original vgroup can continue to provide services normally.