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

TDLC 命令行工具访问

最近更新时间:2026-10-23 17:30:30
本文档已由 AI 辅助审校
我的收藏
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} engine={a}
# 配置 Spark 作业的资源组
./tdlc config set resource-group=my-rg
# 清除配置(unset 支持一次清多个 key)
./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 中的 ${key} 占位符。
--param-strict
是否启用严格模式,默认 true 。开启后 SQL 中存在未替换的 ${key} 占位符会在提交前直接失败。
--task-name
自定义任务名称,用于下游系统展示和识别,适用于 tasks 和 batch-sql 两种提交模式。不指定时不设置自定义任务名称。
示例:
# 带认证与指定资源配置时执行命令(覆盖 config 中的默认值)
./tdlc sql -e "SELECT 1" --secret-id aa --secret-key bb --region ap-beijing --engine public-engine --resource-group my-rg
# 读取本地 ~/biz.sql 文件中的 SQL 提交到 DLC 引擎执行,执行完成后不拉取/打印结果集
./tdlc sql -f ~/biz.sql --no-result
# 读取cos中的文件 SQL 提交到 DLC 引擎执行
./tdlc sql -f cosn://bucket/path/biz.sql
# 查询类:显示执行进度
./tdlc sql -e "SELECT * FROM dlc_db.orders LIMIT 100" -p
# 安静模式:提交后立即退出,不等待执行结果
./tdlc sql -e "INSERT INTO dlc_db.logs VALUES (1, 'a')" -q
# 透传 Session 配置项,可重复指定
./tdlc sql -e "SELECT * FROM dlc_db.large_tbl" \\
--conf spark.sql.adaptive.enabled=true \\
--conf spark.sql.shuffle.partitions=200
# 临时密钥(STS)一次性使用:命令行参数覆盖 config
./tdlc sql -e "SELECT 1" --secret-id TmpAKIDxx --secret-key TmpSKxx --token xxxx --region ap-guangzhou
#使用 batch-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
终止任务
del
删除作业配置
# 查看全部 Spark 作业
./tdlc spark list

# 按作业名再次运行(复用已有作业配置)
./tdlc spark run --name etl-daily

# 查看 Driver 日志 / 指定 Executor 日志
./tdlc spark log --name etl-daily --task-id task-xyz789
./tdlc spark log --name etl-daily --task-id task-xyz789 --executor 1

# 终止运行中的任务
./tdlc spark kill --task-id task-xyz789

# 删除作业配置
./tdlc spark del --name etl-daily
以下是 Spark submit 子命令 支持的参数,列表中的文件相关参数支持使用本地文件或 COSN 协议。
参数
说明
--driver-size
driver 规格,支持使用 small、medium、large、xlarge,内存型集群使用 m.small、m.medium、m.large、m.xlarge。默认使用 medium 规格。
--executor-size
executor 规格,支持使用 small、medium、large、xlarge,内存型集群使用 m.small、m.medium、m.large、m.xlarge。默认使用 medium 规格。
--executor-num
executor 数量
--files
上传的附加依赖文件(非 jar/py),使用 , 分隔,运行时可在 Driver/Executor 的工作目录下直接访问
--archives
依赖压缩文件
--class
Java/Scala 运行的主函数
--jars
依赖的 jar 包,使用 , 分隔
--name
程序名称
--py-files
依赖的 Python 文件,支持.zip、.egg、.py 格式
--conf
额外配置
--network
网络配置,配置格式为:--network "network name"
--task-name
自定义本次运行的任务名称,用于下游系统展示和识别。不指定时不设置自定义任务名称。该参数标识每次运行的任务,不替代用于标识 Spark 应用的 --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
./tdlc spark submit --name spark-demo3 --task-name daily-etl-20260730 cosn://bucket1/etl.py

# 指定 COS 访问角色(jar 作业必需,也可 config set 固化)
./tdlc spark submit --name cos-demo --engine sparkjar \\
--role-arn qcs::cam::uin/100000000000:roleName/DLCAccessRole \\
--class com.demo.CosJob /root/cos-job.jar

# 安静模式:不流式打印日志,等任务结束后按退出码判断成败(适合 CI)
./tdlc spark submit --name ci-demo --engine sparkpy -q cosn://bucket1/ci_job.py