beeline not able to connect to hiveserver2 - hadoop

I have a CDH 5.3 instance.
I start the hive-server2 by first starting the hive-metastore and then the hive-server from command line.
After this I use beeline to connect to my hive-server2 but apparently it is not able to so.
Could not open connection to jdbc:hive2://localhost:10000: java.net.ConnectException: Connection refused (state=08S01,code=0)
Another issue, I tried to see if the hive-server2 was listening on port 10000.
I did " sudo netstat -tulpn | grep :10000" but none of the applications came up.
I also added the following property in the hive-site.xml but to no avail. Why it doesn't show up on the netstat?
<property>
<name>hive.server2.thrift.port</name>
<value>10000</value>
<description>TCP port number to listen on, default 10000</description>
</property>
The connect command on beeline:
!connect jdbc:hive2://localhost:10000 org.apache.hive.jdbc.HiveDriver
when asked for username and password, I just enter test "user" and "password"
for the respective values and then it throws the error.
Any help will be appreciated

Hive Connecting to beeline from client having various Modes.
1.Embedded Mode:
Both Server and Client runs in same machine. No TCP Connection required.
If hive.server2.authentication is "NONE" in HIVE_HOME/conf/hive-site.xml then connect beeline with below url
Connection URL:
!connect jdbc:hive2://
2. Remote Mode:
It supports multiple clients to execute queries with help of following Authentication schemes.
Authentication Schemes:
i.)SASL Authentication:
If value of "hive.server2.authentication" property in HIVE_HOME/conf/hive-site.xml to be set as "SASL" then connect hive beeline with below url
Beeline URL:
!connect jdbc:hive2://<host>:<port>/<db>
ii.)NOSASL Authentication:
If "hive.server2.authentication" is nosasl then connect the beeline like below.
Beeline URL:
!connect jdbc:hive2://<host>:<port>/<db>;auth=noSasl
Hope this really helps you
References:
https://docs.hortonworks.com/HDPDocuments/HDP2/HDP-2.3.2/bk_dataintegration/content/beeline-vs-hive-cli.html

I had the same problem here.
This is simply because hiveserver2 failed to start -- the error does not show up in console, but in hive logs. In my case, hive logs are located in /tmp/ubuntu/hive.log
There might be different reason for you to cause hive-server2 failed to start, but it definitely worth to look into this log file.

The following worked for me. If you installed and configured hive for the first time and trying to connect from beeline, make sure you start the hive service using the following command in the current terminal
>hive --service hiverserver2 &
The process id for Hiverver2 appears in the console.Then retry connecting to hive from beeline using different terminal:
>beeline -u "jdbc:hive2://localhost:10000/default" -n <username> -p <password> -d "org.apache.hive.jdbc.HiveDriver"

In this case,your hiveserver2 service was not started.please follow blow steps to check and fix.
step:
1.see hive.log file to check "Service:HiveServer2 is started."
1) find / -name hive.log
2) vim hive.log
in hive.log file ,if you can not find "Service:HiveServer2 is started.",then prove hiveserver2 is not started.
2.start hiveserver2
command: ./bin/hiveserver2
3.see hive.log。
if you can find "Service:HiveServer2 is started." in hive.log. then connect hiveserver2 by beeline.
4.connect hiveserver2
./bin/beeline
!connect jdbc:hive2://localhost:10000
5.below information can appeare.
Beeline version 1.2.1 by Apache Hive
beeline> !connect jdbc:hive2://localhost:10000
Connecting to jdbc:hive2://localhost:10000
Enter username for jdbc:hive2://localhost:10000: root
Enter password for jdbc:hive2://localhost:10000: ******
Connected to: Apache Hive (version 1.2.1)
Driver: Hive JDBC (version 1.2.1)
Transaction isolation: TRANSACTION_REPEATABLE_READ

you have to give hiveserver2 username and password check it in hive-site.xml by default username(anonymous) and password(anonymous) otherwise just give enter without giving password and username.

try with verbose option so you can see more details...
beeline -u "jdbc:hive2://localhost:10000/default;user=user;password=*******" --verbose

Please make sure the hive2service deployment IP.
I meet the same problem, I use the cloudera server ip(XXX.42) to connect the hive2 service; but in fact hive thrift service(hive2service) is depoyed on other machine(XXX.41).

Related

hive -h <hostname> not establishing connection to hive console

