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
<configuration>
<property>
<!-- 配置NameNode地址 -->
<name>fs.defaultFS</name>
<value>hdfs://bigdata111:9000</value>
</property>
<property>
<!-- 保存HDFS臨時數據的目錄 -->
<name>hadoop.tmp.dir</name>
<value>/root/bigdata/hadoop-2.7.3/tmp</value>
</property>
<property>
<name>hadoop.proxyuser.root.hosts</name>
<value>*</value>
</property>
<property>
<name>hadoop.proxyuser.root.groups</name>
<value>*</value>
</property>
</configuration>
這里說明下:
<property>
<name>hadoop.proxyuser.root.hosts</name>
<value>*</value>
</property>
<property>
<name>hadoop.proxyuser.root.groups</name>
<value>*</value>
</property>
如果不配置這兩個屬性,可能會出現如下問題:
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
<configuration>
<property>
<!-- HDFS數據冗余度,默認3 -->
<name>dfs.replication</name>
<value>1</value>
</property>
</configuration>
我使用的是單機搭建的集群。
<configuration>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://bigdata111:3306/hive?createDatabaseIfNotExist=true&useSSL=false</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>root</value>
</property>
<property>
<name>hive.exec.scratchdir</name>
<value>/hive/mapreduce</value>
</property>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/hive/warehouse</value>
</property>
<property>
<name>hive.server2.thrift.bind.host</name>
<value>bigdata111</value>
</property>
<property>
<name>hive.server2.thrift.port</name>
<value>10001</value>
</property>
</configuration>
上面的其他配置不用關心,主要是最后兩個屬性,我們連接的是HiveServer2,如下配置HiveServer2主機和端口
<property>
<name>hive.server2.thrift.bind.host</name>
<value>bigdata111</value>
</property>
<property>
<name>hive.server2.thrift.port</name>
<value>10001</value>
</property>
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。
