kettle集群的部署已过了很长时间,今天突然想总结下部署过程,方便后人和自己以后部署方便。
一、运行环境
kettle众所周知是Java开发的开源项目,故kettle需要java环境,正常大型项目可能需要用到kettle的资源库配置,故需要一台数据库服务器,里面单独建立kettle的资源库(后面配置会用到),仅此而已。
二、配置文件
无论是主机还是从机都需要这两个配置文件,carte.xml和repositories.xml,其中carte.xml分主从机配置。这两个配置文件放在kettle文件的根目录下即可,下面分别说一下这两个配置文件都需要配置什么:
1、carte.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>#kettle主机命名名称,可自拟
<hostname>1.1.1.1</hostname>#你的主机IP的地址
<port>9090</port>#端口号
<username>cluster</username>#用户名固定
<password>cluster</password>#密码固定
<master>Y</master>#选择是主机还是从机,是Y否N
</slaveserver>
<repository>
<name>dbrep_kettle7</name>#kettle资源库名称
<user>admin</user>#资源库用户名固定
<password>admin</password>#资源库密码固定
</repository>
</slave_config>
carte.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.
-->
#master为主机配置,需要完全和主机的carte配置一一对应
<masters>
<slaveserver>
<name>master1</name>#主机的名字
<hostname>1.1.1.1</hostname>#主机的IP配置
<port>9090</port>#主机的端口号
<username>cluster</username>
<password>cluster</password>
<master>Y</master>
</slaveserver>
</masters>
#是否将从机结果反馈给主机
<report_to_masters>Y</report_to_masters>
#从机配置
<slaveserver>
<name>slave1</name>#从机名称,自拟
<hostname>192.150.251.157</hostname>#从机地址
<port>9091</port>#从机端口号
<username>cluster</username>#从机用户名
<password>cluster</password>#从机密码
<master>N</master>#从机为N
</slaveserver>
#注意:从机同样要配资源库,且和主机资源库保持一致
<repository>
<name>dbrep_kettle7</name>
<user>admin</user>
<password>admin</password>
</repository>
</slave_config>
2、 repositories.xml
<?xml version="1.0" encoding="UTF-8"?>
<repositories>
#数据库连接
<connection>
<name>kettle</name>#数据库连接的名称,自拟
<server>10.10.10.10</server>#数据库地址
<type>MYSQL</type>#数据库类型
<access>Native</access>#mysql默认为native(jdbc)连接方式
<database>kettle</database>#数据库名称
<port>3306</port>#mysql数据库端口号
<username>dsp_kettle7</username>#数据库用户名
<password>Encrypted 2be98afc86ace9c97bb0cbc218dc7f09b</password>#数据库密码
<servername/>
<data_tablespace/>
<index_tablespace/>
#默认属性,无需修改
<attributes>
<attribute><code>FORCE_IDENTIFIERS_TO_LOWERCASE</code><attribute>N</attribute></attribute>
<attribute><code>FORCE_IDENTIFIERS_TO_UPPERCASE</code><attribute>N</attribute></attribute>
<attribute><code>IS_CLUSTERED</code><attribute>N</attribute></attribute>
<attribute><code>PORT_NUMBER</code><attribute>3306</attribute></attribute>
<attribute><code>PRESERVE_RESERVED_WORD_CASE</code><attribute>Y</attribute></attribute>
<attribute><code>QUOTE_ALL_FIELDS</code><attribute>N</attribute></attribute>
<attribute><code>STREAM_RESULTS</code><attribute>Y</attribute></attribute>
<attribute><code>SUPPORTS_BOOLEAN_DATA_TYPE</code><attribute>Y</attribute></attribute>
<attribute><code>SUPPORTS_TIMESTAMP_DATA_TYPE</code><attribute>Y</attribute></attribute>
<attribute><code>USE_POOLING</code><attribute>N</attribute></attribute>
</attributes>
</connection>
#资源库配置
<repository>
<id>KettleDatabaseRepository</id>#资源库id,固定,无需修改
<name>dbrep_kettle7</name>#资源库连接名称,自拟,必须要与carte资源库配置一致
<description>dbrep_kettle7</description>#资源库描述,自拟
<is_default>true</is_default>#是否是默认资源库,选是就可以
<connection>kettle</connection>#连接的数据库名称,和上面connection的数据库连接名称(name)保持一致
</repository>
</repositories>
三、kettle启动
1、先看看.sh结尾的文件权限,权限不够需要赋予权限:
# chmod +x *.sh //以.sh结尾的文件必须拥有执行权限,如果没有,请赋予
2、建议:可调节spoon.sh的最大内存占用空间,尤其是从服务器,主服务主要进行任务分配,从服务器进行执行,保证从服务器运行内存在4G以上,当然也要看我们的任务量和交换量,仅做建议。
修改方法如下:vim spoon.sh
找到这句话,修改里面的Xmx(占用内存最大值):
PENTAHO_DI_JAVA_OPTIONS="-Xms1024m -Xmx4096m -XX:MaxPermSize=256m"
3、各个部署的机器上启动kettle,启动命令:nohup ./carte.sh carte.xml 2>&1 &
四、验证方法
浏览器登录网址kettle部署的IP+你设置的端口号,输入设置的用户名密码(cluster)即可查看kettle状态,即启动成功。
以上部署集群的方法如有问题或需要补充内容可与我单独交流,共同探讨。