You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@doris.apache.org by GitBox <gi...@apache.org> on 2022/04/07 08:24:51 UTC

[GitHub] [incubator-doris] hf200012 commented on a diff in pull request #8776: [Refactor][doc] Added doc for compilation, deployment and data export

hf200012 commented on code in PR #8776:
URL: https://github.com/apache/incubator-doris/pull/8776#discussion_r844547880


##########
new-docs/zh-CN/data-operate/export/export-manual.md:
##########
@@ -24,4 +24,179 @@ specific language governing permissions and limitations
 under the License.
 -->
 
-# 数据导出
\ No newline at end of file
+# 数据导出
+
+数据导出(Export)是 Doris 提供的一种将数据导出的功能。该功能可以将用户指定的表或分区的数据,以文本的格式,通过 Broker 进程导出到远端存储上,如 HDFS/BOS 等。
+
+本文档主要介绍 Export 的基本原理、使用方式、最佳实践以及注意事项。
+
+## 原理
+
+用户提交一个 Export 作业后。Doris 会统计这个作业涉及的所有 Tablet。然后对这些 Tablet 进行分组,每组生成一个特殊的查询计划。该查询计划会读取所包含的 Tablet 上的数据,然后通过 Broker 将数据写到远端存储指定的路径中,也可以通过S3协议直接导出到支持S3协议的远端存储上。
+
+总体的调度方式如下:
+
+```
++--------+
+| Client |
++---+----+
+    |  1. Submit Job
+    |
++---v--------------------+
+| FE                     |
+|                        |
+| +-------------------+  |
+| | ExportPendingTask |  |
+| +-------------------+  |
+|                        | 2. Generate Tasks
+| +--------------------+ |
+| | ExportExporingTask | |
+| +--------------------+ |
+|                        |
+| +-----------+          |     +----+   +------+   +---------+
+| | QueryPlan +----------------> BE +--->Broker+--->         |
+| +-----------+          |     +----+   +------+   | Remote  |
+| +-----------+          |     +----+   +------+   | Storage |
+| | QueryPlan +----------------> BE +--->Broker+--->         |
+| +-----------+          |     +----+   +------+   +---------+
++------------------------+         3. Execute Tasks
+
+```
+
+1. 用户提交一个 Export 作业到 FE。
+2. FE 的 Export 调度器会通过两阶段来执行一个 Export 作业:
+  1. PENDING:FE 生成 ExportPendingTask,向 BE 发送 snapshot 命令,对所有涉及到的 Tablet 做一个快照。并生成多个查询计划。
+  2. EXPORTING:FE 生成 ExportExportingTask,开始执行查询计划。
+
+### 查询计划拆分
+
+Export 作业会生成多个查询计划,每个查询计划负责扫描一部分 Tablet。每个查询计划扫描的 Tablet 个数由 FE 配置参数 `export_tablet_num_per_task` 指定,默认为 5。即假设一共 100 个 Tablet,则会生成 20 个查询计划。用户也可以在提交作业时,通过作业属性 `tablet_num_per_task` 指定这个数值。
+
+一个作业的多个查询计划顺序执行。
+
+### 查询计划执行
+
+一个查询计划扫描多个分片,将读取的数据以行的形式组织,每 1024 行为一个 batch,调用 Broker 写入到远端存储上。
+
+查询计划遇到错误会整体自动重试 3 次。如果一个查询计划重试 3 次依然失败,则整个作业失败。
+
+Doris 会首先在指定的远端存储的路径中,建立一个名为 `__doris_export_tmp_12345` 的临时目录(其中 `12345` 为作业 id)。导出的数据首先会写入这个临时目录。每个查询计划会生成一个文件,文件名示例:
+
+`export-data-c69fcf2b6db5420f-a96b94c1ff8bccef-1561453713822`
+
+其中 `c69fcf2b6db5420f-a96b94c1ff8bccef` 为查询计划的 query id。`1561453713822` 为文件生成的时间戳。
+
+当所有数据都导出后,Doris 会将这些文件 rename 到用户指定的路径中。
+
+### Broker 参数
+
+Export 需要借助 Broker 进程访问远端存储,不同的 Broker 需要提供不同的参数,具体请参阅 [Broker文档](./advanced/broker.html)
+
+## 开始导出
+
+Export 的详细用法可参考 [SHOW EXPORT](../../sql-manual/sql-reference-v2/Show-Statements/SHOW-EXPORT.html) 。
+
+### 导出到HDFS
+
+```sql
+EXPORT TABLE db1.tbl1 
+PARTITION (p1,p2)
+[WHERE [expr]]
+TO "hdfs://host/path/to/export/" 
+PROPERTIES
+(
+    "label" = "mylabel",
+    "column_separator"=",",
+    "columns" = "col1,col2",
+    "exec_mem_limit"="2147483648",
+    "timeout" = "3600"
+)
+WITH BROKER "hdfs"
+(
+    "username" = "user",
+    "password" = "passwd"
+);
+```
+
+* `label`:本次导出作业的标识。后续可以使用这个标识查看作业状态。
+* `column_separator`:列分隔符。默认为 `\t`。支持不可见字符,比如 '\x07'。
+* `columns`:要导出的列,使用英文状态逗号隔开,如果不填这个参数默认是导出表的所有列。
+* `line_delimiter`:行分隔符。默认为 `\n`。支持不可见字符,比如 '\x07'。
+* `exec_mem_limit`: 表示 Export 作业中,一个查询计划在单个 BE 上的内存使用限制。默认 2GB。单位字节。
+* `timeout`:作业超时时间。默认 2小时。单位秒。
+* `tablet_num_per_task`:每个查询计划分配的最大分片数。默认为 5。
+
+### 查看导出状态
+
+提交作业后,可以通过  [SHOW EXPORT](../../sql-manual/sql-reference-v2/Show-Statements/SHOW-EXPORT.html) 命令查询导入作业状态。结果举例如下:
+
+```sql
+     JobId: 14008

Review Comment:
   add  `SHOW EXPORT FROM db1 WHERE LABEL = "mylabel"`;



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@doris.apache.org
For additional commands, e-mail: commits-help@doris.apache.org