The Sync Tool is an IoTDB suite tool that continuously uploads the timeseries data from the edge (sender) to the cloud(receiver).
On the sender side of the sync, the sync module is embedded in the IoTDB engine. You should start an IoTDB before using the Sync tool.
You can use SQL commands to start or close a synchronization task at the sender, and you can check the status of the synchronization task at any time. At the receiving end, you can set the IP white list to specify the access IP address range of sender.

Two machines A and B, which are installed with iotdb, we want to continuously synchronize the data from A to B. To better describe this process, we introduce the following concepts.
root.sg.d.s, sender B also includes the path root.sg.d.s, sender A deletes storage group root.sg will also delete all data of B stored in the path root.sg.d.s at receiver.Execute the following SQL statements at the sender and receiver to quickly start a data synchronization task between two IoTDB. For complete SQL statements and configuration matters, please see the parameter configurationand SQL sections. For more usage examples, please refer to the usage examples section.
IoTDB> START PIPESERVER
IOTDB> STOP PIPESERVER
IoTDB> CREATE PIPESINK central_iotdb AS IoTDB (IP='There is your goal IP')
IoTDB> CREATE PIPE my_pipe TO central_iotDB
IoTDB> START PIPE my_pipe
IoTDB> SHOW PIPES
IoTDB> STOP PIPE my_pipe
IoTDB> START PIPE my_pipe
IoTDB> DROP PIPE my_pipe
All parameters are in $IOTDB_ HOME$/conf/iotdb-engine, after all modifications are completed, execute load configuration and it will take effect immediately.
| Parameter Name | max_number_of_sync_file_retry |
|---|---|
| Description | The maximum number of retries when the sender fails to synchronize files to the receiver. |
| Data type | Int : [0,2147483647] |
| Default value | 5 |
| Parameter Name | ip_white_list |
|---|---|
| Description | Set the white list of IP addresses of the sending end of the synchronization, which is expressed in the form of network segments, and multiple network segments are separated by commas. When the sender synchronizes data to the receiver, the receiver allows synchronization only when the IP address of the sender is within the network segment set in the white list. If the whitelist is empty, the receiver does not allow any sender to synchronize data. By default, the receiving end accepts the synchronization request of all IP addresses. |
| Data type | String |
| Default value | 0.0.0.0/0 |
| Parameter Name | sync_server_port |
|---|---|
| Description | The port which the receiver listens, please ensure this port is not occupied by other applications. |
| Data type | Short Int : [0,65535] |
| Default value | 6670 |
IoTDB> CREATE PIPESINK <PipeSinkName> AS IoTDB [(IP='127.0.0.1',port=6670);]
IoTDB> SHOW PIPESINKTYPE IoTDB> +-----+ | type| +-----+ |IoTDB| +-----+
IoTDB> SHOW PIPESINKS IoTDB> SHOW PIPESINK [PipeSinkName] IoTDB> +-----------+-----+------------------------+ | name| type| attributes| +-----------+-----+------------------------+ |my_pipesink|IoTDB|ip='127.0.0.1',port=6670| +-----------+-----+------------------------+
IoTDB> DROP PIPESINK <PipeSinkName>
** (i.e. data in all timeseries), the FROM statement only supports root, and the WHERE statement only supports the start time of the specified time.SyncDelOp parameter is true, the deletions of sender will not be synchronized to receiver.IoTDB> CREATE PIPE my_pipe TO my_iotdb [FROM (select ** from root WHERE time>='yyyy-mm-dd HH:MM:SS' )] [WITH SyncDelOp=true]
This statement can be executed on both senders and receivers.
Create time, the creation time of this pipe.
Name, the name of this pipe.
Role, the current role of this IoTDB in pipe, there are two possible roles.
Remote, information about the opposite end of the pipe.
Status, this pipe's status.
Message, the status message of this pipe. When pipe runs normally, this column is usually empty. When an exception occurs, messages may appear in following two states.
IoTDB> SHOW PIPES IoTDB> +-----------------------+--------+--------+-------------+---------+-------+ | create time| name | role| remote| status|message| +-----------------------+--------+--------+-------------+---------+-------+ |2022-03-30T20:58:30.689|my_pipe1| sender| my_pipesink| STOP| | +-----------------------+--------+--------+-------------+---------+-------+ |2022-03-31T12:55:28.129|my_pipe2|receiver|192.168.11.11| RUNNING| | +-----------------------+--------+--------+-------------+---------+-------+
Show PIPES.IoTDB> SHOW PIPE [PipeName]
IoTDB> STOP PIPE <PipeName>
IoTDB> START PIPE <PipeName>
IoTDB> DROP PIPE <PipeName>
IoTDB> START PIPESERVER
IoTDB> STOP PIPESERVER
IoTDB> SHOW PIPESERVER STATUS +----------+ | enalbe| +----------+ |true/false| +----------+
vi conf/iotdb-datanode.properties to config the parameters,set the IP white list to 192.168.0.1/1 to receive and only receive data from sender.#################### ### PIPE Server Configuration #################### # PIPE server port to listen # Datatype: int # pipe_server_port=6670 # White IP list of Sync client. # Please use the form of network segment to present the range of IP, for example: 192.168.0.0/16 # If there are more than one IP segment, please separate them by commas # The default is to allow all IP to sync # Datatype: String ip_white_list=192.168.0.1/1
IoTDB> START PIPESERVER
True result means running correctly.IoTDB> SHOW PIPESERVER STATUS
max_number_of_sync_file_retry parameter to 10.#################### ### PIPE Sender Configuration #################### # The maximum number of retry when syncing a file to receiver fails. max_number_of_sync_file_retry=10
IoTDB> CREATE PIPESINK my_iotdb AS IoTDB (IP='192.168.0.2',PORT=6670)
SyncDelOp to false.IoTDB> CREATE PIPE p TO my_iotdb FROM (select ** from root where time>='2022-03-30 00:00:00') WITH SyncDelOp=false
IoTDB> START PIPE p
IoTDB> SHOW PIPE p
Execute SQL on sender.
SET STORAGE GROUP TO root.vehicle; CREATE TIMESERIES root.vehicle.d0.s0 WITH DATATYPE=INT32, ENCODING=RLE; CREATE TIMESERIES root.vehicle.d0.s1 WITH DATATYPE=TEXT, ENCODING=PLAIN; CREATE TIMESERIES root.vehicle.d1.s2 WITH DATATYPE=FLOAT, ENCODING=RLE; CREATE TIMESERIES root.vehicle.d1.s3 WITH DATATYPE=BOOLEAN, ENCODING=PLAIN; insert into root.vehicle.d0(timestamp,s0) values(now(),10); insert into root.vehicle.d0(timestamp,s0,s1) values(now(),12,'12'); insert into root.vehicle.d0(timestamp,s1) values(now(),'14'); insert into root.vehicle.d1(timestamp,s2) values(now(),16.0); insert into root.vehicle.d1(timestamp,s2,s3) values(now(),18.0,true); insert into root.vehicle.d1(timestamp,s3) values(now(),false); flush;
Execute SELECT statements, the same results can be found on sender and receiver.
IoTDB> select ** from root.vehicle +-----------------------------+------------------+------------------+------------------+------------------+ | Time|root.vehicle.d0.s0|root.vehicle.d0.s1|root.vehicle.d1.s3|root.vehicle.d1.s2| +-----------------------------+------------------+------------------+------------------+------------------+ |2022-04-03T20:08:17.127+08:00| 10| null| null| null| |2022-04-03T20:08:17.358+08:00| 12| 12| null| null| |2022-04-03T20:08:17.393+08:00| null| 14| null| null| |2022-04-03T20:08:17.538+08:00| null| null| null| 16.0| |2022-04-03T20:08:17.753+08:00| null| null| true| 18.0| |2022-04-03T20:08:18.263+08:00| null| null| false| null| +-----------------------------+------------------+------------------+------------------+------------------+ Total line number = 6 It costs 0.134s
Execute
STOP PIPESERVER
to close IoTDB PipeServer service with message.
Msg: 328: Failed to stop pipe server because there is pipe still running.
STOP PIPE <PipeName> to stop pipe, then stop PipeServer service.Execute
CREATE PIPE mypipe
get message.
Msg: 411: Create transport for pipe mypipe error, because CREATE request connects to receiver 127.0.0.1:6670 error..
SHOW PIPESERVER on the receiver side to check if the receiver side is started, if not use START PIPESERVER to start; check if the whitelist in iotdb-datanode.properties on the receiver side contains the sender ip.Execute
DROP PIPESINK pipesinkName
get message.
Msg: 411: Can not drop pipeSink demo, because pipe mypipe is using it.
SHOW PIPE on the sender side to stop using the PipeSink's PIPE.Sender creates PIPE prompt.
Msg: 411: Pipe p is RUNNING, please retry after drop it.
DROP PIPE p and retry.