Kettle连接HiveServer2配置和常见问题解决

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

扫描二维码关注公众号,回复: 10775920 查看本文章

两个参数主要配置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&amp;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。

发布了89 篇原创文章 · 获赞 79 · 访问量 10万+

猜你喜欢

转载自blog.csdn.net/L_15156024189/article/details/88714103
今日推荐