You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by qi...@apache.org on 2022/08/12 03:46:51 UTC
[iotdb] branch master updated: [IOTDB-4113] Update Cluster-Setup UserGuide (#6970)
This is an automated email from the ASF dual-hosted git repository.
qiaojialin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git
The following commit(s) were added to refs/heads/master by this push:
new aadb5f5ff7 [IOTDB-4113] Update Cluster-Setup UserGuide (#6970)
aadb5f5ff7 is described below
commit aadb5f5ff7b80d2406eac79867cd599957dcdd5c
Author: YongzaoDan <33...@users.noreply.github.com>
AuthorDate: Fri Aug 12 11:46:46 2022 +0800
[IOTDB-4113] Update Cluster-Setup UserGuide (#6970)
---
.../confignode/service/ConfigNodeCommandLine.java | 2 +-
docs/UserGuide/Cluster/Cluster-Setup.md | 279 +++++++++++++++++----
.../Maintenance-Tools/Maintenance-Command.md | 242 +++++++++---------
docs/zh/UserGuide/Cluster/Cluster-Setup.md | 270 ++++++++++++++++----
.../Maintenance-Tools/Maintenance-Command.md | 236 ++++++++---------
5 files changed, 689 insertions(+), 340 deletions(-)
diff --git a/confignode/src/main/java/org/apache/iotdb/confignode/service/ConfigNodeCommandLine.java b/confignode/src/main/java/org/apache/iotdb/confignode/service/ConfigNodeCommandLine.java
index 124b765449..ae36f91a92 100644
--- a/confignode/src/main/java/org/apache/iotdb/confignode/service/ConfigNodeCommandLine.java
+++ b/confignode/src/main/java/org/apache/iotdb/confignode/service/ConfigNodeCommandLine.java
@@ -95,7 +95,7 @@ public class ConfigNodeCommandLine extends ServerCommandLine {
private void doRemoveNode(String[] args) throws IOException {
LOGGER.info("Starting to remove {}...", ConfigNodeConstant.GLOBAL_NAME);
if (args.length != 3) {
- LOGGER.info("Usage: -r <ip>:<rpcPort>");
+ LOGGER.info("Usage: -r <internal_address>:<internal_port>");
return;
}
diff --git a/docs/UserGuide/Cluster/Cluster-Setup.md b/docs/UserGuide/Cluster/Cluster-Setup.md
index f8f477e9a7..eed7fb3869 100644
--- a/docs/UserGuide/Cluster/Cluster-Setup.md
+++ b/docs/UserGuide/Cluster/Cluster-Setup.md
@@ -25,17 +25,17 @@ This article is the setup process of IoTDB Cluster (0.14.0-preview1).
## Environments
-1. JDK>=1.8
+1. JDK>=1.8.
-2. Max open file 65535
+2. Max open file 65535.
-3. Disable the swap memory
+3. Disable the swap memory.
## Get the binary distribution
### Download
-Download the binary distribution from website [Download Page](https://iotdb.apache.org/Download/)
+Download the binary distribution from website [Download Page](https://iotdb.apache.org/Download/).
### Compiled from source code
@@ -45,7 +45,7 @@ Download the source code:
git clone https://github.com/apache/iotdb.git
```
-The default branch is master, you could checkout to the release tag:
+The default branch is master, you should checkout to the release tag:
```
git checkout v0.14.0-preview1
@@ -57,17 +57,17 @@ Under the source root folder:
mvn clean package -pl distribution -am -DskipTests
```
-Then you will get the binary distribution under **distribution/target**, in which the **all-bin** contains ConfigNode and DataNode,and DataNode contains the Cli.
+Then you will get the binary distribution under **distribution/target**, in which the **all-bin** contains ConfigNode and DataNode, and DataNode contains the Cli.
## Binary Distribution Content
-| **Folder** | **Description** |
-| -------- | -------------------------------------------- |
-| confignode | Contains start/stop shell, configurations, logs, data of ConfigNode |
-| datanode | Contains start/stop shell, configurations, logs, data of DataNode, cli shell|
-| grafana-metrics-example | Grafana metric page module |
-| lib | Jar files folder |
-| tools | System tools |
+| **Folder** | **Description** |
+|-------------------------|-------------------------------------------------------------------------------------|
+| confignode | Contains start/stop/remove shell, configurations, logs, data of ConfigNode |
+| datanode | Contains start/stop/remove shell, configurations, logs, data of DataNode, cli shell |
+| grafana-metrics-example | Grafana metric page module |
+| lib | Jar files folder |
+| tools | System tools |
## Start the Cluster
@@ -84,18 +84,18 @@ The total process are three steps:
Please set the important parameters in iotdb-confignode.properties:
-| **Configuration** | **Description** |
-| -------- | -------------------------------------------- |
-| internal\_address | Internal rpc service address of ConfigNode |
-| internal\_port | Internal rpc service address of ConfigNode |
-| consensus\_port | ConfigNode replication consensus protocol communication port |
-| target\_config\_nodes | Target ConfigNode address, if the current is the first ConfigNode, then set its address:port |
-| data\_replication\_factor | Data replication factor, no more than DataNode number |
-| data\_region\_consensus\_protocol\_class | Consensus protocol of data replicas |
-| schema\_replication\_factor | Schema replication factor, no more than DataNode number |
-| schema\_region\_consensus\_protocol\_class | Consensus protocol of schema replicas |
-
-Start on Linux
+| **Configuration** | **Description** |
+|--------------------------------------------|----------------------------------------------------------------------------------------------|
+| internal\_address | Internal rpc service address of ConfigNode |
+| internal\_port | Internal rpc service address of ConfigNode |
+| consensus\_port | ConfigNode replication consensus protocol communication port |
+| target\_config\_nodes | Target ConfigNode address, if the current is the first ConfigNode, then set its address:port |
+| data\_replication\_factor | Data replication factor, no more than DataNode number |
+| data\_region\_consensus\_protocol\_class | Consensus protocol of data replicas |
+| schema\_replication\_factor | Schema replication factor, no more than DataNode number |
+| schema\_region\_consensus\_protocol\_class | Consensus protocol of schema replicas |
+
+Start on Linux:
```
# Foreground
./confignode/sbin/start-confignode.sh
@@ -104,12 +104,12 @@ Start on Linux
nohup ./confignode/sbin/start-confignode.sh >/dev/null 2>&1 &
```
-Start on Windows
+Start on Windows:
```
confignode\sbin\start-confignode.bat
```
-More details [ConfigNode Configurations](https://iotdb.apache.org/UserGuide/Master/Reference/ConfigNode-Config-Manual.html)
+More details [ConfigNode Configurations](https://iotdb.apache.org/UserGuide/Master/Reference/ConfigNode-Config-Manual.html).
### Add ConfigNode (Optional)
@@ -121,20 +121,20 @@ The adding ConfigNode also use the start-confignode.sh/bat.
You could add any number of DataNode.
-Please set the important parameters in iotdb-datanode.properties
+Please set the important parameters in iotdb-datanode.properties.
-| **Configuration** | **Description** |
-| -------- | -------------------------------------------- |
-| rpc\_address | Client RPC Service address |
-| rpc\_port | Client RPC Service port |
-| internal\_address | Control flow address of DataNode inside cluster |
-| internal\_port | Control flow port of DataNode inside cluster |
-| mpp\_data\_exchange\_port | Data flow port of DataNode inside cluster |
-| data\_region\_consensus\_port | Data replicas communication port for consensus |
-| schema\_region\_consensus\_port | Schema replicas communication port for consensus |
-| target\_config\_nodes | Running ConfigNode of the Cluster |
+| **Configuration** | **Description** |
+|---------------------------------|--------------------------------------------------|
+| rpc\_address | Client RPC Service address |
+| rpc\_port | Client RPC Service port |
+| internal\_address | Control flow address of DataNode inside cluster |
+| internal\_port | Control flow port of DataNode inside cluster |
+| mpp\_data\_exchange\_port | Data flow port of DataNode inside cluster |
+| data\_region\_consensus\_port | Data replicas communication port for consensus |
+| schema\_region\_consensus\_port | Schema replicas communication port for consensus |
+| target\_config\_nodes | Running ConfigNode of the Cluster |
-Start on Linux
+Start on Linux:
```
# Foreground
./datanode/sbin/start-datanode.sh
@@ -143,38 +143,215 @@ Start on Linux
nohup ./datanode/sbin/start-datanode.sh >/dev/null 2>&1 &
```
-Start on Windows
+Start on Windows:
```
datanode\sbin\start-datanode.bat
```
-More details [DataNode Configurations](https://iotdb.apache.org/UserGuide/Master/Reference/DataNode-Config-Manual.html)
+More details [DataNode Configurations](https://iotdb.apache.org/UserGuide/Master/Reference/DataNode-Config-Manual.html).
### Start Cli
-Cli is in datanode/sbin folder
+Cli is in datanode/sbin folder.
-Start on Linux
+Start on Linux:
```
./datanode/sbin/start-cli.sh
```
-Start on Windows
+Start on Windows:
```
datanode\sbin\start-cli.bat
```
+## Shrink the Cluster
+
+### Remove ConfigNode
+
+Execute the remove-confignode shell on an active ConfigNode.
+
+Remove on Linux:
+```
+./confignode/sbin/remove-confignode.sh -r <internal_address>:<internal_port>
+```
+
+### Remove DataNode
+
+Execute the remove-datanode shell on an active DataNode.
+
+Remove on Linux:
+
++ Remove a DataNode:
+```
+./datanode/sbin/remove-datanode.sh <rpc_address>:<rpc_port>
+```
+
++ Remove multiple DataNodes:
+```
+./datanode/sbin/remove-datanode.sh <rpc_address_0>:<rpc_port_0>,...,<rpc_address_n>:<rpc_port_n>
+```
+
+Remove on Windows:
+
++ Remove a DataNode:
+```
+datanode\sbin\remove-datanode.bat <rpc_address>:<rpc_port>
+```
+
++ Remove multiple DataNodes:
+```
+datanode\sbin\remove-datanode.bat <rpc_address_0>:<rpc_port_0>,...,<rpc_address_n>:<rpc_port_n>
+```
+
## Quick Start
-unzip apache-iotdb-0.14.0-preview1-all-bin.zip
+This section uses a local environment as an example to
+illustrate how to start, expand, and shrink a IoTDB Cluster.
+
+### 1. Prepare the Start Environment
+
+Unzip the apache-iotdb-0.14.0-preview1-all-bin.zip file to cluster0 folder.
+
+### 2. Starting a Minimum Cluster
-Deploy a one-ConfigNode and one-DataNode(1C1D)cluster, default is one replica.
+Starting the Cluster version with one ConfigNode and one DataNode(1C1D),
+the default number of replica is one.
```
-./confignode/sbin/start-confignode.sh
-./datanode/sbin/start-datanode.sh
+./cluster0/confignode/sbin/start-confignode.sh
+./cluster0/datanode/sbin/start-datanode.sh
```
-Start Cli
+### 3. Verify the Minimum Cluster
+
++ The minimum cluster is successfully started. Start the Cli for verification.
+```
+./cluster0/datanode/sbin/start-cli.sh
+```
+
++ Execute the [show cluster](https://iotdb.apache.org/UserGuide/Master/Maintenance-Tools/Maintenance-Command.html#show-all-node-information)
+ command on the Cli. The result is shown below:
+```
+IoTDB> show cluster
++------+----------+-------+---------+-----+
+|NodeID| NodeType| Status| Host| Port|
++------+----------+-------+---------+-----+
+| 0|ConfigNode|Running| 0.0.0.0|22277|
+| 1| DataNode|Running|127.0.0.1| 9003|
++------+----------+-------+---------+-----+
+Total line number = 2
+It costs 0.160s
+```
+
+### 4. Prepare the Expanding Environment
+
+Unzip the apache-iotdb-0.14.0-preview1-all-bin.zip file to cluster1 and cluster2 folder.
+
+### 5. Modify the Node Configuration file
+
+For folder cluster1:
+
++ Modify ConfigNode address:
+
+| **configuration item** | **value** |
+|------------------------|---------------|
+| internal\_address | 0.0.0.0 |
+| internal\_port | 22279 |
+| consensus\_port | 22280 |
+| target\_config\_nodes | 0.0.0.0:22277 |
+
++ Modify DataNode address:
+
+| **configuration item** | **value** |
+|---------------------------------|-----------------|
+| rpc\_address | 0.0.0.0 |
+| rpc\_port | 6668 |
+| internal\_address | 127.0.0.1 |
+| internal\_port | 9004 |
+| mpp\_data\_exchange\_port | 8778 |
+| data\_region\_consensus\_port | 40011 |
+| schema\_region\_consensus\_port | 50011 |
+| target\_config\_nodes | 127.0.0.1:22277 |
+
+For folder cluster1:
+
++ Modify ConfigNode address:
+
+| **configuration item** | **value** |
+|------------------------|---------------|
+| internal\_address | 0.0.0.0 |
+| internal\_port | 22281 |
+| consensus\_port | 22282 |
+| target\_config\_nodes | 0.0.0.0:22277 |
+
++ Modify DataNode address:
+
+| **configuration item** | **value** |
+|---------------------------------|-----------------|
+| rpc\_address | 0.0.0.0 |
+| rpc\_port | 6669 |
+| internal\_address | 127.0.0.1 |
+| internal\_port | 9005 |
+| mpp\_data\_exchange\_port | 8779 |
+| data\_region\_consensus\_port | 40012 |
+| schema\_region\_consensus\_port | 50012 |
+| target\_config\_nodes | 127.0.0.1:22277 |
+
+### 6. Expanding the Cluster
+
+Expanding the Cluster to three ConfigNode and three DataNode(3C3D).
+The following commands can be executed in no particular order.
+
+```
+./cluster1/confignode/sbin/start-confignode.sh
+./cluster1/datanode/sbin/start-datanode.sh
+./cluster2/confignode/sbin/start-confignode.sh
+./cluster2/datanode/sbin/start-datanode.sh
+```
+
+### 7. Verify Cluster expansion
+
+Execute the show cluster command, the result is shown below:
+```
+IoTDB> show cluster
++------+----------+-------+---------+-----+
+|NodeID| NodeType| Status| Host| Port|
++------+----------+-------+---------+-----+
+| 0|ConfigNode|Running| 0.0.0.0|22277|
+| 2|ConfigNode|Running| 0.0.0.0|22279|
+| 3|ConfigNode|Running| 0.0.0.0|22281|
+| 1| DataNode|Running|127.0.0.1| 9003|
+| 4| DataNode|Running|127.0.0.1| 9004|
+| 5| DataNode|Running|127.0.0.1| 9005|
++------+----------+-------+---------+-----+
+Total line number = 6
+It costs 0.012s
+```
+
+### 8. Shrinking the Cluster
+
++ Remove a ConfigNode:
+```
+./cluster0/confignode/sbin/remove-confignode.sh -r 0.0.0.0:22279
+```
+
++ Remove a DataNode:
+```
+./cluster0/datanode/sbin/remove-datanode.sh 127.0.0.1:6668
+```
+
+### 9. Verify Cluster shrinkage
+
+Execute the show cluster command, the result is shown below:
+```
+IoTDB> show cluster
++------+----------+-------+---------+-----+
+|NodeID| NodeType| Status| Host| Port|
++------+----------+-------+---------+-----+
+| 0|ConfigNode|Running| 0.0.0.0|22277|
+| 3|ConfigNode|Running| 0.0.0.0|22281|
+| 1| DataNode|Running|127.0.0.1| 9003|
+| 5| DataNode|Running|127.0.0.1| 9005|
++------+----------+-------+---------+-----+
+Total line number = 4
+It costs 0.007s
```
-./datanode/sbin/start-cli.sh
-```
\ No newline at end of file
diff --git a/docs/UserGuide/Maintenance-Tools/Maintenance-Command.md b/docs/UserGuide/Maintenance-Tools/Maintenance-Command.md
index 53c3fced41..a6ce0f9827 100644
--- a/docs/UserGuide/Maintenance-Tools/Maintenance-Command.md
+++ b/docs/UserGuide/Maintenance-Tools/Maintenance-Command.md
@@ -127,127 +127,6 @@ To get the executing `queryId`,you can use the `show query processlist` comman
The maximum display length of statement is 64 characters. For statements with more than 64 characters, the intercepted part will be displayed.
-
-
-## Monitoring tool for cluster Region distribution
-
-A cluster uses a Region as a unit for data replication and data management . The Region status and distribution is helpful for system operation and maintenance testing , as shown in the following scenario :
-
-- Check which Datanodes are allocated to each Region in the cluster and whether the balance is correct.
-
-Currently, IoTDB supports Region query using the following SQL:
-
-- `SHOW REGIONS`: Show all Region
-- `SHOW SCHEMA REGIONS`: Show all SchemaRegion distribution
-- `SHOW DATA REGIONS`: Show all DataRegion distribution
-- `SHOW (DATA|SCHEMA)? REGIONS OF STORAGE GROUP <sg1,sg2,...>`: Show region distribution of specified storage groups
-
-First, let's take a look at the distribution of Regions under three copies:
-
-```
-IoTDB> create timeseries root.sg.d1.s1 with datatype=BOOLEAN,encoding=PLAIN
-Msg: The statement is executed successfully.
-IoTDB> create timeseries root.sg.d2.s1 with datatype=BOOLEAN,encoding=PLAIN
-Msg: The statement is executed successfully.
-IoTDB> create timeseries root.ln.d1.s1 with datatype=BOOLEAN,encoding=PLAIN
-Msg: The statement is executed successfully.
-
-+--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
-|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port| Role|
-+--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
-| 0|SchemaRegion| Up| root.sg| 2| 0| 5|127.0.0.1|6671|Follower|
-| 0|SchemaRegion| Up| root.sg| 2| 0| 4|127.0.0.1|6669|Follower|
-| 0|SchemaRegion| Up| root.sg| 2| 0| 3|127.0.0.1|6667| Leader|
-| 1|SchemaRegion| Up| root.ln| 1| 0| 5|127.0.0.1|6671|Follower|
-| 1|SchemaRegion| Up| root.ln| 1| 0| 4|127.0.0.1|6669|Follower|
-| 1|SchemaRegion| Up| root.ln| 1| 0| 3|127.0.0.1|6667| Leader|
-+--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
-Total line number = 6
-It costs 0.032s
-```
-
-Then take a look at the distribution of Regions under a single copy:
-
-
-```sql
-IoTDB> show regions
-+--------+------------+------+-------------+------------+----------+----------+---------+----+------+
-|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port| Role|
-+--------+------------+------+-------------+------------+----------+----------+---------+----+------+
-| 0|SchemaRegion| Up| root.sg| 2| 0| 5|127.0.0.1|6671|Leader|
-| 1|SchemaRegion| Up| root.ln| 1| 0| 4|127.0.0.1|6669|Leader|
-+--------+------------+------+-------------+------------+----------+----------+---------+----+------+
-Total line number = 2
-It costs 0.128s
-```
-
-Show the distribution information of Schema Region and Data Region:
-
-```
-IoTDB> insert into root.sg.d1(timestamp,s1) values(1,true)
-Msg: The statement is executed successfully.
-IoTDB> insert into root.ln.d1(timestamp,s1) values(1,true)
-Msg: The statement is executed successfully.
-
-IoTDB> show data regions
-+--------+----------+------+-------------+------------+----------+----------+---------+----+--------+
-|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port| Role|
-+--------+----------+------+-------------+------------+----------+----------+---------+----+--------+
-| 2|DataRegion| Up| root.sg| 1| 1| 5|127.0.0.1|6671|Follower|
-| 2|DataRegion| Up| root.sg| 1| 1| 4|127.0.0.1|6669| Leader|
-| 2|DataRegion| Up| root.sg| 1| 1| 3|127.0.0.1|6667|Follower|
-| 3|DataRegion| Up| root.ln| 1| 1| 5|127.0.0.1|6671| Leader|
-| 3|DataRegion| Up| root.ln| 1| 1| 4|127.0.0.1|6669|Follower|
-| 3|DataRegion| Up| root.ln| 1| 1| 3|127.0.0.1|6667|Follower|
-+--------+----------+------+-------------+------------+----------+----------+---------+----+--------+
-Total line number = 2
-It costs 0.011s
-IoTDB> show schema regions
-+--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
-|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port| Role|
-+--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
-| 0|SchemaRegion| Up| root.sg| 2| 0| 5|127.0.0.1|6671|Follower|
-| 0|SchemaRegion| Up| root.sg| 2| 0| 4|127.0.0.1|6669| Leader|
-| 0|SchemaRegion| Up| root.sg| 2| 0| 3|127.0.0.1|6667|Follower|
-| 1|SchemaRegion| Up| root.ln| 1| 0| 5|127.0.0.1|6671|Follower|
-| 1|SchemaRegion| Up| root.ln| 1| 0| 4|127.0.0.1|6669|Follower|
-| 1|SchemaRegion| Up| root.ln| 1| 0| 3|127.0.0.1|6667| Leader|
-+--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
-Total line number = 2
-It costs 0.012s
-```
-
-Show region distribution of specified storage groups
-
-```
-IoTDB> show regions of storage group root.sg
-+--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
-|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port| Role|
-+--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
-| 0|SchemaRegion| Up| root.sg| 2| 0| 5|127.0.0.1|6671|Follower|
-| 0|SchemaRegion| Up| root.sg| 2| 0| 4|127.0.0.1|6669| Leader|
-| 0|SchemaRegion| Up| root.sg| 2| 0| 3|127.0.0.1|6667|Follower|
-| 2| DataRegion| Up| root.sg| 1| 1| 5|127.0.0.1|6671|Follower|
-| 2| DataRegion| Up| root.sg| 1| 1| 4|127.0.0.1|6669| Leader|
-| 2| DataRegion| Up| root.sg| 1| 1| 3|127.0.0.1|6667|Follower|
-+--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
-Total line number = 2
-It costs 0.005s
-
-IoTDB> create timeseries root.sgcc.wf01.d1.wt01 with datatype=BOOLEAN,encoding=PLAIN
-Msg: The statement is executed successfully.
-IoTDB> show regions of storage group root.*.wf01
-+--------+------------+------+--------------+------------+----------+----------+---------+----+--------+
-|RegionId| Type|Status| storage group|Series Slots|Time Slots|DataNodeId| Host|Port| Role|
-+--------+------------+------+--------------+------------+----------+----------+---------+----+--------+
-| 4|SchemaRegion| Up|root.sgcc.wf01| 1| 0| 5|127.0.0.1|6671| Leader|
-| 4|SchemaRegion| Up|root.sgcc.wf01| 1| 0| 4|127.0.0.1|6669|Follower|
-| 4|SchemaRegion| Up|root.sgcc.wf01| 1| 0| 3|127.0.0.1|6667|Follower|
-+--------+------------+------+--------------+------------+----------+----------+---------+----+--------+
-Total line number = 3
-It costs 0.012s
-```
-
## Monitoring tool for cluster Node distribution
### Show all DataNode information
@@ -365,7 +244,7 @@ It costs 0.009s
### Show all Node information
- Currently, iotdb supports the following SQL to view the information of all nodes :
+Currently, iotdb supports the following SQL to view the information of all nodes :
```
SHOW CLUSTER
@@ -407,3 +286,122 @@ Total line number = 6
It costs 0.012s
```
+## Monitoring tool for cluster Region distribution
+
+A cluster uses a Region as a unit for data replication and data management . The Region status and distribution is helpful for system operation and maintenance testing , as shown in the following scenario :
+
+- Check which Datanodes are allocated to each Region in the cluster and whether the balance is correct.
+
+Currently, IoTDB supports Region query using the following SQL:
+
+- `SHOW REGIONS`: Show all Region
+- `SHOW SCHEMA REGIONS`: Show all SchemaRegion distribution
+- `SHOW DATA REGIONS`: Show all DataRegion distribution
+- `SHOW (DATA|SCHEMA)? REGIONS OF STORAGE GROUP <sg1,sg2,...>`: Show region distribution of specified storage groups
+
+First, let's take a look at the distribution of Regions under three copies:
+
+```
+IoTDB> create timeseries root.sg.d1.s1 with datatype=BOOLEAN,encoding=PLAIN
+Msg: The statement is executed successfully.
+IoTDB> create timeseries root.sg.d2.s1 with datatype=BOOLEAN,encoding=PLAIN
+Msg: The statement is executed successfully.
+IoTDB> create timeseries root.ln.d1.s1 with datatype=BOOLEAN,encoding=PLAIN
+Msg: The statement is executed successfully.
+
++--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
+|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port| Role|
++--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
+| 0|SchemaRegion| Up| root.sg| 2| 0| 5|127.0.0.1|6671|Follower|
+| 0|SchemaRegion| Up| root.sg| 2| 0| 4|127.0.0.1|6669|Follower|
+| 0|SchemaRegion| Up| root.sg| 2| 0| 3|127.0.0.1|6667| Leader|
+| 1|SchemaRegion| Up| root.ln| 1| 0| 5|127.0.0.1|6671|Follower|
+| 1|SchemaRegion| Up| root.ln| 1| 0| 4|127.0.0.1|6669|Follower|
+| 1|SchemaRegion| Up| root.ln| 1| 0| 3|127.0.0.1|6667| Leader|
++--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
+Total line number = 6
+It costs 0.032s
+```
+
+Then take a look at the distribution of Regions under a single copy:
+
+
+```sql
+IoTDB> show regions
++--------+------------+------+-------------+------------+----------+----------+---------+----+------+
+|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port| Role|
++--------+------------+------+-------------+------------+----------+----------+---------+----+------+
+| 0|SchemaRegion| Up| root.sg| 2| 0| 5|127.0.0.1|6671|Leader|
+| 1|SchemaRegion| Up| root.ln| 1| 0| 4|127.0.0.1|6669|Leader|
++--------+------------+------+-------------+------------+----------+----------+---------+----+------+
+Total line number = 2
+It costs 0.128s
+```
+
+Show the distribution information of Schema Region and Data Region:
+
+```
+IoTDB> insert into root.sg.d1(timestamp,s1) values(1,true)
+Msg: The statement is executed successfully.
+IoTDB> insert into root.ln.d1(timestamp,s1) values(1,true)
+Msg: The statement is executed successfully.
+
+IoTDB> show data regions
++--------+----------+------+-------------+------------+----------+----------+---------+----+--------+
+|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port| Role|
++--------+----------+------+-------------+------------+----------+----------+---------+----+--------+
+| 2|DataRegion| Up| root.sg| 1| 1| 5|127.0.0.1|6671|Follower|
+| 2|DataRegion| Up| root.sg| 1| 1| 4|127.0.0.1|6669| Leader|
+| 2|DataRegion| Up| root.sg| 1| 1| 3|127.0.0.1|6667|Follower|
+| 3|DataRegion| Up| root.ln| 1| 1| 5|127.0.0.1|6671| Leader|
+| 3|DataRegion| Up| root.ln| 1| 1| 4|127.0.0.1|6669|Follower|
+| 3|DataRegion| Up| root.ln| 1| 1| 3|127.0.0.1|6667|Follower|
++--------+----------+------+-------------+------------+----------+----------+---------+----+--------+
+Total line number = 2
+It costs 0.011s
+IoTDB> show schema regions
++--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
+|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port| Role|
++--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
+| 0|SchemaRegion| Up| root.sg| 2| 0| 5|127.0.0.1|6671|Follower|
+| 0|SchemaRegion| Up| root.sg| 2| 0| 4|127.0.0.1|6669| Leader|
+| 0|SchemaRegion| Up| root.sg| 2| 0| 3|127.0.0.1|6667|Follower|
+| 1|SchemaRegion| Up| root.ln| 1| 0| 5|127.0.0.1|6671|Follower|
+| 1|SchemaRegion| Up| root.ln| 1| 0| 4|127.0.0.1|6669|Follower|
+| 1|SchemaRegion| Up| root.ln| 1| 0| 3|127.0.0.1|6667| Leader|
++--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
+Total line number = 2
+It costs 0.012s
+```
+
+Show region distribution of specified storage groups
+
+```
+IoTDB> show regions of storage group root.sg
++--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
+|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port| Role|
++--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
+| 0|SchemaRegion| Up| root.sg| 2| 0| 5|127.0.0.1|6671|Follower|
+| 0|SchemaRegion| Up| root.sg| 2| 0| 4|127.0.0.1|6669| Leader|
+| 0|SchemaRegion| Up| root.sg| 2| 0| 3|127.0.0.1|6667|Follower|
+| 2| DataRegion| Up| root.sg| 1| 1| 5|127.0.0.1|6671|Follower|
+| 2| DataRegion| Up| root.sg| 1| 1| 4|127.0.0.1|6669| Leader|
+| 2| DataRegion| Up| root.sg| 1| 1| 3|127.0.0.1|6667|Follower|
++--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
+Total line number = 2
+It costs 0.005s
+
+IoTDB> create timeseries root.sgcc.wf01.d1.wt01 with datatype=BOOLEAN,encoding=PLAIN
+Msg: The statement is executed successfully.
+IoTDB> show regions of storage group root.*.wf01
++--------+------------+------+--------------+------------+----------+----------+---------+----+--------+
+|RegionId| Type|Status| storage group|Series Slots|Time Slots|DataNodeId| Host|Port| Role|
++--------+------------+------+--------------+------------+----------+----------+---------+----+--------+
+| 4|SchemaRegion| Up|root.sgcc.wf01| 1| 0| 5|127.0.0.1|6671| Leader|
+| 4|SchemaRegion| Up|root.sgcc.wf01| 1| 0| 4|127.0.0.1|6669|Follower|
+| 4|SchemaRegion| Up|root.sgcc.wf01| 1| 0| 3|127.0.0.1|6667|Follower|
++--------+------------+------+--------------+------------+----------+----------+---------+----+--------+
+Total line number = 3
+It costs 0.012s
+```
+
diff --git a/docs/zh/UserGuide/Cluster/Cluster-Setup.md b/docs/zh/UserGuide/Cluster/Cluster-Setup.md
index 1a92a9c0ae..1eb7b0eff0 100644
--- a/docs/zh/UserGuide/Cluster/Cluster-Setup.md
+++ b/docs/zh/UserGuide/Cluster/Cluster-Setup.md
@@ -35,7 +35,7 @@
### 下载
-可以直接在官网下载二进制版本 [Download Page](https://iotdb.apache.org/Download/)
+可以直接在官网下载二进制版本 [Download Page](https://iotdb.apache.org/Download/)。
### 源码编译
@@ -61,20 +61,20 @@ mvn clean package -pl distribution -am -DskipTests
## 安装包说明
-| **目录** | **说明** |
-| -------- | -------------------------------------------- |
-| confignode | 包含 ConfigNode 的启停脚本、配置文件、日志、数据 |
-| datanode | 包含 DataNode 的启停脚本、配置文件、日志、数据;Cli的启动脚本 |
-| grafana-metrics-example | Grafana 监控界面模板 |
-| lib | 库文件目录 |
-| tools | 系统工具目录 |
+| **目录** | **说明** |
+|-------------------------|-----------------------------------------|
+| confignode | 包含 ConfigNode 的启停移除脚本、配置文件、日志、数据 |
+| datanode | 包含 DataNode 的启停移除脚本、配置文件、日志、数据;Cli的启动脚本 |
+| grafana-metrics-example | Grafana 监控界面模板 |
+| lib | 库文件目录 |
+| tools | 系统工具目录 |
## 启动集群
用户可以启动包括若干 ConfigNode 和 DataNode 的集群。
集群可以提供服务的标准是至少启动一个 ConfigNode 且启动 不小于(数据/元数据)副本个数 的 DataNode。
-总体启动流程分为三步
+总体启动流程分为三步:
* 启动种子 ConfigNode
* 增加 ConfigNode(可选)
@@ -84,18 +84,18 @@ mvn clean package -pl distribution -am -DskipTests
对 confignode/conf/iotdb-confignode.properties 中的重要参数进行配置:
-| **配置项** | **说明** |
-| -------- | -------------------------------------------- |
-| internal\_address | ConfigNode 在集群内部通讯使用的地址 |
-| internal\_port | ConfigNode 在集群内部通讯使用的端口 |
-| consensus\_port | ConfigNode 副本组共识协议通信使用的端口 |
-| target\_config\_nodes | 种子 ConfigNode 地址,第一个 ConfigNode 配置自己的 address:port |
-| data\_replication\_factor | 数据副本数,DataNode 数量不应少于此数目 |
-| data\_region\_consensus\_protocol\_class | 数据副本组的共识协议 |
-| schema\_replication\_factor | 元数据副本数,DataNode 数量不应少于此数目 |
-| schema\_region\_consensus\_protocol\_class | 元数据副本组的共识协议 |
-
-Linux 启动方式
+| **配置项** | **说明** |
+|--------------------------------------------|----------------------------------------------------|
+| internal\_address | ConfigNode 在集群内部通讯使用的地址 |
+| internal\_port | ConfigNode 在集群内部通讯使用的端口 |
+| consensus\_port | ConfigNode 副本组共识协议通信使用的端口 |
+| target\_config\_nodes | 种子 ConfigNode 地址,第一个 ConfigNode 配置自己的 address:port |
+| data\_replication\_factor | 数据副本数,DataNode 数量不应少于此数目 |
+| data\_region\_consensus\_protocol\_class | 数据副本组的共识协议 |
+| schema\_replication\_factor | 元数据副本数,DataNode 数量不应少于此数目 |
+| schema\_region\_consensus\_protocol\_class | 元数据副本组的共识协议 |
+
+Linux 启动方式:
```
# 前台启动
./confignode/sbin/start-confignode.sh
@@ -104,7 +104,7 @@ Linux 启动方式
nohup ./confignode/sbin/start-confignode.sh >/dev/null 2>&1 &
```
-Windows 启动方式
+Windows 启动方式:
```
confignode\sbin\start-confignode.bat
```
@@ -113,29 +113,29 @@ confignode\sbin\start-confignode.bat
### 增加 ConfigNode(可选)
-增加 ConfigNode 是一个扩容操作,除端口不能冲突外,其他参数需要与集群已有的 ConfigNode 保持一致,并将 config\_nodes 配置为集群已有节点。
+增加 ConfigNode 是一个扩容操作,除 IP 和端口不能冲突外,上述其它重要参数需要与集群已有的 ConfigNode 保持一致,并将 target\_config\_nodes 配置为集群活跃的 ConfigNode。
启动方式同上。
### 增加 DataNode
-可以像集群中添加任意个 DataNode。
+可以向集群中添加任意个 DataNode。
-iotdb-datanode.properties 中的重要配置如下
+iotdb-datanode.properties 中的重要配置如下:
-| **配置项** | **说明** |
-| -------- | -------------------------------------------- |
-| rpc\_address | 客户端 RPC 服务的地址 |
-| rpc\_port | 客户端 RPC 服务的端口 |
-| internal\_address | DataNode 在集群内部接收控制流使用的端口 |
-| internal\_port | DataNode 在集群内部接收控制流使用的端口 |
-| mpp\_data\_exchange\_port | DataNode 在集群内部接收数据流使用的端口 |
-| data\_region\_consensus\_port | DataNode 的数据副本间共识协议通信的端口 |
-| schema\_region\_consensus\_port | DataNode 的元数据副本间共识协议通信的端口 |
-| target\_config\_nodes | 集群中正在运行的 ConfigNode 地址 |
+| **配置项** | **说明** |
+|---------------------------------|---------------------------|
+| rpc\_address | 客户端 RPC 服务的地址 |
+| rpc\_port | 客户端 RPC 服务的端口 |
+| internal\_address | DataNode 在集群内部接收控制流使用的端口 |
+| internal\_port | DataNode 在集群内部接收控制流使用的端口 |
+| mpp\_data\_exchange\_port | DataNode 在集群内部接收数据流使用的端口 |
+| data\_region\_consensus\_port | DataNode 的数据副本间共识协议通信的端口 |
+| schema\_region\_consensus\_port | DataNode 的元数据副本间共识协议通信的端口 |
+| target\_config\_nodes | 集群中正在运行的 ConfigNode 地址 |
-Linux 启动方式
+Linux 启动方式:
```
# 前台启动
./datanode/sbin/start-datanode.sh
@@ -144,38 +144,212 @@ Linux 启动方式
nohup ./datanode/sbin/start-datanode.sh >/dev/null 2>&1 &
```
-Windows 启动方式
+Windows 启动方式:
```
datanode\sbin\start-datanode.bat
```
-具体参考 [DataNode配置参数](https://iotdb.apache.org/zh/UserGuide/Master/Reference/DataNode-Config-Manual.html)
+具体参考 [DataNode配置参数](https://iotdb.apache.org/zh/UserGuide/Master/Reference/DataNode-Config-Manual.html)。
### 启动 Cli
-Cli 启动脚本在 datanode/sbin 目录
+Cli 启动脚本在 datanode/sbin 目录。
-Linux 启动方式
+Linux 启动方式:
```
./datanode/sbin/start-cli.sh
```
-Windows 启动方式
+Windows 启动方式:
```
datanode\sbin\start-cli.bat
```
+## 集群缩容
+
+### 移除 ConfigNode
+
+需要在活跃的 ConfigNode 上执行 remove-confignode 脚本。
+
+Linux 移除方式:
+```
+./confignode/sbin/remove-confignode.sh -r <internal_address>:<internal_port>
+```
+
+### 移除 DataNode
+
+需要在活跃的 DataNode 上执行 remove-datanode 脚本。
+
+Linux 移除方式:
+
++ 移除单个 DataNode:
+```
+./datanode/sbin/remove-datanode.sh <rpc_address>:<rpc_port>
+```
+
++ 移除多个 DataNode:
+```
+./datanode/sbin/remove-datanode.sh <rpc_address_0>:<rpc_port_0>,...,<rpc_address_n>:<rpc_port_n>
+```
+
+Windows 移除方式:
+
++ 移除单个 DataNode:
+```
+datanode\sbin\remove-datanode.bat <rpc_address>:<rpc_port>
+```
+
++ 移除多个 DataNode:
+```
+datanode\sbin\remove-datanode.bat <rpc_address_0>:<rpc_port_0>,...,<rpc_address_n>:<rpc_port_n>
+```
+
## 快速上手
-解压 apache-iotdb-0.14.0-preview1-all-bin.zip
+以本地环境为例,演示 IoTDB 集群的启动、扩容与缩容:
+
+### 1. 准备启动环境
+
+解压 apache-iotdb-0.14.0-preview1-all-bin.zip 至 cluster0 目录。
-部署 1 个 ConfigNode 和 1 个 DataNode(1C1D)集群版,默认 1 副本。
+### 2. 启动最小集群
+
+部署 1 个 ConfigNode 和 1 个 DataNode(1C1D)集群版,默认 1 副本:
```
-./confignode/sbin/start-confignode.sh
-./datanode/sbin/start-datanode.sh
+./cluster0/confignode/sbin/start-confignode.sh
+./cluster0/datanode/sbin/start-datanode.sh
+```
+
+### 3. 验证最小集群
+
++ 最小集群启动成功,启动 Cli 进行验证:
+```
+./cluster0/datanode/sbin/start-cli.sh
```
-启动 Cli
++ 在 Cli 执行 [show cluster](https://iotdb.apache.org/zh/UserGuide/Master/Maintenance-Tools/Maintenance-Command.html#%E6%9F%A5%E7%9C%8B%E5%85%A8%E9%83%A8%E8%8A%82%E7%82%B9%E4%BF%A1%E6%81%AF)
+指令,结果如下所示:
+```
+IoTDB> show cluster
++------+----------+-------+---------+-----+
+|NodeID| NodeType| Status| Host| Port|
++------+----------+-------+---------+-----+
+| 0|ConfigNode|Running| 0.0.0.0|22277|
+| 1| DataNode|Running|127.0.0.1| 9003|
++------+----------+-------+---------+-----+
+Total line number = 2
+It costs 0.160s
+```
+
+### 4. 准备扩容环境
+
+解压 apache-iotdb-0.14.0-preview1-all-bin.zip 至 cluster1 目录和 cluster2 目录
+
+### 5. 修改节点配置文件
+
+对于 cluster1 目录:
+
++ 修改 ConfigNode 地址:
+
+| **配置项** | **值** |
+|-----------------------|---------------|
+| internal\_address | 0.0.0.0 |
+| internal\_port | 22279 |
+| consensus\_port | 22280 |
+| target\_config\_nodes | 0.0.0.0:22277 |
+
++ 修改 DataNode 地址:
+
+| **配置项** | **值** |
+|---------------------------------|-----------------|
+| rpc\_address | 0.0.0.0 |
+| rpc\_port | 6668 |
+| internal\_address | 127.0.0.1 |
+| internal\_port | 9004 |
+| mpp\_data\_exchange\_port | 8778 |
+| data\_region\_consensus\_port | 40011 |
+| schema\_region\_consensus\_port | 50011 |
+| target\_config\_nodes | 127.0.0.1:22277 |
+
+对于 cluster2 目录:
+
++ 修改 ConfigNode 地址:
+
+| **配置项** | **值** |
+|-----------------------|---------------|
+| internal\_address | 0.0.0.0 |
+| internal\_port | 22281 |
+| consensus\_port | 22282 |
+| target\_config\_nodes | 0.0.0.0:22277 |
+
++ 修改 DataNode 地址:
+
+| **配置项** | **值** |
+|---------------------------------|-----------------|
+| rpc\_address | 0.0.0.0 |
+| rpc\_port | 6669 |
+| internal\_address | 127.0.0.1 |
+| internal\_port | 9005 |
+| mpp\_data\_exchange\_port | 8779 |
+| data\_region\_consensus\_port | 40012 |
+| schema\_region\_consensus\_port | 50012 |
+| target\_config\_nodes | 127.0.0.1:22277 |
+
+### 6. 集群扩容
+
+将集群扩容至 3 个 ConfigNode 和 3 个 DataNode(3C3D)集群版,
+指令执行顺序可不分先后:
+```
+./cluster1/confignode/sbin/start-confignode.sh
+./cluster1/datanode/sbin/start-datanode.sh
+./cluster2/confignode/sbin/start-confignode.sh
+./cluster2/datanode/sbin/start-datanode.sh
+```
+
+### 7. 验证扩容结果
+
+在 Cli 执行 show cluster,结果如下:
+```
+IoTDB> show cluster
++------+----------+-------+---------+-----+
+|NodeID| NodeType| Status| Host| Port|
++------+----------+-------+---------+-----+
+| 0|ConfigNode|Running| 0.0.0.0|22277|
+| 2|ConfigNode|Running| 0.0.0.0|22279|
+| 3|ConfigNode|Running| 0.0.0.0|22281|
+| 1| DataNode|Running|127.0.0.1| 9003|
+| 4| DataNode|Running|127.0.0.1| 9004|
+| 5| DataNode|Running|127.0.0.1| 9005|
++------+----------+-------+---------+-----+
+Total line number = 6
+It costs 0.012s
+```
+
+### 8. 集群缩容
+
++ 缩容一个 ConfigNode:
+```
+./cluster0/confignode/sbin/remove-confignode.sh -r 0.0.0.0:22279
+```
+
++ 缩容一个 DataNode:
+```
+./cluster0/datanode/sbin/remove-datanode.sh 127.0.0.1:6668
+```
+
+### 9. 验证缩容结果
+
+在 Cli 执行 show cluster,结果如下:
+```
+IoTDB> show cluster
++------+----------+-------+---------+-----+
+|NodeID| NodeType| Status| Host| Port|
++------+----------+-------+---------+-----+
+| 0|ConfigNode|Running| 0.0.0.0|22277|
+| 3|ConfigNode|Running| 0.0.0.0|22281|
+| 1| DataNode|Running|127.0.0.1| 9003|
+| 5| DataNode|Running|127.0.0.1| 9005|
++------+----------+-------+---------+-----+
+Total line number = 4
+It costs 0.007s
```
-./datanode/sbin/start-cli.sh
-```
\ No newline at end of file
diff --git a/docs/zh/UserGuide/Maintenance-Tools/Maintenance-Command.md b/docs/zh/UserGuide/Maintenance-Tools/Maintenance-Command.md
index 3978695aa5..83db3fdd12 100644
--- a/docs/zh/UserGuide/Maintenance-Tools/Maintenance-Command.md
+++ b/docs/zh/UserGuide/Maintenance-Tools/Maintenance-Command.md
@@ -124,124 +124,6 @@ KILL QUERY <queryId>
其中 statement 最大显示长度为 64 字符。对于超过 64 字符的查询语句,将截取部分进行显示。
-## 集群 Region 分布监控工具
-
-集群中以 Region 作为数据复制和数据管理的单元,Region 的状态和分布对于系统运维和测试有很大帮助,如以下场景:
-
-- 查看集群中各个 Region 被分配到了哪些 DataNode,是否均衡
-
-当前 IoTDB 支持使用如下 SQL 查看 Region:
-
-- `SHOW REGIONS`: 展示所有 Region
-- `SHOW SCHEMA REGIONS`: 展示所有 SchemaRegion 分布
-- `SHOW DATA REGIONS`: 展示所有 DataRegion 分布
-- `SHOW (DATA|SCHEMA)? REGIONS OF STORAGE GROUP <sg1,sg2,...>`: 展示指定的存储组<sg1,sg2,...>对应的Region分布。
-
-首先来看一下三副本下Region的分布情况:
-
-```
-IoTDB> create timeseries root.sg.d1.s1 with datatype=BOOLEAN,encoding=PLAIN
-Msg: The statement is executed successfully.
-IoTDB> create timeseries root.sg.d2.s1 with datatype=BOOLEAN,encoding=PLAIN
-Msg: The statement is executed successfully.
-IoTDB> create timeseries root.ln.d1.s1 with datatype=BOOLEAN,encoding=PLAIN
-Msg: The statement is executed successfully.
-
-+--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
-|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port| Role|
-+--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
-| 0|SchemaRegion| Up| root.sg| 2| 0| 5|127.0.0.1|6671|Follower|
-| 0|SchemaRegion| Up| root.sg| 2| 0| 4|127.0.0.1|6669|Follower|
-| 0|SchemaRegion| Up| root.sg| 2| 0| 3|127.0.0.1|6667| Leader|
-| 1|SchemaRegion| Up| root.ln| 1| 0| 5|127.0.0.1|6671|Follower|
-| 1|SchemaRegion| Up| root.ln| 1| 0| 4|127.0.0.1|6669|Follower|
-| 1|SchemaRegion| Up| root.ln| 1| 0| 3|127.0.0.1|6667| Leader|
-+--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
-Total line number = 6
-It costs 0.032s
-```
-
-然后再来看一下单副本下Region的分布情况:
-
-
-```sql
-IoTDB> show regions
-+--------+------------+------+-------------+------------+----------+----------+---------+----+------+
-|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port| Role|
-+--------+------------+------+-------------+------------+----------+----------+---------+----+------+
-| 0|SchemaRegion| Up| root.sg| 2| 0| 5|127.0.0.1|6671|Leader|
-| 1|SchemaRegion| Up| root.ln| 1| 0| 4|127.0.0.1|6669|Leader|
-+--------+------------+------+-------------+------------+----------+----------+---------+----+------+
-Total line number = 2
-It costs 0.128s
-```
-查看Schema Region和Data Region的分布信息:
-
-```
-IoTDB> insert into root.sg.d1(timestamp,s1) values(1,true)
-Msg: The statement is executed successfully.
-IoTDB> insert into root.ln.d1(timestamp,s1) values(1,true)
-Msg: The statement is executed successfully.
-
-IoTDB> show data regions
-+--------+----------+------+-------------+------------+----------+----------+---------+----+--------+
-|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port| Role|
-+--------+----------+------+-------------+------------+----------+----------+---------+----+--------+
-| 2|DataRegion| Up| root.sg| 1| 1| 5|127.0.0.1|6671|Follower|
-| 2|DataRegion| Up| root.sg| 1| 1| 4|127.0.0.1|6669| Leader|
-| 2|DataRegion| Up| root.sg| 1| 1| 3|127.0.0.1|6667|Follower|
-| 3|DataRegion| Up| root.ln| 1| 1| 5|127.0.0.1|6671| Leader|
-| 3|DataRegion| Up| root.ln| 1| 1| 4|127.0.0.1|6669|Follower|
-| 3|DataRegion| Up| root.ln| 1| 1| 3|127.0.0.1|6667|Follower|
-+--------+----------+------+-------------+------------+----------+----------+---------+----+--------+
-Total line number = 2
-It costs 0.011s
-IoTDB> show schema regions
-+--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
-|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port| Role|
-+--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
-| 0|SchemaRegion| Up| root.sg| 2| 0| 5|127.0.0.1|6671|Follower|
-| 0|SchemaRegion| Up| root.sg| 2| 0| 4|127.0.0.1|6669| Leader|
-| 0|SchemaRegion| Up| root.sg| 2| 0| 3|127.0.0.1|6667|Follower|
-| 1|SchemaRegion| Up| root.ln| 1| 0| 5|127.0.0.1|6671|Follower|
-| 1|SchemaRegion| Up| root.ln| 1| 0| 4|127.0.0.1|6669|Follower|
-| 1|SchemaRegion| Up| root.ln| 1| 0| 3|127.0.0.1|6667| Leader|
-+--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
-Total line number = 2
-It costs 0.012s
-```
-
-展示指定的存储组<sg1,sg2,...>对应的Region分布:
-
-```
-IoTDB> show regions of storage group root.sg
-+--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
-|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port| Role|
-+--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
-| 0|SchemaRegion| Up| root.sg| 2| 0| 5|127.0.0.1|6671|Follower|
-| 0|SchemaRegion| Up| root.sg| 2| 0| 4|127.0.0.1|6669| Leader|
-| 0|SchemaRegion| Up| root.sg| 2| 0| 3|127.0.0.1|6667|Follower|
-| 2| DataRegion| Up| root.sg| 1| 1| 5|127.0.0.1|6671|Follower|
-| 2| DataRegion| Up| root.sg| 1| 1| 4|127.0.0.1|6669| Leader|
-| 2| DataRegion| Up| root.sg| 1| 1| 3|127.0.0.1|6667|Follower|
-+--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
-Total line number = 2
-It costs 0.005s
-
-IoTDB> create timeseries root.sgcc.wf01.d1.wt01 with datatype=BOOLEAN,encoding=PLAIN
-Msg: The statement is executed successfully.
-IoTDB> show regions of storage group root.*.wf01
-+--------+------------+------+--------------+------------+----------+----------+---------+----+--------+
-|RegionId| Type|Status| storage group|Series Slots|Time Slots|DataNodeId| Host|Port| Role|
-+--------+------------+------+--------------+------------+----------+----------+---------+----+--------+
-| 4|SchemaRegion| Up|root.sgcc.wf01| 1| 0| 5|127.0.0.1|6671| Leader|
-| 4|SchemaRegion| Up|root.sgcc.wf01| 1| 0| 4|127.0.0.1|6669|Follower|
-| 4|SchemaRegion| Up|root.sgcc.wf01| 1| 0| 3|127.0.0.1|6667|Follower|
-+--------+------------+------+--------------+------------+----------+----------+---------+----+--------+
-Total line number = 3
-It costs 0.012s
-```
-
## 集群节点分布式监控工具
### 查看DataNode节点信息
@@ -401,3 +283,121 @@ Total line number = 6
It costs 0.012s
```
+## 集群 Region 分布监控工具
+
+集群中以 Region 作为数据复制和数据管理的单元,Region 的状态和分布对于系统运维和测试有很大帮助,如以下场景:
+
+- 查看集群中各个 Region 被分配到了哪些 DataNode,是否均衡
+
+当前 IoTDB 支持使用如下 SQL 查看 Region:
+
+- `SHOW REGIONS`: 展示所有 Region
+- `SHOW SCHEMA REGIONS`: 展示所有 SchemaRegion 分布
+- `SHOW DATA REGIONS`: 展示所有 DataRegion 分布
+- `SHOW (DATA|SCHEMA)? REGIONS OF STORAGE GROUP <sg1,sg2,...>`: 展示指定的存储组<sg1,sg2,...>对应的Region分布。
+
+首先来看一下三副本下Region的分布情况:
+
+```
+IoTDB> create timeseries root.sg.d1.s1 with datatype=BOOLEAN,encoding=PLAIN
+Msg: The statement is executed successfully.
+IoTDB> create timeseries root.sg.d2.s1 with datatype=BOOLEAN,encoding=PLAIN
+Msg: The statement is executed successfully.
+IoTDB> create timeseries root.ln.d1.s1 with datatype=BOOLEAN,encoding=PLAIN
+Msg: The statement is executed successfully.
+
++--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
+|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port| Role|
++--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
+| 0|SchemaRegion| Up| root.sg| 2| 0| 5|127.0.0.1|6671|Follower|
+| 0|SchemaRegion| Up| root.sg| 2| 0| 4|127.0.0.1|6669|Follower|
+| 0|SchemaRegion| Up| root.sg| 2| 0| 3|127.0.0.1|6667| Leader|
+| 1|SchemaRegion| Up| root.ln| 1| 0| 5|127.0.0.1|6671|Follower|
+| 1|SchemaRegion| Up| root.ln| 1| 0| 4|127.0.0.1|6669|Follower|
+| 1|SchemaRegion| Up| root.ln| 1| 0| 3|127.0.0.1|6667| Leader|
++--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
+Total line number = 6
+It costs 0.032s
+```
+
+然后再来看一下单副本下Region的分布情况:
+
+
+```sql
+IoTDB> show regions
++--------+------------+------+-------------+------------+----------+----------+---------+----+------+
+|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port| Role|
++--------+------------+------+-------------+------------+----------+----------+---------+----+------+
+| 0|SchemaRegion| Up| root.sg| 2| 0| 5|127.0.0.1|6671|Leader|
+| 1|SchemaRegion| Up| root.ln| 1| 0| 4|127.0.0.1|6669|Leader|
++--------+------------+------+-------------+------------+----------+----------+---------+----+------+
+Total line number = 2
+It costs 0.128s
+```
+查看Schema Region和Data Region的分布信息:
+
+```
+IoTDB> insert into root.sg.d1(timestamp,s1) values(1,true)
+Msg: The statement is executed successfully.
+IoTDB> insert into root.ln.d1(timestamp,s1) values(1,true)
+Msg: The statement is executed successfully.
+
+IoTDB> show data regions
++--------+----------+------+-------------+------------+----------+----------+---------+----+--------+
+|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port| Role|
++--------+----------+------+-------------+------------+----------+----------+---------+----+--------+
+| 2|DataRegion| Up| root.sg| 1| 1| 5|127.0.0.1|6671|Follower|
+| 2|DataRegion| Up| root.sg| 1| 1| 4|127.0.0.1|6669| Leader|
+| 2|DataRegion| Up| root.sg| 1| 1| 3|127.0.0.1|6667|Follower|
+| 3|DataRegion| Up| root.ln| 1| 1| 5|127.0.0.1|6671| Leader|
+| 3|DataRegion| Up| root.ln| 1| 1| 4|127.0.0.1|6669|Follower|
+| 3|DataRegion| Up| root.ln| 1| 1| 3|127.0.0.1|6667|Follower|
++--------+----------+------+-------------+------------+----------+----------+---------+----+--------+
+Total line number = 2
+It costs 0.011s
+IoTDB> show schema regions
++--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
+|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port| Role|
++--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
+| 0|SchemaRegion| Up| root.sg| 2| 0| 5|127.0.0.1|6671|Follower|
+| 0|SchemaRegion| Up| root.sg| 2| 0| 4|127.0.0.1|6669| Leader|
+| 0|SchemaRegion| Up| root.sg| 2| 0| 3|127.0.0.1|6667|Follower|
+| 1|SchemaRegion| Up| root.ln| 1| 0| 5|127.0.0.1|6671|Follower|
+| 1|SchemaRegion| Up| root.ln| 1| 0| 4|127.0.0.1|6669|Follower|
+| 1|SchemaRegion| Up| root.ln| 1| 0| 3|127.0.0.1|6667| Leader|
++--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
+Total line number = 2
+It costs 0.012s
+```
+
+展示指定的存储组<sg1,sg2,...>对应的Region分布:
+
+```
+IoTDB> show regions of storage group root.sg
++--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
+|RegionId| Type|Status|storage group|Series Slots|Time Slots|DataNodeId| Host|Port| Role|
++--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
+| 0|SchemaRegion| Up| root.sg| 2| 0| 5|127.0.0.1|6671|Follower|
+| 0|SchemaRegion| Up| root.sg| 2| 0| 4|127.0.0.1|6669| Leader|
+| 0|SchemaRegion| Up| root.sg| 2| 0| 3|127.0.0.1|6667|Follower|
+| 2| DataRegion| Up| root.sg| 1| 1| 5|127.0.0.1|6671|Follower|
+| 2| DataRegion| Up| root.sg| 1| 1| 4|127.0.0.1|6669| Leader|
+| 2| DataRegion| Up| root.sg| 1| 1| 3|127.0.0.1|6667|Follower|
++--------+------------+------+-------------+------------+----------+----------+---------+----+--------+
+Total line number = 2
+It costs 0.005s
+
+IoTDB> create timeseries root.sgcc.wf01.d1.wt01 with datatype=BOOLEAN,encoding=PLAIN
+Msg: The statement is executed successfully.
+IoTDB> show regions of storage group root.*.wf01
++--------+------------+------+--------------+------------+----------+----------+---------+----+--------+
+|RegionId| Type|Status| storage group|Series Slots|Time Slots|DataNodeId| Host|Port| Role|
++--------+------------+------+--------------+------------+----------+----------+---------+----+--------+
+| 4|SchemaRegion| Up|root.sgcc.wf01| 1| 0| 5|127.0.0.1|6671| Leader|
+| 4|SchemaRegion| Up|root.sgcc.wf01| 1| 0| 4|127.0.0.1|6669|Follower|
+| 4|SchemaRegion| Up|root.sgcc.wf01| 1| 0| 3|127.0.0.1|6667|Follower|
++--------+------------+------+--------------+------------+----------+----------+---------+----+--------+
+Total line number = 3
+It costs 0.012s
+```
+