centos7环境下部署kettle

您所在的位置:网站首页 centos7的安装与启动目的 centos7环境下部署kettle

centos7环境下部署kettle

2023-07-31 09:03| 来源: 网络整理| 查看: 265

需求:

项目中业务数据库中的数据需要同步到目标数据库中,页面上的程序目前不具备数据抽取同步功能,暂时使用kettle作为同步抽取工具。

环境说明

Linux: Centos7.9 最小系统 JDK: 1.8.0_282 Kettle: 7.1.0.0-12

安装步骤

按照Centos7.9最小安装不在此章节介绍,主要围绕jdk和kettle的安装展开。

JDK安装

JDK安装分在线安装和离线安装两种方式。安装之前卸载系统在带的jdk

卸载jdk

查看是否已经安装jdk

yum list installed | grep java

如果无输出,说明没有安装,如果有输出信息,则删除之前安装版本

yum -y remove #输出的名称 在线安装jdk

安装命令

yum install java-1.8.0-openjdk* -y

查看版本

java -version

在这里插入图片描述

默认jre jdk 安装路径是/usr/lib/jvm 下面 在这里插入图片描述

离线安装

1、下载jdk 根据自己的需求下载对应的JDK版本,下载链接 如下:

https://java.com/zh-CN/download/manual.jsp

上传至服务器指定的目录 2、解压jdk

tar -zxvf jdk-linux-x64.tar.gz -C /usr/local/jdk/

3、配置环境变量

vi /etc/profile JAVA_HOME=/usr/local/jdk/jdk1.8.0.282/ PATH=$PATH:$JAVA_HOME/bin

4、配置生效

source /etc/profile

5、验证安装

java -version

在这里插入图片描述

离线安装和在线安装达到的效果都是一样的,为下一步kettle的安装准备条件。以上jdk安装完毕,接下来安装kettle

Kettle安装

1、下载kettle 根据需要下载对应的kettle版本,下载链接如下:

https://community.hitachivantara.com/s/article/data-integration-kettle

2、解压部署 下载后为zip压缩文件 解压文件:

unzip pdi-ce-7.1.0.0-12.zip -C /opt/kettle/

如果解压失败,安装zip解压包

yum install -y unzip

3、执行文件赋权限,默认没有执行权限 进入到解压文件就的data-integration文件夹下,给启动文件执行权限,命令如下:

chmod +x kitchen.sh

4、执行启动命令

./kitchen.sh

输出以下信息,说明kettle部署成功

Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; support was removed in 8.0 Options: -rep = Repository name -user = Repository username -pass = Repository password -job = The name of the job to launch -dir = The directory (dont forget the leading /) -file = The filename (Job XML) to launch -level = The logging level (Basic, Detailed, Debug, Rowlevel, Error, Minimal, Nothing) -logfile = The logging file to write to -listdir = List the directories in the repository -listjobs = List the jobs in the specified directory -listrep = List the available repositories -norep = Do not log into the repository -version = show the version, revision and build date -param = Set a named parameter =. For example -param:FILE=customers.csv -listparam = List information concerning the defined parameters in the specified job. -export = Exports all linked resources of the specified job. The argument is the name of a ZIP file. -custom = Set a custom plugin specific option as a String value in the job using =, for example: -custom:COLOR=Red -maxloglines = The maximum number of log lines that are kept internally by Kettle. Set to 0 to keep all rows (default) -maxlogtimeout = The maximum age (in minutes) of a log line while being kept internally by Kettle. Set to 0 to keep all rows indefinitely (default)

5、执行脚本 由于kettle本次安装为centos7最小系统安装,不具备图形化界面,需要将作业和转换的脚本在本地编写完毕后并验证确认无误后上传至服务执行。 在指定目录下创建shell脚本

#!/bin/bash # 将业务数据库抽取至目标数据库 # /opt/kettle/kjb/task.sh /opt/kettle/kitchen.sh -file=/opt/kettle/kjb/task.kjb log=log.timelog ~data +%y%m%d

如果有多个任务,可以编写多个shell脚本文件,后面单独配置定时任务。 6、给脚本文件赋执行权限

chmod a+x *.sh

7、编制定时任务 脚本编写完毕,数据抽取需要一定的时间间隔进行数据的抽取,抽取这块,分固定时间周期和数据量抽取策略(存量抽取和增量抽取) 运行,linux定时任务编写,

crontab -e

每隔5分钟执行一次task.sh

*/5 * * * * bash /opt/kettle/kjb/task.sh

8、验证定时任务 运行如下命令查看定时任务是否已经载入

crontab -l

9、重启定时任务,配置生效

systemctl restart crond

查看状态

systemctl status crond

10、验证kettle整体任务 目标数据库中查看业务数据库数据是否同步完成。



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3