pentaho-kettle 命令行工具详解:Carte 服务器配置与远程执行

pentaho-kettle 命令行工具详解:Carte 服务器配置与远程执行

【免费下载链接】pentaho-kettle pentaho/pentaho-kettle: 一个基于 Java 的数据集成和变换工具,用于实现数据仓库和数据湖的构建。适合用于大数据集成和变换场景,可以实现高效的数据处理和计算。 【免费下载链接】pentaho-kettle 项目地址: https://gitcode.com/gh_mirrors/pe/pentaho-kettle

什么是Carte服务器

Carte是Pentaho Data Integration (PDI)的远程服务器组件,提供基于Web的API用于执行和监控转换(Transformation)与作业(Job)。作为数据集成和变换工具的核心服务,它允许用户通过网络接口远程管理数据处理任务,实现分布式数据集成架构。

快速启动Carte服务器

基础启动命令

Carte服务器可以通过命令行快速启动,默认使用8080端口:

./carte.sh

如需指定配置文件启动:

./carte.sh carte-config.xml

启动参数说明

  • -l:指定日志级别,如-l DEBUG启用调试日志
  • -x:启用XML格式日志输出

配置文件详解

配置文件结构

Carte服务器使用XML格式的配置文件,典型结构如下:

<?xml version="1.0" encoding="UTF-8"?>
<slave_config>
  <slaveserver>
    <name>Carte-Server</name>
    <hostname>localhost</hostname>
    <port>8080</port>
    <username>admin</username>
    <password>password</password>
    <master>N</master>
  </slaveserver>
  <max_log_lines>10000</max_log_lines>
  <max_log_timeout_minutes>1440</max_log_timeout_minutes>
  <object_timeout_minutes>1440</object_timeout_minutes>
</slave_config>

关键配置参数

参数说明默认值
name服务器名称Carte-Server
hostname主机名或IP地址localhost
port服务端口8080
username认证用户名admin
password认证密码password
max_log_lines最大日志行数10000
max_log_timeout_minutes日志超时分钟数1440

服务器管理API

基础URL与认证

Carte API的基础URL格式为:

http://{hostname}:{port}/kettle

默认情况下使用HTTP Basic认证,可通过curl命令访问:

curl -u username:password "http://localhost:8080/kettle/status?xml=Y"

获取服务器状态

使用以下命令检查Carte服务器运行状态:

# 获取XML格式状态
curl "http://localhost:8080/kettle/status?xml=Y"

# 获取HTML格式状态
curl "http://localhost:8080/kettle/status"

响应内容包含:

  • 服务器内存使用情况
  • CPU信息
  • 运行中的转换和作业
  • 系统信息

关闭服务器

通过API优雅关闭Carte服务器:

curl "http://localhost:8080/kettle/stopCarte?xml=Y"

转换(Transformation)管理

注册转换

从仓库或文件系统注册转换:

curl "http://localhost:8080/kettle/registerTrans?name=my-transformation&xml=Y"

执行转换

同步执行
curl "http://localhost:8080/kettle/executeTrans?name=my-transformation&xml=Y"
异步执行
curl "http://localhost:8080/kettle/runTrans?name=my-transformation&xml=Y"

监控转换状态

curl "http://localhost:8080/kettle/transStatus?name=my-transformation&xml=Y"

响应包含:

  • 执行状态
  • 步骤状态
  • 日志信息
  • 性能指标

停止转换

curl "http://localhost:8080/kettle/stopTrans?name=my-transformation&xml=Y"

作业(Job)管理

注册作业

curl "http://localhost:8080/kettle/registerJob?name=my-job&xml=Y"

执行作业

# 同步执行
curl "http://localhost:8080/kettle/executeJob?name=my-job&xml=Y"

# 异步执行
curl "http://localhost:8080/kettle/runJob?name=my-job&xml=Y"

监控作业状态

curl "http://localhost:8080/kettle/jobStatus?name=my-job&xml=Y"

实用工具API

获取服务器属性

curl "http://localhost:8080/kettle/properties?xml=Y"

健康检查

简单的健康检查端点:

curl "http://localhost:8080/kettle/status"

如果返回200状态码,表示Carte服务器运行正常。

安全配置

启用认证

在配置文件中设置用户名和密码:

<slaveserver>
  <name>slave-server-name</name>
  <hostname>localhost</hostname>
  <port>8080</port>
  <username>admin</username>
  <password>password</password>
</slaveserver>

安全最佳实践

  1. 始终启用认证
  2. 生产环境使用HTTPS加密传输
  3. 通过防火墙限制Carte端口访问
  4. 定期更新密码
  5. 监控服务器资源使用情况

集群管理

注册从服务器

curl "http://localhost:8080/kettle/registerSlave?xml=Y"

查看从服务器列表

curl "http://localhost:8080/kettle/getSlaves?xml=Y"

故障排除

常见问题解决

  1. 连接被拒绝:检查Carte是否运行及端口是否可访问
  2. 认证失败:验证用户名/密码配置
  3. 转换未找到:确保使用正确名称注册转换
  4. 内存问题:监控服务器资源并调整JVM设置

启用调试日志

./carte.sh carte-config.xml -l DEBUG

完整工作流示例

以下是一个完整的数据处理任务流程示例:

  1. 启动Carte服务器
./carte.sh carte-config.xml
  1. 注册并执行转换
# 注册转换
curl "http://localhost:8080/kettle/registerTrans?name=data-ETL&xml=Y"

# 执行转换
curl "http://localhost:8080/kettle/runTrans?name=data-ETL&xml=Y"

# 检查状态
curl "http://localhost:8080/kettle/transStatus?name=data-ETL&xml=Y"
  1. 执行后续作业
# 注册作业
curl "http://localhost:8080/kettle/registerJob?name=report-generation&xml=Y"

# 执行作业
curl "http://localhost:8080/kettle/runJob?name=report-generation&xml=Y"
  1. 查看作业状态
curl "http://localhost:8080/kettle/jobStatus?name=report-generation&xml=Y"

通过这些API和命令,您可以构建自动化的数据集成流程,实现远程、定时、批量的数据处理任务。Carte服务器为pentaho-kettle提供了强大的分布式执行能力,是构建企业级数据集成平台的关键组件。

【免费下载链接】pentaho-kettle pentaho/pentaho-kettle: 一个基于 Java 的数据集成和变换工具,用于实现数据仓库和数据湖的构建。适合用于大数据集成和变换场景,可以实现高效的数据处理和计算。 【免费下载链接】pentaho-kettle 项目地址: https://gitcode.com/gh_mirrors/pe/pentaho-kettle

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值