Kettle版本:pdi-ce-8.2.0.0-342.zip
Hive版本:apache-hive-2.3.0-bin.tar.gz
Hadoop版本:hadoop-2.7.3.tar.gz
Kettle关于Hadoop生态圈组件连接配置基本都在data-integration\plugins\pentaho-big-data-plugin目录下,如图:
其中plugin.properties配置文件中有两个主要参数:
(1)active.hadoop.configuration
# The Hadoop Configuration to use when communicating with a Hadoop cluster. This is used for all Hadoop client tools
# including HDFS, Hive, HBase, and Sqoop.
# For more configuration options specific to the Hadoop configuration choosen
# here see the config.properties file in that configuration's directory.
active.hadoop.configuration=hdp30
(2)hadoop.configurations.path
# Path to the directory that contains the available Hadoop configurations
hadoop.configurations.path=hadoop-configurations
两个参数主要配置Hadoop集群的版本,在hadoop-configurations目录下,提供了如下几个Hadoop集群版本:
其中cdh和hdp是目前用的比较多的两个版本。它们整合了Hadoop集群的各个组件,可以快速配置和部署。因为我们这里使用的是Apache开源的Hadoop集群,所以可以采用hdp30。选择hdp30,而不选择hdp26,主要是选择高版本可以向后兼容。
hdp30目录下,提供如下一些配置文件和jar包,如图:
我们这里连接Hive2,需要Hadoop集群支持,所以将Hadoop的配置文件core-site.xml,hdfs-site.xml和Hive的配置文件hive-site.xml拷贝过来(事先需要搭建好Hadoop和Hive集群)。
core-site.xml
fs.defaultFS
hdfs://bigdata111:9000
hadoop.tmp.dir
/root/bigdata/hadoop-2.7.3/tmp
hadoop.proxyuser.root.hosts
*
hadoop.proxyuser.root.groups
*
这里说明下:
如果不配置这两个属性,可能会出现如下问题:
Error connecting to database: (using class org.apache.hive.jdbc.HiveDriver)
Could not open client transport with JDBC Uri: jdbc:hive2://bigdata111:10001/test: Failed to open new session: java.lang.RuntimeException: org.apache.hadoop.ipc.RemoteException(org.apache.hadoop.security.authorize.AuthorizationException): User: root is not allowed to impersonate anonymous
主要是hadoop安全验证,不允许root匿名。配置好后需要重启hdfs。
hdfs-site.xml
dfs.replication
1
我使用的是单机搭建的集群。
javax.jdo.option.ConnectionURL
jdbc:mysql://bigdata111:3306/hive?createDatabaseIfNotExist=true&useSSL=false
javax.jdo.option.ConnectionDriverName
com.mysql.jdbc.Driver
javax.jdo.option.ConnectionUserName
root
javax.jdo.option.ConnectionPassword
root
hive.exec.scratchdir
/hive/mapreduce
hive.metastore.warehouse.dir
/hive/warehouse
hive.server2.thrift.bind.host
bigdata111
hive.server2.thrift.port
10001
上面的其他配置不用关心,主要是最后两个属性,我们连接的是HiveServer2,如下配置HiveServer2主机和端口
Kettle如下连接Hive2
如图,需要事先在Hive中创建好test的数据库用于连接测试,点击测试,连接成功后如图:
在连接过程中经常会出现Error connecting to database(using class org.apache.hadoop.hive.jdbc.HiveDriver)错误。原因有很多,主要有如下几个:
(1)版本兼容问题
hdp30目录下lib中的jdbc和Hive集群不兼容,可以将Hive集群中的lib下的jar包拷贝过来
(2)根本没有jdbc的jar
这时需要检查下active.hadoop.configuration=hdp30配置是否有问题,或者已经修改后,还是找不到jdbc,需要重启Kettle。