Support Questions
Find answers, ask questions, and share your expertise
Announcements
Alert: Welcome to the Unified Cloudera Community. Former HCC members be sure to read and learn how to activate your account here.

Beeline -u "JDBC:hive2://url..." -n username gives error while beeline !connect "JDBC:hive2://url..." works

Beeline -u "JDBC:hive2://url..." -n username gives error while beeline !connect "JDBC:hive2://url..." works

New Contributor

When I directly try to connect to hive using Beeline -u "jdbc:hive2://node03.comp.net:2181,node02.comp.net:2181,node01.comp.net:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2-hive2" -n username

CLI throws the following error

"Connecting to jdbc:hive2://node03.comp.net:2181,node02.comp.net:2181,node01.comp.net:2181/
17/07/07 18:11:35 [main]: WARN jdbc.HiveConnection: Failed to connect to node03.comp.net:2181
Error: Could not open client transport with JDBC Uri: jdbc:hive2://node03.comp.net:2181/: null (state=08S01,code=0)
Beeline version 1.2.1000.2.6.1.0-129 by Apache Hive"

While I just run beeline <enter> and use same jdbc url I'm able to connect.

!connect jdbc:hive2://node03.comp.net:2181,node02.comp.net:2181,node01.comp.net:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2-hive2
Connecting to jdbc:hive2://node03.comp.net:2181,node02.comp.net:2181,node01.comp.net:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2-hive2
Enter username for jdbc:hive2://node03.comp.net:2181,node02.comp.net:2181,node01.comp.net:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2-hive2: username
Enter password for jdbc:hive2://node03.comp.net:2181,node02.comp.net:2181,node01.comp.net:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2-hive2:  *********
Connected to: Apache Hive (version 2.1.0.2.6.1.0-129)
Driver: Hive JDBC (version 1.2.1000.2.6.1.0-129)
Transaction isolation: TRANSACTION_REPEATABLE_READ

Any idea why this is happening. How to fix it?

A bit about our env:

We have Ranger (LDAP) for authorization and also LDAP/AD for Hive authentication.

I plan to use the above commands to launch HQL scripts with parameters like

beeline -u jdbc:hive2://node03.comp.net:2181,node02.comp.net:2181,node01.comp.net:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2-hive2 -n xxxx -w pfile -f /home/hdfs/hive_llap/script/test.hql --hivevar db=$dbname

Any help is appreciated, thanks.

7 REPLIES 7

Re: Beeline -u "JDBC:hive2://url..." -n username gives error while beeline !connect "JDBC:hive2://url..." works

Master Collaborator

Typically beeline -u "<jdbc_url>" -n <username> -w <password>, note the jdbc_url is quoted. Are you sure you did that?

Re: Beeline -u "JDBC:hive2://url..." -n username gives error while beeline !connect "JDBC:hive2://url..." works

New Contributor

Yes, I tried both the approach with double quotes and without quotes.

Re: Beeline -u "JDBC:hive2://url..." -n username gives error while beeline !connect "JDBC:hive2://url..." works

Expert Contributor

@Gaurav Mallikarjuna Try the below command and see if it works for you.

In my environment, hive.server2.zookeeper.namespace is set to hiveserver2. Try to put the command within quotes.

[hdfs@hadoopnn01 ~]$ beeline -u "jdbc:hive2://hadoopnn01.infoshop.com.tr:2181,hadoop01.infoshop.com.tr:2181,hadoopnn02.infoshop.com.tr:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2" WARNING: Use "yarn jar" to launch YARN applications. Connecting to jdbc:hive2://hadoopnn01.infoshop.com.tr:2181,hadoop01.infoshop.com.tr:2181,hadoopnn02.infoshop.com.tr:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2 Connected to: Apache Hive (version 1.2.1000.2.4.3.0-227) Driver: Hive JDBC (version 1.2.1000.2.4.3.0-227) Transaction isolation: TRANSACTION_REPEATABLE_READ Beeline version 1.2.1000.2.4.3.0-227 by Apache Hive 0: jdbc:hive2://hadoopnn01.infoshop.com.tr:21>

https://community.hortonworks.com/questions/1342/how-to-enable-zookeeper-discovery-for-hiveserver2.h...

Re: Beeline -u "JDBC:hive2://url..." -n username gives error while beeline !connect "JDBC:hive2://url..." works

@Gaurav Mallikarjuna