While inputing:
hive -h <hostname>
From hdfs command line I am not getting directed to hive console.
Still being asked for Hostname to be entered.
'Choose Hive Server/Metastore Hostname from : <hostname>'
'Enter Hive Server/Metastore Hostname :'
If the hostname is getting submitted using command hive -h then ideally it should not ask for hostname again.
Using Hive 3, the output I get from hive -h hostname is help that does not mention a -h option. Using beeline to specify a hostname works for me:
[me#myhost-1 ~]$ beeline -u jdbc:hive2://myhost-2.com:10000
...
Connecting to jdbc:hive2://myhost.com:10000
Connected to: Apache Hive (version 3.1.0.3.0.3.0-192)
Driver: Hive JDBC (version 3.1.0.3.0.3.0-192)
Transaction isolation: TRANSACTION_REPEATABLE_READ
Beeline version 3.1.0.3.0.3.0-192 by Apache Hive
0: jdbc:hive2://myhost-2.com:>
Help output also includes other beeline examples to connect to Hive:
Example:
1. Connect using simple authentication to HiveServer2 on localhost:10000
$ beeline -u jdbc:hive2://localhost:10000 username password
2. Connect using simple authentication to HiveServer2 on hs.local:10000 using -n for username and -p for password
$ beeline -n username -p password -u jdbc:hive2://hs2.local:10012
3. Connect using Kerberos authentication with hive/localhost#mydomain.com as HiveServer2 principal
$ beeline -u "jdbc:hive2://hs2.local:10013/default;principal=hive/localhost#mydomain.com"
4. Connect using SSL connection to HiveServer2 on localhost at 10000
$ beeline "jdbc:hive2://localhost:10000/default;ssl=true;sslTrustStore=/usr/local/truststore;trustStorePassword=mytruststorepassword"
5. Connect using LDAP authentication
$ beeline -u jdbc:hive2://hs2.local:10013/default <ldap-username> <ldap-password>
Using two hyphens, not one, is the correct syntax:
hive --help
Usage ./hive <parameters> --service serviceName <service parameters>
Service List: beeline cleardanglingscratchdir cli fixacidkeyindex help hiveburninclient hiveserver2 hplsql jar lineage llapdump llap llapstatus metastore metatool orcfiledump rcfilecat schemaTool strictmanagedmigration tokentool version
Parameters parsed:
--auxpath : Auxiliary jars
--config : Hive configuration directory
--service : Starts specific service/component. cli is default
Parameters used:
HADOOP_HOME or HADOOP_PREFIX : Hadoop install directory
HIVE_OPT : Hive options
For help on a particular service:
./hive --service serviceName --help
Debug help: ./hive --debug --help

Beeline cannot connect to HiveServe2 with NOSASL authentication mode ( old client )

This question is common here, there are several flavors of it. In this scenario, I set up an HiveServer2 with no authentication ( NOSASL ) which is working from Python, where I'm using Impyla library to connect.
When I connect using beeline, there is no way to get a working connection.
Beeline ends with:
beeline> !connect jdbc:hive2://127.0.0.1:10000/default/hive
Error: Could not open client transport with JDBC Uri: jdbc:hive2://127.0.0.1:10000/default/hive: null (state=08S01,code=0)
In HiveServer2 logs I have:
17/11/16 20:59:35 [HiveServer2-Handler-Pool: Thread-34]: ERROR server.TThreadPoolServer: Thrift error occurred during processing of message.
org.apache.thrift.protocol.TProtocolException: Missing version in readMessageBegin, old client?
at org.apache.thrift.protocol.TBinaryProtocol.readMessageBegin(TBinaryProtocol.java:228)
at org.apache.thrift.TBaseProcessor.process(TBaseProcessor.java:27)
at org.apache.hive.service.auth.TSetIpAddressProcessor.process(TSetIpAddressProcessor.java:56)
at org.apache.thrift.server.TThreadPoolServer$WorkerProcess.run(TThreadPoolServer.java:285)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Any ideas?
Finally, I found the solution.
!connect jdbc:hive2://127.0.0.1:10000/default/;auth=noSasl
Using this I'm able to connect to HiveServer2.
Also, I'm using HiveServer2 for development, so I started the processes under root and all the file system tree belongs to root. Due to this option, I need to use the root user when login to HiveServer2 using beeline:
Connecting to jdbc:hive2://127.0.0.1:10000/default/;auth=noSasl
Enter username for jdbc:hive2://127.0.0.1:10000/default/;auth=noSasl: root
Enter password for jdbc:hive2://127.0.0.1:10000/default/;auth=noSasl:
Connected to: Apache Hive (version 1.2.2)
I did not need to provide the password since there is no authentication at all. Now I'm able to create databases and tables.
This "​Comparing Beeline to the Hive CLI" has been a valid reference to solve this problem.

Hive : The application won't work without a running HiveServer2

I am new to this field. I was checking CDH 5.8 quick-start VM to try some basic hive/impala example.
But I hit an issue, while I am opening HUE it's giving below error. I searched solution for but didnt get anything which can resolve my issue.
Configuration files located in /etc/hue/conf.empty
Potential misconfiguration detected. Fix and restart Hue.
Hive The application won't work without a running HiveServer2.
I checked the and it's up & running. Tried restarting the service & CDH, didnt help.
Hive Server2 is running [ OK ]
When navigated to Hive tried some command it gave me below error.
Could not connect to quickstart.cloudera:10000 (code THRIFTTRANSPORT): TTransportException('Could not connect to quickstart.cloudera:10000',)
FOR Impala I am getting
AnalysisException: This Impala daemon is not ready to accept user requests. Status: Waiting for catalog update from the StateStore.
Tried starting hive --service metastore but got error
[cloudera#quickstart conf.empty]$ hive --service metastore
2017-03-03 05:37:14,502 WARN [main] mapreduce.TableMapReduceUtil: The hbase-prefix-tree module jar containing PrefixTreeCodec is not present. Continuing without it.
Starting Hive Metastore Server
org.apache.thrift.transport.TTransportException: Could not create ServerSocket on address 0.0.0.0/0.0.0.0:9083.
Not sure what is wrong or if I need to change some config. Can you anyone guide me towards the solution ?
You HiveServer2 requires Metastore up and running. Seems your Metastore Server cannot start because the port 9083 is already used by some service. Check it:
netstat -tulpn | grep 9083
If something is using this port you need to either change the port of you metastore in hive configuration or stop the application which already uses this port.

Connecting to Hive via Beeline using Kerberos keytab

Is it possible to connect to Hive via beeline using (kerberos) keytab file similar to the approach used for JDBC at
https://cwiki.apache.org/confluence/display/Hive/HiveServer2+Clients#HiveServer2Clients-UsingKerberoswithaPre-AuthenticatedSubject
PS : beeline does support connecting on a kerberos secured hive server with username and password. But I am looking for a way to connect it with a keytab file.
http://doc.mapr.com/display/MapR40x/Configuring+Hive+on+a+Secure+Cluster#ConfiguringHiveonaSecureCluster-UsingBeelinewithKerberos
I think you cannot connect with keytab file into beeline but you can get ticket with keytab using kinit and then pass the hive server principal with the jdbc connection string of beeline to connect.
kinit -k -t keytab principal
Connection string to connect with beeline
!connect jdbc:hive2://hostname:10000/default;principal=hive/_HOST#REALM
It is a bug, but it is not a critical one.
Though you provided kerberos details, still it will ask you the username and password. You can just enter -> enter, it allows us to connect.
Example:
!connect jdbc:hive2://:10000/default;principal=hive/_HOST#REALM.COM
Connecting to jdbc:hive2://:10000/default;principal=hive/_HOST#REALM.COM
Enter username for jdbc:hive2://:10000/default;principal=hive/_HOST#REALM.COM: press enter
Enter password for jdbc:hive2://:10000/default;principal=hive/_HOST#REALM.COM: press enter
Connected to: Apache Hive (version 0.13.1-cdh5.3.7-SNAPSHOT)
Driver: Hive JDBC (version 0.13.1-cdh5.3.7-SNAPSHOT)
Transaction isolation: TRANSACTION_REPEATABLE_READ

Beeline command issue

I am new to Hive and hopefully this is going to be an easy thing to solve
for someone with more experience, but I am having trouble doing it on my
own.
On my EC2 app server I am running the following command with no error:
beeline -u jdbc:hive2://master
This is working on Hive 13 which was installed through a bootstrap action
using the latest AMI version. 'master' is pointing to my EMR cluster
Then I downloaded the source for Hive 14 and built it. I have replaced my
/home/hadoop/hive directory with the package that was built.
However, if I try to execute the same command, I get an error:
scan complete in 6ms
Connecting to jdbc:hive2://master
Error: Could not open client transport with JDBC Uri: jdbc:hive2://master:
Cannot open without port. (state=08S01,code=0)
Beeline version 0.14.0 by Apache Hive
0: jdbc:hive2://master (closed)>
Running it with the port provided works correctly:
beeline -u jdbc:hive2://master:10000
I would like to be able to able to run the command without providing the
default port number.
Can anyone direct me with an instruction.
Thanks,
Hive Beeline Connection in Two Modes:
1.Embedded Mode:
If both Hive Client and Hive server are same then connect beeline by using below url:
!connect jdbc:hive2://
2.Remote Mode:
If server in one machine but client in one machine you can connect beeline using below url:
!connect jdbc:hive2://<host>:<port>

Resources