元数据导出
1. 功能概述
元数据导出工具 export-schema.sh 位于tools/schema目录下,能够将 UDB-DS 中指定数据库下的元数据导出为脚本文件。
2. 功能详解
2.1 参数介绍
| 参数缩写 | 参数全称 | 参数含义 | 是否为必填项 | 默认值 |
|---|---|---|---|---|
-h |
-- host |
主机名 | 否 | 127.0.0.1 |
-p |
--port |
端口号 | 否 | 7777 |
-u |
--username |
用户名 | 否 | root |
-pw |
--password |
密码 | 否 | root |
-sql_dialect |
--sql_dialect |
选择 server 是树模型还是表模型,当前支持 tree 和 table 类型 | 否 | tree |
-db |
--database |
将要导出的目标数据库,只在-sql_dialect为 table 类型下生效。 |
-sql_dialect为 table 时必填 |
- |
-table |
--table |
将要导出的目标表,只在-sql_dialect为 table 类型下生效。 |
否 | - |
-t |
--target |
指定输出文件的目标文件夹,如果路径不存在新建文件夹 | 是 | |
-path |
--path_pattern |
指定导出元数据的path pattern | -sql_dialect为 tree 时必填 |
|
-pfn |
--prefix_file_name |
指定导出文件的名称。 | 否 | dump_dbname.sql |
-lpf |
--lines_per_file |
指定导出的dump文件最大行数,只在-sql_dialect为 tree 类型下生效。 |
否 | 10000 |
-timeout |
--query_timeout |
会话查询的超时时间(ms) | 否 | -1范围:-1~Long. max=9223372036854775807 |
-help |
--help |
显示帮助信息 | 否 |
2.2 运行命令
> tools/export-schema.sh [-sql_dialect<sql_dialect>] -db<database> -table<table>
[-h <host>] [-p <port>] [-u <username>] [-pw <password>]
-t <target_directory> [-path <exportPathPattern>] [-pfn <prefix_file_name>]
[-lpf <lines_per_file>] [-timeout <query_timeout>]
2.3 运行示例
# 导出 root.treedb路径下的元数据
./export-schema.sh -sql_dialect tree -t /home/ -path "root.treedb.**"
# 导出结果内容格式如下
Timeseries,Alias,DataType,Encoding,Compression
root.treedb.device.temperature,,DOUBLE,GORILLA,LZ4
root.treedb.device.humidity,,DOUBLE,GORILLA,LZ4