帮你快速理解、总结文档立即下载

TDLC 命令行工具访问

最近更新时间:2026-06-08 15:45:27

我的收藏
TDLC 是腾讯云数据湖计算 (DataLake Compute,DLC) 提供的客户端命令工具。通过 TDLC 工具,您可以向 DLC 数据引擎 提交 SQL、Spark 任务。
TDLC 使用 Go 编写,基于 Cobra 框架,支持配置多个存储桶和跨桶操作。您可以通过 ./tdlc [command] --help 来查看 TDLC 的使用方法。

下载与安装

TDLC 命令行工具提供 Windows、Mac、Linux 操作系统的二进制包,通过简单的安装和配置后即可使用。您可以根据客户端的操作系统类型选择下载。
操作系统
TDLC 二进制包 下载地址
Windows
Mac
Linux
将下载的文件重命名为 tdlc。打开客户端的命令行,切换到下载路径下,如果您是 Mac/Linux 系统 ,需要使用 chmod +x tdlc 命令授予文件可执行权限。执行./tdlc 后,成功展示如下内容即安装成功可以使用。
Tencentcloud DLC command tools is used to play around with DLC.
With TDLC user can manger engines, execute SQLs and submit Spark Jobs.

Usage:
tdlc [flags]
tdlc [command]

Available Commands:
config
help Help about any command
spark Submit spark app to engines.
sql Executing SQL.
version

Flags:
--endpoint string Endpoint of Tencentcloud account. (default "dlc.tencentcloudapi.com")
--engine string DLC engine. (default "public-engine")
-h, --help help for tdlc
--region string Region of Tencentcloud account.
--resource-group string DLC resource group name of spark engine.
--role-arn string Required by spark jar app.
--secret-id string SecretId of Tencentcloud account.
--secret-key string SecretKey of Tencentcloud account.
--token string Token of Tencentcloud account.

Use "tdlc [command] --help" for more information about a command.

使用说明

全局参数

TDLC 提供如下全局参数。
全局参数
说明
--endpoint string
服务连接地址,默认使用 dlc.tencentcloudapi.com
--engine string
DLC 数据引擎名称,默认值为 public-engine。建议您使用独享数据引擎
--resource-group string
(选填)DLC 标准 Spark 引擎资源组名称,默认值为默认资源组 default-rg-xxxx
--region string
使用地域。如 ap-nanjing, ap-beijing, ap-guangzhou,ap-shanghai, ap-chengdu,ap-chongqing, na-siliconvalley, ap-singapore, ap-hongkong
--role-arn string
当您提交 Spark 作业时,需要指定访问 COS 文件的权限,此次指定权限角色的 rolearn,rolearn 详情可以参考配置数据访问策略
--secret-id string
腾讯云账号的 secretId
--secret-key string
腾讯云账号的 secretKey
--token string
(选填)腾讯云账号临时 token

CONFIG 命令

config 可以配置常用的参数,配置的参数会以默认值提供。命令行参数会覆盖已配置 config 的参数。
命令
说明
list
列出当前的默认配置
set
变更配置
unset
重置配置
示例:
./tdlc config list
./tdlc config set secret-id={1} secret-key={2} region={b}
./tdlc config unset region

SQL 子命令

SQL 子命令目前仅支持 Presto 或者 SparkSQL 集群,以下是 SQL 子命令支持的参数。
参数
说明
-e, --exec
执行 SQL 语句。
-f, --file
执行 SQL 文件,如果有多个 SQL 文件请用 ;分隔。
支持本地路径和 COS 路径,(cos://{bucket}/{key} 或 cosn://{bucket}/{key})。
--no-result
执行后不获取结果。
-p, --progress
显示执行进度。
-q, --quiet
安静模式,提交任务后不等待任务执行状态。
--conf
Session 配置项,格式为 key=value ,可重复指定。在 --submit-mode=batch-sql 下可透传任意 Spark 原生 conf。
--submit-mode
提交通道,可选 tasks(默认)或 batch-sql。
--driver-size
Driver 规格,可选 small / medium / large / xlarge ,内存型集群使用 m.small / m.medium / m.large / m.xlarge。
仅在 --submit-mode=batch-sql 下生效。
--executor-size
Executor 规格,取值同 --driver-size 。仅在 --submit-mode=batch-sql 下生效。
--executor-num
Executor 数量,仅在 --submit-mode=batch-sql 下生效。
--executor-max-num
Executor 数量上限,大于 --executor-num 时启用动态分配。仅在 --submit-mode=batch-sql 下生效。
--param
业务参数注入,格式为 key=value ,可重复指定,用于替换 SQL 中的 ${name} 占位符。
--param-strict
是否启用严格模式,默认 true 。开启后 SQL 中存在未替换的 ${name} 占位符会在提交前直接失败。
示例:
./tdlc sql -e "SELECT 1" --secret-id aa --secret-key bb --region ap-beijing --engine public-engine --resource-group my-rg
./tdlc sql -f ~/biz.sql --no-result

./tdlc sql -f cosn://bucket/path/biz.sql
./tdlc sql -e "SELECT 1" --submit-mode batch-sql --driver-size small --executor-size small --executor-num 2 --conf spark.sql.adaptive.enabled=true

Spark 子命令

Spark 子命令包含以下命令,可以用以提交 Spark 作业、查看运行日志、终止任务。
命令
说明
submit
通过 spark-submit 提交任务
run
执行 Spark 作业
log
查看运行日志
list
查看 Spark 作业列表
kill
终止任务
以下是 Spark submit 子命令 支持的参数,列表中的文件相关参数支持使用本地文件或 COSN 协议。
参数
说明
--driver-size
driver 规格,默认使用 small、medium、large、xlarge,内存型集群使用 m.small、m.medium、m.large、m.xlarge
--executor-size
executor 规格,默认使用 small、medium、large、xlarge,内存型集群使用 m.small、m.medium、m.large、m.xlarge
--executor-num
executor 数量
--files
查看 Spark 作业列表
--archives
依赖压缩文件
--class
Java/Scala 运行的主函数
--jars
依赖的 jar 包,使用 ,分隔
--name
程序名称
--py-files
依赖的 Python 文件,支持.zip、.egg、.py 格式
--conf
额外配置
--network
网络配置,配置格式为:--network "network name"
示例:
./tdlc spark submit --name spark-demo1 --engine sparkjar --jars /root/sparkjar-dep.jar --class com.demo.Example /root/sparkjar-main.jar arg1
./tdlc spark submit --name spark-demo2 cosn://bucket1/abc.py arg1