I tested the same as mine HDP 2.6.1 and could not see any issues

[root@dkhdp262c6 ~]# beeline -u "jdbc:hive2://dkhdp263c6.openstacklocal:2181,dkhdp262c6.openstacklocal:2181,dkhdp261c6.openstacklocal:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2" -n admin
Connecting to jdbc:hive2://dkhdp263c6.openstacklocal:2181,dkhdp262c6.openstacklocal:2181,dkhdp261c6.openstacklocal:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2
Connected to: Apache Hive (version 1.2.1000.2.6.1.0-129)
Driver: Hive JDBC (version 1.2.1000.2.6.1.0-129)
Transaction isolation: TRANSACTION_REPEATABLE_READ
Beeline version 1.2.1000.2.6.1.0-129 by Apache Hive
0: jdbc:hive2://dkhdp263c6.openstacklocal:218> show databases;
+----------------+--+
| database_name  |
+----------------+--+
| default        |
+----------------+--+
1 row selected (0.305 seconds)
0: jdbc:hive2://dkhdp263c6.openstacklocal:218>

This is non Kerberised environment though.

One more thing, I have transport mode set to binary. What is yours?

If your environment is also non-Kerberised and hive transport mode is binary, try the following:

beeline -u "jdbc:hive2://dkhdp261c6.openstacklocal:10000/" -n admin

The above is a hostname where your hiveserver2 is installed + its port number.

Here is how this works my end:

[root@dkhdp262c6 ~]# beeline -u "jdbc:hive2://dkhdp261c6.openstacklocal:10000/" -n admin
Connecting to jdbc:hive2://dkhdp261c6.openstacklocal:10000/
Connected to: Apache Hive (version 1.2.1000.2.6.1.0-129)
Driver: Hive JDBC (version 1.2.1000.2.6.1.0-129)
Transaction isolation: TRANSACTION_REPEATABLE_READ
Beeline version 1.2.1000.2.6.1.0-129 by Apache Hive
0: jdbc:hive2://dkhdp261c6.openstacklocal:100> show databases;
+----------------+--+
| database_name  |
+----------------+--+
| default        |
+----------------+--+
1 row selected (0.29 seconds)
0: jdbc:hive2://dkhdp261c6.openstacklocal:100>
Highlighted

Re: Beeline -u "JDBC:hive2://url..." -n username gives error while beeline !connect "JDBC:hive2://url..." works

New Contributor

@Daniel Kozlowski We have Ranger (LDAP) for authorization and also LDAP/AD for Hive authentication. So the "-n admin" option doesn't work

Re: Beeline -u "JDBC:hive2://url..." -n username gives error while beeline !connect "JDBC:hive2://url..." works

@Gaurav Mallikarjuna

In the above example you can notice that I used other method to connect to hiveserver2 - using hive2 node + its port number like

$ beeline -u "jdbc:hive2://dkhdp261c6.openstacklocal:10000/" -n admin

Using admin is for my sample only.

In your case - if your transport mode is binary and the cluster is NON kerberized -

$ beeline -u "jdbc:hive2://<hiveserver2-hostname>:10000/" -n <username>

Re: Beeline -u "JDBC:hive2://url..." -n username gives error while beeline !connect "JDBC:hive2://url..." works

Cloudera Employee

@Gaurav Mallikarjuna

I believe the issue could be with the permissions on the '/user/hive/' directory in hdfs. So the user you are passing in your beeline command line should have the proper access to this directory as well. In my case, the '/user/hive/' was owned by 'hive' user and 'hadoop' group. Also the folder has '755' permissions in my case.

I tried below query and it worked for me:

# beeline -u "jdbc:hive2://<my zookeeper fqdn>:2181,<my zookeeper fqdn>:2181,<my zookeeper fqdn>:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2" -u hrt_qa

Connecting to jdbc:hive2://<my zookeeper fqdn>:2181,<my zookeeper fqdn>:2181,<my zookeeper fqdn>:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2

Connected to: Apache Hive (version 1.2.1000.2.5.0.0-1245)

Driver: Hive JDBC (version 1.2.1000.2.5.0.0-1245)

Transaction isolation: TRANSACTION_REPEATABLE_READ

Beeline version 1.2.1000.2.5.0.0-1245 by Apache Hive

0: jdbc:hive2://<my zookeeper hostname>.o>

So, I think it has nothing to with quotes.

Don't have an account?
Coming from Hortonworks? Activate your account here