1、通过restful api 查询导出数据
curl -H "Content-Type:application/json" -H "Authorization:Basic cm9vdDpyb290" -X POST --data '{"sql":" select js_data from root.xxx.yyylimit 6"}' http://127.0.0.1:18080/rest/v1/query
其中,Authorization:Basic cm9vdDpyb290 这里说明,Basic 是认证方式,后面是用户名和密码的base64编码 如Base64.getEncoder().encodeToString("root:root".getBytes(StandardCharsets.UTF_8)),也可使用在线base64编码生成。
2、通过iotdb自带的tools
root@xxxxxx:/iotdb/tools# ls
detect-watermark.sh export-csv.bat import-csv.bat mlog start-WalChecker.sh start-sync-client.sh stop-sync-client.sh
detect-watermark.bat export-csv.sh import-csv.sh start-WalChecker.bat start-sync-client.bat stop-sync-client.bat tsfileToolSet
示例步骤如下:
(1)、touch 9005sql.txt
内容如下:
select jsdata from root.xxxx.yyyy limit 5
(2)、若export-csv.sh没有执行权限,则增加执行权限,有则跳过此步骤 chmod +x export-csv.sh
(3)、sh export-csv.sh -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -s 9005sql.txt
------------------------------------------ Starting IoTDB Client Export Script ------------------------------------------ 13:14:36.263 [main] DEBUG org.apache.iotdb.session.Session - EndPoint(ip:127.0.0.1, port:6667) execute sql select jsdata from root.xxxx.yyyy limit 5 13:14:36.275 [main] DEBUG org.apache.iotdb.rpc.AutoResizingBuffer - org.apache.iotdb.rpc.AutoResizingBuffer@21a947fe expand from 1024 to 73665, request: 73665 Export completely! (4)、root@xxxx:/iotdb/tools# ls -l-rw-r--r-- 1 root root 125 Sep 6 13:13 9005sql.txt
-rwxr-xr-x 1 root root 1950 Mar 18 00:49 detect-watermark.bat
-rwxr-xr-x 1 root root 1369 Mar 18 00:49 detect-watermark.sh
-rw-r--r-- 1 root root 79070 Sep 6 13:14 dump0.csv
-rwxr-xr-x 1 root root 1893 Mar 18 00:49 export-csv.bat
-rwxr-xr-x 1 root root 1601 Mar 18 00:49 export-csv.sh
-rwxr-xr-x 1 root root 1894 Mar 18 00:49 import-csv.bat
-rwxr-xr-x 1 root root 1601 Mar 18 00:49 import-csv.sh
drwxr-xr-x 2 root root 4096 Mar 18 00:49 mlog
-rwxr-xr-x 1 root root 2911 Mar 18 00:49 start-WalChecker.bat
-rwxr-xr-x 1 root root 2340 Mar 18 00:49 start-WalChecker.sh
-rwxr-xr-x 1 root root 2092 Mar 18 00:49 start-sync-client.bat
-rwxr-xr-x 1 root root 1701 Mar 18 00:49 start-sync-client.sh
-rwxr-xr-x 1 root root 1032 Mar 18 00:49 stop-sync-client.bat
-rwxr-xr-x 1 root root 1009 Mar 18 00:49 stop-sync-client.sh
drwxr-xr-x 2 root root 4096 Mar 18 00:49 tsfileToolSet
(5)、查看到的dump0.csv即是导出的数据文件 ,SZ下载下来即可
备注:
1、第二种方式,在docker中操作更有效
2、如果查询的结果数据量不大的情况下,就是复制粘贴结果就好了,谢谢
标签:00,两种,49,18,导出,IOTDB,xr,root,Mar From: https://www.cnblogs.com/xuzhujack/p/16661872.html