赞
踩
- 数据库备份与迁移是数据库运维中的核心任务,其重要性不言而喻。
- 确保备份过程既简单快捷又稳定可靠,对于保障数据安全与业务连续性至关重要。
- 鉴于IoTDB底层数据文件采用TsFile格式,IoTDB特别提供了TsFile导入导出工具。
- 这一工具极大地简化了数据库备份、迁移以及同步的流程,为用户带来了极大的便利。
如果是使用开源版本IoTDB,那么有如下三种数据同步和备份的方法,可供选择。
如果是使用企业版本IoTDB(TimechoDB),那么一种数据同步的方法就够了,简单方便更好用。
准备两台服务器,一台导出,一台导入。
[root@VM-0-3-centos apache-iotdb-1.3.1-all-bin]# bash sbin/start-cli.sh
---------------------
Starting IoTDB Cli
---------------------
_____ _________ ______ ______
|_ _| | _ _ ||_ _ `.|_ _ \
| | .--.|_/ | | \_| | | `. \ | |_) |
| | / .'`\ \ | | | | | | | __'.
_| |_| \__. | _| |_ _| |_.' /_| |__) |
|_____|'.__.' |_____| |______.'|_______/ version 1.3.1 (Build: 214695d)
Successfully login at 127.0.0.1:6667
IoTDB> select status from root.test.test
+-----------------------------+---------------------+
| Time|root.test.test.status|
+-----------------------------+---------------------+
|1970-01-01T08:00:00.001+08:00| 4.0|
|1970-01-01T08:00:00.002+08:00| 5.0|
|1970-01-01T08:00:00.003+08:00| 6.0|
|2024-05-04T01:35:38.608+08:00| 1.0|
|2024-05-04T01:35:45.166+08:00| 2.0|
|2024-05-04T01:35:47.096+08:00| 3.0|
|2024-05-04T01:35:56.606+08:00| 3.0|
+-----------------------------+---------------------+
Total line number = 7
It costs 0.469s
[root@iZ2ze30dygwd6yh7gu6lskZ iot-db]# bash sbin/start-cli.sh
---------------------
Starting IoTDB Cli
---------------------
_____ _________ ______ ______
|_ _| | _ _ ||_ _ `.|_ _ \
| | .--.|_/ | | \_| | | `. \ | |_) |
| | / .'`\ \ | | | | | | | __'.
_| |_| \__. | _| |_ _| |_.' /_| |__) |
|_____|'.__.' |_____| |______.'|_______/ version 1.3.1 (Build: 214695d)
Successfully login at 127.0.0.1:6667
IoTDB> select status from root.test.test
+----+
|Time|
+----+
+----+
Empty set.
It costs 0.221s
tools/export-tsfile.sh -h <ip> -p <port> -u <username> -pw <password> -td <directory> [-f <export filename> -q <query command> -s <sql file>]
[root@VM-0-3-centos apache-iotdb-1.3.1-all-bin]# bash tools/export-tsfile.sh -h 127.0.0.1 -p 6667 -u root -pw root -td ./
------------------------------------------
Starting IoTDB Client Export Script
------------------------------------------
ExportTsFile> please input query: select status from root.test.test
select status from root.test.test
12378 [main] WARN o.a.i.t.c.conf.TSFileDescriptor - not found iotdb-common.properties, use the default configs.
12476 [main] INFO o.a.iotdb.tsfile.write.TsFileWriter - start close file
Export completely!cost: 115 ms.
dump0.tsfile
就是本次导出的tsfile文件。
将步骤三获得的dump0.tsfile上传到导入服务器中
load '<path/dir>' [sglevel=int][verify=true/false][onSuccess=delete/none]
[root@iZ2ze30dygwd6yh7gu6lskZ iot-db]# bash sbin/start-cli.sh
---------------------
Starting IoTDB Cli
---------------------
_____ _________ ______ ______
|_ _| | _ _ ||_ _ `.|_ _ \
| | .--.|_/ | | \_| | | `. \ | |_) |
| | / .'`\ \ | | | | | | | __'.
_| |_| \__. | _| |_ _| |_.' /_| |__) |
|_____|'.__.' |_____| |______.'|_______/ version 1.3.1 (Build: 214695d)
Successfully login at 127.0.0.1:6667
IoTDB> load '/home/iot-db/dump0.tsfile'
Msg: The statement is executed successfully.
IoTDB> select status from root.test.test
+-----------------------------+---------------------+
| Time|root.test.test.status|
+-----------------------------+---------------------+
|1970-01-01T08:00:00.001+08:00| 4.0|
|1970-01-01T08:00:00.002+08:00| 5.0|
|1970-01-01T08:00:00.003+08:00| 6.0|
|2024-05-04T01:35:38.608+08:00| 1.0|
|2024-05-04T01:35:45.166+08:00| 2.0|
|2024-05-04T01:35:47.096+08:00| 3.0|
|2024-05-04T01:35:56.606+08:00| 3.0|
+-----------------------------+---------------------+
Total line number = 7
It costs 0.245s
觉得好,就一键三连呗(点赞+收藏+关注)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。