Apache Hop 常用 CLI 命令与工具详解
Apache Hop 2.19.0 常用 CLI 命令与工具详解:hop 主命令、hop run 执行、hop server、hop conf、hop encrypt、hop gui、hop search 等子命令的真实帮助与速查,含参数默认值与示例。
Apache Hop 常用 CLI 命令与工具详解
目标:详解 Apache Hop 2.19.0 的命令行工具
hop及其子命令(run、server、conf、encrypt、gui等),各命令参数与默认值均来自本机真实--help/--version回显,并给出可独立执行的示例。
一、环境信息
| 项目 | 值 |
|---|---|
| 操作系统 | Ubuntu 22.04.5 LTS |
| 软件版本 | Apache Hop 2.19.0 |
| 运行 JDK | OpenJDK 21.0.12.1 |
| 安装目录 | /opt/apache-hop/hop |
| 项目根目录 | /opt/data/apache-hop/project |
| 主命令路径 | /opt/apache-hop/hop/hop |
| 示例账号 | root/admin,示例密码 q1w2e3r4 |
二、工具概览
Apache Hop 命令行统一由主命令 hop(或其等价脚本 hop-run.sh、hop-server.sh 等)进入。hop 顶层子命令:
| 子命令 | 作用 |
|---|---|
help | 显示指定命令的帮助 |
run | 运行一个转换(pipeline)或工作流(workflow) |
server | 以 Hop 服务器(Web/API)常驻运行 |
conf | 配置 Hop(项目、环境、驱动等) |
driver | 管理 JDBC 驱动(list/install) |
encrypt | 加密密钥/密码 |
gui | 启动 Hop 图形界面(GUI) |
import | 导入元数据 |
search | 在 Hop 元数据中搜索 |
marketplace | 从 Maven 仓库安装/管理可选插件 |
三、前置条件
- 已完成 Hop 2.19.0 安装并设置环境变量(
source /etc/profile.d/hop-env.sh),hop在PATH中。 - 转换/工作流文件位于项目
PROJECT_HOME内(本文为/opt/data/apache-hop/project),并已配置pipeline-run-configuration/local.json。 - 下列命令大多在项目目录执行
cd /opt/data/apache-hop/project。
四、工具详解
4.1 hop(主命令)
显示主帮助:
hop -h
实测回显:
Usage: hop [-hV] [--dev-debug] [--dev-debug-wait] [-s=<systemProperties>[,
<systemProperties>...]]... [COMMAND]
--dev-debug Allow a Hop developer to debug remotely
--dev-debug-wait Allow a Hop developer to debug remotely. The script
will wait until a debugging session is set up.
-h, --help Show this help message and exit.
-s, --system-properties=<systemProperties>[,<systemProperties>...]
A comma separated list of KEY=VALUE pairs
-V, --version Print version information and exit.
Commands:
help Display help information about the specified command.
conf Configure Hop
driver Manage JDBC drivers (list, install)
encrypt Encrypt secrets
gui The Hop GUI
import Import metadata
marketplace Install and manage optional Hop plugins from a Maven repository
run Run a pipeline or workflow
search Search in Hop metadata
server Run a Hop server
输出版本号:
hop --version
实测回显:2.19.0
⚠️ 注意:实测
hop --version与hop -h正确输出后退出码为1,这是 Hop 对 help/version 分支的既有行为,判定成功以是否输出版本/帮助为准。
4.2 hop run(运行转换/工作流)
hop run 是命令行执行转换(.hpl)与工作流(.hwf)的核心命令。
hop run --help
实测回显:
Usage: hop run [-hov] [-au] [-a=<startActionName>] [-e=<environmentOption>]
[-f=<filename>] [-j=<projectOption>] [-l=<level>]
[-lf=<logFile>] [-m=<metadataExportFile>]
[-ps=<parametersSeparator>] [-r=<runConfigurationName>]
[-p=<parameters>]... [-s=<systemProperties>[,
<systemProperties>...]]...
Run a pipeline or workflow
-a, --startaction=<startActionName>
The name of the action where to start a workflow
-au, --allow-unsupported
Allow running pipelines or workflows that contain
transforms or actions marked UNSUPPORTED on the
selected engine. By default such runs are rejected
at startup with the list of incompatible elements;
this flag is the CLI equivalent of the GUI "Run
anyway" override.
-e, --environment=<environmentOption>
The name of the lifecycle environment to use
-f, --file=<filename> The filename of the workflow or pipeline to run
-h, --help Displays this help message and quits.
-j, --project=<projectOption>
The name of the project to use
-l, --level=<level> The debug level, one of NOTHING, ERROR, MINIMAL,
BASIC, DETAILED, DEBUG, ROWLEVEL
-lf, --logfile=<logFile>
The complete filename where hop-run will write the
Hop console log
-m, --metadata-export=<metadataExportFile>
A file containing exported metadata in JSON format
-o, --printoptions Print the used options
-p, --parameters=<parameters>
A list of PARAMETER=VALUE pairs (default separator:
comma). For values containing the separator, wrap
in double quotes, e.g. -p 'key1="value1,value2"'
-ps, --parameters-separator=<parametersSeparator>
A character to be used as separator for our list of
PARAMETER=VALUE pairs (default is ,)
-r, --runconfig=<runConfigurationName>
The name of the Run Configuration to use
-s, --system-properties=<systemProperties>[,<systemProperties>...]
A comma separated list of KEY=VALUE pairs
-v, --version Print version information and exit
常用参数速查:
| 参数 | 默认值 | 含义 |
|---|---|---|
-f, --file | 必填 | 待运行转换/工作流文件名 |
-r, --runconfig | local | 运行配置名 |
-p, --parameters | , | 参数 KEY=VALUE 列表,分隔符为逗号 |
-ps, --parameters-separator | , | 参数分隔符 |
-l, --level | Basic | 日志级别:NOTHING/ERROR/MINIMAL/BASIC/DETAILED/DEBUG/ROWLEVEL |
-lf, --logfile | 空 | Hop 控制台日志写入文件 |
-o, --printoptions | 关 | 打印本次实际使用的选项 |
-a, --startaction | 空 | 工作流起始动作名 |
执行转换(带参数):
hop run -f pipelines/my-first-pipeline.hpl
实测回显:
2026/10/11 05:45:48 - HopRun - Enabling project 'default'
2026/10/11 05:45:48 - HopRun - Two-way password encoder initialized with plugin ID 'Hop' for project 'default'
2026/10/11 05:45:48 - HopRun - Starting pipeline: /opt/data/apache-hop/project/pipelines/my-first-pipeline.hpl
2026/10/11 05:45:48 - my-first-pipeline - Executing this pipeline using the Local Pipeline Engine with run configuration 'local'
2026/10/11 05:45:48 - my-first-pipeline - Execution started for pipeline [my-first-pipeline]
2026/10/11 05:45:48 - Generate Rows.0 - Finished processing (I=0, O=0, R=0, W=10, U=0, E=0)
2026/10/11 05:45:48 - Dummy.0 - Finished processing (I=0, O=0, R=10, W=10, U=0, E=0)
2026/10/11 05:45:48 - my-first-pipeline - Pipeline duration : 0.093 seconds [ 0.093" ]
2026/10/11 05:45:48 - my-first-pipeline - Execution finished on a local pipeline engine with run configuration 'local'
执行转换并覆盖参数 row_limit=15(转换内已定义参数):
hop run -f pipelines/my-first-pipeline.hpl -p row_limit=15
实测回显示例(行数按参数变大):
Generate Rows.0 - Finished processing (I=0, O=0, R=0, W=15, U=0, E=0)
Dummy.0 - Finished processing (I=0, O=0, R=15, W=15, U=0, E=0)
执行时打印实际使用的选项:
hop run -f pipelines/my-first-pipeline.hpl -o
实测回显(节选):
HopRun - OPTION: filename : '/opt/data/apache-hop/project/pipelines/my-first-pipeline.hpl'
HopRun - OPTION: run configuration : 'local'
HopRun - OPTION: Logging level : Basic
执行并把日志写入文件(ROWLEVEL 级别,逐行输出):
hop run -f pipelines/my-first-pipeline.hpl -lf /opt/data/apache-hop/logs/pipeline.log -l ROWLEVEL
实测写入的日志文件头(/opt/data/apache-hop/logs/pipeline.log):
2026/10/11 05:46:57 - HopRun - Starting pipeline: /opt/data/apache-hop/project/pipelines/my-first-pipeline.hpl
2026/10/11 05:46:57 - my-first-pipeline - Executing this pipeline using the Local Pipeline Engine with run configuration 'local'
2026/10/11 05:46:57 - my-first-pipeline - Execution started for pipeline [my-first-pipeline]
执行工作流:
hop run -f workflows/my-first-workflow.hwf
实测回显:
2026/10/11 05:46:08 - HopRun - Starting workflow: /opt/data/apache-hop/project/workflows/my-first-workflow.hwf
2026/10/11 05:46:08 - my-first-workflow - Start of workflow execution
2026/10/11 05:46:08 - my-first-workflow - Starting action [Start]
2026/10/11 05:46:08 - my-first-workflow - Finished action [Start] (result=[true])
2026/10/11 05:46:08 - my-first-workflow - Starting action [Dummy Action]
2026/10/11 05:46:08 - my-first-workflow - Finished action [Dummy Action] (result=[true])
2026/10/11 05:46:08 - my-first-workflow - Workflow execution finished
2026/10/11 05:46:08 - my-first-workflow - Workflow duration : 0.027 seconds [ 0.027" ]
4.3 hop run 子命令退出码
| 场景 | 退出码 |
|---|---|
| 转换/工作流执行成功 | 0 |
| 文件路径无效/运行配置缺失 | 非 0(伴随异常栈) |
hop --version / hop -h | 1(正常输出,Hop 既有行为) |
4.4 hop server(运行 Hop 服务器)
hop server 以常驻方式启动 Hop Web 服务,监听 8080:
hop server --help
实测回显(节选):
Usage: hop server [-ahV] [-gs] [-e=<environmentOption>] [-id=<id>]
[-j=<projectOption>] [-l=<level>] [-n=<serverName>]
[-p=<password>] [-ps=<pipelineName>] [-swt=<shutdownTimeout>]
[-u=<username>] [-ws=<workflowName>] [-s=<systemProperties>[,
<systemProperties>...]]... [<parameters>...]
Run a Hop server
-a, --auth Does the Hop web server have authentication enabled
-e, --environment=<environmentOption>
The name of the lifecycle environment to use
-g, --general-status List the general status of the server
-h, --help Show this help message and exit.
-id=<id> Specify the ID of the pipeline or workflow to query
-j, --project=<projectOption>
The name of the project to use
-l, --level=<level> The debug level, one of NOTHING, ERROR, MINIMAL,
BASIC, DETAILED, DEBUG, ROWLEVEL
-n, --server-name=<serverName>
The name of the server to start as defined in the
metadata.
-p, --password=<password>
The server password. Required for administrative
operations only, not for starting the server.
-ps, --pipeline-status=<pipelineName>
List the status of the pipeline with this name (also
specify the -id option)
-s, --system-properties=<systemProperties>[,<systemProperties>...]
A comma separated list of KEY=VALUE pairs
-swt, --shutdown-timeout=<shutdownTimeout>
-u, --username=<username>
The username. Required for administrative operations
only, not for starting the server.
-ws, --workflow-status=<workflowName>
List the status of the workflow with this name
启动服务器:
hop server
实测回显(节选):
HopServer - Enabling project 'default'
HopServer - Two-way password encoder initialized with plugin ID 'Hop' for project 'default'
HopServer - Installing timer to purge stale objects after 1440 minutes.
HopServer - Hop Server: Basic authentication is ENABLED
HopServer - Created listener for webserver @ address : localhost:8080
💡 说明:
hop server默认监听localhost:8080并开启 Basic 认证(认证账号按部署配置,演示用admin/q1w2e3r4)。停止用Ctrl+C或kill <PID>。
4.5 hop conf(配置 Hop)
hop conf --help 实测回显(节选):
Usage: hop conf [-hv] [-cdb] [-eap] [-ec] [-ed] [-el] [-em] [-exafs] [-exv]
[-ey] [--git-gui-diff-ignore-position] [--git-gui-enabled]
[--git-gui-search-parent-folders] [-oh] [-pc] [-pd] [-pkf]
[-pl] [-pla] [-plm] [-plt] [-pm] [-pn] [-py] [-sat] [-sit]
[-wd] [-we] [-aza=<account>] [-aze=<localEmulatorUrl>]
[-azk=<key>] [-cfg=<configFile>]
[-dc=<defaultProjectConfigFile>] [-de=<defaultEnvironment>]
[-dp=<defaultProject>] [-dv=<describeVariable>]
[-e=<environmentName>] [-ep=<environmentProject>]
...
Configure Hop
-aza, --azure-account=<account>
常用参数速查:
| 参数 | 含义 |
|---|---|
-dp, --default-project=<defaultProject> | 设置默认项目 |
-de, --default-environment=<defaultEnvironment> | 设置默认生命周期环境 |
-sv, --set-variable=<setVariable> | 设置变量(KEY=VALUE) |
-dv, --describe-variable=<describeVariable> | 描述某变量 |
-p, --project=<projectName> | 指定项目名 |
-ph, --project-home=<projectHome> | 指定项目目录 |
-pl, --list-projects | 列出项目 |
4.6 hop encrypt(加密密钥)
生成 Hop 使用的加密/混淆密码:
hop encrypt --help
实测回显:
Usage: hop encrypt [-hV] [-hop] [-server]
Encrypt secrets
-h, --help Show this help message and exit.
-hop, --hop Generate an obfuscated or encrypted password
(depending on the configuration), for use in XML,
password or metadata files
-server, --server generate an obfuscated password to include in the
hop-server password file 'pwd/hop.pwd'
-V, --version Print version information and exit.
💡 说明:
-hop生成用于元数据/XML 的加密密码;-server生成写入pwd/hop.pwd的服务端密码。交互式回车后输入需加密的明文口令。
4.7 hop gui(图形界面)
hop gui --help
实测回显:
Usage: hop gui [-hV]
The Hop GUI
-h, --help Show this help message and exit.
-V, --version Print version information and exit.
⚠️ 说明:
hop gui需要在带桌面图形环境(X/Wayland 显示)的服务器上运行,无头纯 CLI 服务器不可用图形界面。
4.8 其它子命令
hop driver:JDBC 驱动管理,子操作为list(列出已装驱动)与install(安装驱动)。hop search:在 Hop 元数据中按关键字搜索。hop import:导入导出的元数据(结合hop run的-m --metadata-export导出)。hop marketplace:从 Maven 仓库安装可选插件。
各子命令可用 hop <子命令> --help 查看明细。
五、注意事项
- 执行前先加载环境:
source /etc/profile.d/hop-env.sh,确保hop在PATH、HOP_OPTIONS已设置为堆限(-Xms256m -Xmx512m)。 - 参数分隔符:
-p的多个参数用逗号分隔(key1=v1,key2=v2);值含逗号时包双引号,如-p 'key1="v1,v2"'。 hop run与hop run.sh等价:hop-run.sh是对hop run的脚本封装,用法一致。- 日志级别:
ROWLEVEL会逐行打印处理的数据,数据量大时开销大,普通验证用MINIMAL/BASIC。 -version退出码为 1:hop --version/-h输出正常但退出码为1,属既有行为,不要误判为失败。
六、常见问题
6.1 hop run -f 报 Invalid Java Runtime(UnsupportedClassVersionError)
定位:JAVA_HOME 指向了 JDK 17(或更旧)。解决:export JAVA_HOME=/usr/lib/jvm/java-21-openjdk-amd64 后重试。
6.2 'hop' 不是内部或外部命令
定位:hop 不在 PATH。解决:export PATH="/opt/apache-hop/hop:$PATH" 或将安装目录加入 PATH。
6.3 hop run 报 Please specify a run configuration
定位:项目缺少运行配置。解决:为项目创建 metadata/pipeline-run-configuration/local.json(名称 local),或 -r 指定已有配置。
6.4 日志文件未生成
定位:-lf 指定的父目录不存在。解决:先 mkdir -p 日志目录(如 /opt/data/apache-hop/logs)再执行。
七、参考链接
- Apache Hop 官方下载站:https://dlcdn.apache.org/hop/
- Apache Hop 项目官网:https://hop.apache.org/
- Apache Hop 官方文档(命令行):https://hop.apache.org/manual/latest/
- Apache Hop GitHub 仓库:https://github.com/apache/hop