kettle集群

本文详细介绍了如何在Kettle中配置和搭建一个1主2从的集群,包括主服务器与从服务器的配置、步骤粒度的集群应用和实际测试过程。通过实例展示,读者将学会如何设置Carte配置文件,以及如何确保集群在主服务器故障时仍能正常运作。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

背景:

学习,学习,还是TM的学习(微笑脸)!

 

1. 简介

在Kettle中合理的使用集群可以加快执行的速度,并且还能在部分服务器宕机的情况下继续使用。Kettle中集群是由一个主Carte服务器和多个从Carte服务器组成。在执行转换时,主服务器负责分发跟踪任务和收集结果总汇,从服务器负责具体的转换执行。在Kettle中,如果主服务器也宕机的话并不存在服务器(类似于redis、zookeeper等)重新选举的功能,也就是说一旦主服务器宕机,则Kettle集群就不能使用了

——百度

kettle的集群粒度是每个步骤,右键步骤会有集群的选项。

主服务器不仅仅分发任务收集结果,也有执行任务的功能。

例如,一个转换有3个步骤,设置步骤2为集群的话,那么步骤2会在子服务器执行,步骤1和步骤3依旧在主服务器上执行。

 

kettle集群官方文档:https://help.pentaho.com/Documentation/9.1/Products/Set_Up_a_Carte_Cluster

 2. 集群

本文集群设置1主2从,因此三个节点上需要部署kettle,可以参考:kettle简介与安装

博主在windows上部署了一个作为主服务器,两个虚拟机各部署一个kettle作为从服务器。

进入kettle安装目录,在目录pwd下有以下配置,集群时需要配置以下文件:

2.1 主服务器 

编辑carte-config-master-8080.xml

<slave_config>
  <!-- 
     Document description...
     
     - masters: You can list the slave servers to which this slave has to report back to.
                If this is a master, we will contact the other masters to get a list of all the slaves in the cluster.

     - report_to_masters : send a message to the defined masters to let them know we exist (Y/N)

     - slaveserver : specify the slave server details of this carte instance.
                     IMPORTANT : the username and password specified here are used by the master instances to connect to this slave.

  --> 

  <slaveserver>
    <name>master1</name>
    <hostname>192.168.0.142</hostname>
    <port>8080</port>
    <master>Y</master>
	<username>yuwen</username>
	<password>yuwen</password>
  </slaveserver>


</slave_config>

保存配置,回到上级目录,打开cmd,执行以下命令,即可启动一个kettle的web服务:

Carte.bat ./pwd/carte-config-master-8080.xml

启动成功日志如下:

2.2 从服务器

进入1号从服务器kettle的pwd目录下,编辑carte-config-8081.xml,指定主服务器和配置自身信息,注意,主服务器的master标签值为Y,从服务器为N。

<slave_config>
  <!-- 
     Document description...
     
     - masters: You can list the slave servers to which this slave has to report back to.
                If this is a master, we will contact the other masters to get a list of all the slaves in the cluster.

     - report_to_masters : send a message to the defined masters to let them know we exist (Y/N)

     - slaveserver : specify the slave server details of this carte instance.
                     IMPORTANT : the username and password specified here are used by the master instances to connect to this slave.

  --> 

  <masters>

    <slaveserver>
      <name>master1</name>
      <hostname>192.168.0.142</hostname>
      <port>8080</port>
      <username>yuwen</username>
      <password>yuwen</password>
      <master>Y</master>
    </slaveserver>

  </masters>

  <report_to_masters>Y</report_to_masters>

  <slaveserver>
    <name>slave1-8081</name>
    <hostname>192.168.59.128</hostname>
    <port>8081</port>
    <username>yuwen</username>
    <password>yuwen</password>
    <master>N</master>
  </slaveserver>


</slave_config>

返回上级目录,执行以下命令,启动1号从服务器

./carte.sh pwd/carte-config-8081.xml

出现以下日志则启动成功,


进入2号从服务器kettle的pwd目录下,编辑carte-config-8082.xml,指定主服务器和配置自身信息,

<slave_config>
  <!-- 
     Document description...
     
     - masters: You can list the slave servers to which this slave has to report back to.
                If this is a master, we will contact the other masters to get a list of all the slaves in the cluster.

     - report_to_masters : send a message to the defined masters to let them know we exist (Y/N)

     - slaveserver : specify the slave server details of this carte instance.
                     IMPORTANT : the username and password specified here are used by the master instances to connect to this slave.

  --> 

  <masters>

    <slaveserver>
      <name>master1</name>
      <hostname>192.168.0.142</hostname>
      <port>8080</port>
      <username>yuwen</username>
      <password>yuwen</password>
      <master>Y</master>
    </slaveserver>

  </masters>

  <report_to_masters>Y</report_to_masters>

  <slaveserver>
    <name>slave2-8082</name>
    <hostname>192.168.59.129</hostname>
    <port>8082</port>
    <username>yuwen</username>
    <password>yuwen</password>
    <master>N</master>
  </slaveserver>


</slave_config>

返回上级目录,执行以下命令,启动1号从服务器

./carte.sh pwd/carte-config-8082.xml

出现以下日志则启动成功,

 

3. 测试

使用前文的转换进行测试,kettle新建转换

 打开 主对象树->转换->子服务器 ,右击新建,分别建立上面配置的三个服务器,注意,主服务器需要勾选 是主服务器吗? 选项。

右击子服务器下的 kettle集群schemas,点击新建,把刚刚的子服务器添加上,注意把 Dynamic cluster 勾选上,因为我们是动态集群,如果有部分从服务器失去连接,也能执行。如果没有勾选,就以静态集群使用,如果有部分服务器失去连接,就会报connect refused错误。

配置好后,右击转换的表输出步骤,点击集群,咱们把它配置为集群运行

 配置好后,表输出就会出现一个 CxN 的标识

接下来去配置集群的启动设置,打开 主对象树->转换->run configuration。右击新建一个运行配置,如下;

最后我们去运行这个转换,运行配置选择刚刚新建的,

点击启动,查看三台机器的日志分别如下

主:

从1:

从2: 

主服务器执行了没有配置集群的几个步骤,分发配置集群的表输出到从服务器。

从服务器执行了配置集群的表输出 。

结果符合预期。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值