Search code examples
apache-zookeeperooziehortonworks-data-platformbeeline

How to connect to hive server 2 through hive2 oozie action?


I am unable to connect to Hive through Hive2 action of oozie. The jdbcUrl is zooKeeper service discovery enabled. My data platform is Hortonworks 2.6.

Initially I was trying to connect to beelne through a python script and that script was being executed by shell action of oozie. But was unable to do it. So I tried to use hive2 action instead. But even that is not working. The jdbcURL for beeline doesnt have SSL. It has zooKeeper service discovery enabled.

<workflow-app xmlns="uri:oozie:workflow:0.3" name="hive2-wf">
<start to="hive2-node"/>
<action name="hive2-node">
    <hive2 xmlns="uri:oozie:hive2-action:0.2">
        <job-tracker>${jobTracker}</job-tracker>
        <name-node>${nameNode}</name-node>
        <configuration>
            <property>
                <name>mapred.job.queue.name</name>
                <value>${queueName}</value>
            </property>
        </configuration>
        <jdbc-url>${jdbcURL}</jdbc-url>
        <script>table_create.hql</script>
    </hive2>
    <ok to="end"/>
    <error to="fail"/>
</action>

<kill name="fail">
    <message>Hive2 (Beeline) action failed, error message[${wf:errorMessage(wf:lastErrorNode())}]</message>
</kill>
<end name="end"/>

The error that I am facing is "org.apache.hive.jdbc.HiveConnection: Error opening session".

I tried with below properties. But still it is not working: oozie.use.system.libpath=true oozie.libpath= hdfs://host:8020/user/oozie/share/lib/lib_20180801150051 oozie.wf.application.path=hdfs://host/user/pid/hive2

SHARELIB PATH FOR ACTION#

oozie.action.sharelib.for.hive=hive,hcatalog,sqoop jdbcURL=jdbc:hive2://host:2181(zookeeper quorum) /;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2 hive_query=table_creation.hql

Also I noticed one thing. But don't know how relevant it is.The JDBC url that I am using has three diiferent zookeeper quorom: jdbcURL= jdbc:hive2://host1:2181,host2:2181,host3:2181/ ;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2

But when I run the oozie workflow, it is taking different port: Connecting to jdbc:hive2://host1:2181,host2:2181,host3:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2 Error: Could not establish connection to jdbc:hive2://host1:10001/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2: HTTP Response code: 401 (state=08S01,code=0)


Solution

  • It worked by providing jdbcURL and jdbcPrincipal in Hive credentials and passed these credentials to hive2 action