iotdb 数据的导出
Posted 健康平安的活着
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了iotdb 数据的导出相关的知识,希望对你有一定的参考价值。
一 iotdb数据的导出
1.首先进入到iotdb的客户端的tools目录下
root@172-16-26-29 iotdb-cli]# cd tools
[root@172-16-26-29 tools]# ls
export-csv.bat export-csv.sh import-csv.bat import-csv.sh mytest.txt
2.编写导出的sql脚本
[root@172-16-26-29 tools]# touch 0324sql.txt
内容如下:
select DCS4RTS_40HLA40CP101_c from root.iot_point.tenant_system limit 5
3.赋予脚本执行权限
[root@172-16-26-29 tools]# chmod +x export-csv.sh
4.将脚本通过dos2unix转换执行脚本的格式
[root@172-16-26-29 tools]# sh export-csv.sh -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -s 0324sql.txt
export-csv.sh: line 20: $'\\r': command not found
------------------------------------------
Starting IoTDB Client Export Script
------------------------------------------
export-csv.sh: line 24: $'\\r': command not found
export-csv.sh: line 30: syntax error near unexpected token `$'do\\r''
'xport-csv.sh: line 30: ` for java in "$JAVA_HOME"/bin/amd64/java "$JAVA_HOME"/bin/java; do
[root@172-16-26-29 tools]# dos2unix export-csv.sh
dos2unix: converting file export-csv.sh to Unix format ...
5.执行导出
[root@172-16-26-29 tools]# sh export-csv.sh -h 127.0.0.1 -p 6667 -u root -pw root -td ./ -s 0324sql.txt
------------------------------------------
Starting IoTDB Client Export Script
------------------------------------------
22:09:48.168 [main] DEBUG org.apache.iotdb.session.Session - EndPoint(ip:127.0.0.1, port:6667) execute sql select DCS4RTS_40HLA40CP101_c from root.iot_point.tenant_system limit 5
Export completely!
22:09:48.240 [main] DEBUG org.apache.iotdb.session.Session - EndPoint(ip:127.0.0.1, port:6667) execute sql
Cannot dump result because: 401: Error occurred while parsing SQL to physical plan: line 1:0 mismatched input '<EOF>' expecting CREATE, INSERT, UPDATE, DELETE, SELECT, SHOW, KILL, GRANT, SET, DESCRIBE, TRACING, DROP, MERGE, LIST, ALTER, REVOKE, LOAD, UNSET, FLUSH, REMOVE, MOVE, COUNT, FULL, CLEAR, START, STOP, DEBUG
[root@172-16-26-29 tools]# ls -l
total 24
-rw-r--r-- 1 root root 73 Mar 24 22:05 0324sql.txt
-rw-r--r-- 1 root root 289 Mar 24 22:09 dump0.csv
-rw-r--r-- 1 root root 1915 Jun 10 2021 export-csv.bat
-rwxr-xr-x 1 root root 1621 Mar 24 22:09 export-csv.sh
-rw-r--r-- 1 root root 1917 Jun 10 2021 import-csv.bat
-rw-r--r-- 1 root root 1673 Jun 10 2021 import-csv.sh
-rw-r--r-- 1 root root 0 Mar 24 18:53 mytest.txt
6.查看导出的csv文件
以上是关于iotdb 数据的导出的主要内容,如果未能解决你的问题,请参考以下文章