Beeline command issue - jdbc

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>

Related

hive shell is not starting in cloudera

I tried restarting my system, checked whether there is enough space or not and also made sure my hive server2 is running. But I'm getting these errors when given '$hive' in Cloudera.
Logging initialized using configuration in
file:/etc/hive/conf.dist/hive-log4j.properties
WARN: The method class
org.apache.commons.logging.impl.SLF4JLogFactory#release() was invoked.
Exception in thread "main" java.lang.RuntimeException:
org.apache.hadoop.hive.ql.metadata.HiveException:
java.lang.RuntimeException:
org.apache.hadoop.hive.ql.metadata.HiveException:
java.lang.RuntimeException: Unable to instantiate
org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient
The process of starting Hive2 is changed, as Hive got deprecated. Usage of Beeline is recommended.
Beeline was developed specifically to interact with the new server. Unlike Hive CLI, which is an Apache Thrift-based client, Beeline is a JDBC client based on the SQLLine CLI — although the JDBC driver used communicates with HiveServer2 using HiveServer2’s Thrift APIs.
As Hive development has shifted from the original Hive server (HiveServer1) to the new server (HiveServer2), users and developers accordingly need to switch to the new client tool. However, there’s more to this process than simply switching the executable name from “hive” to “beeline”.
More information provided over here
Use the below command to enter into interactive mode. Beeline supports same commands that Hive server does. You can execute same script in Beeline without any modifications.
beeline -u jdbc:hive2://
To start the Hive metastore,
sudo service hive-metastore start

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.

beeline not able to connect to hiveserver2

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).

JDBC connection to Shark Server hangs

I am using following configuration for my shark cluster
Scala 2.10.3
Spark 0.9.0
Hive 0.12.0-chd5.0.2
Shark 0.9.0
Spark and Hive are configured via Cloudera manager (CDH 5.0.2)
I am following this tutorial to connect to shark server:
https://cwiki.apache.org/confluence/display/Hive/HiveClient
I start shark server as follows:./shark --service sharkserver 9956
I am able to connect to hive server using code in above mentioned tutorial.
But when i try to connect to shark server it hung at this line
Connection con = DriverManager.getConnection("jdbc:hive://localhost:9956/default", "", "");
It does not give any error or exception, just program stuck at that line.
I was able to solve this problem by running server in sudo mode.
In default mode shark server was unable to write a file because of permission denied error.

Could not establish connection to localhost:10000/default: java.net.ConnectException: Connection refused

I have work on Hadoop/Hive. I have installed Hadoop 1.1.2 and Hive 0.10.0.When I use Hive as command prompt then it works fine,but when I am using as it JDBC in Eclipse then gives the below error :
Could not establish connection to localhost:10000/default:
java.net.ConnectException: Connection refused
You can connect to Hive in two modes. Through thrift server and embedded mode.
By seeing your url localhost:10000/default, it looks like you are trying to connect to the thrift sever. So please ensure that you are have started the hive thrift server by the following command.
$ hive --service hiveserver
If you want to connect in embedded mode. you should give the url as
jdbc:hive://
To use the embedded mode you should add the hive/conf and the jars in hive/lib to your classpath.
It is to be noted that, use of the Thrift server is not thread safe as of now.

Resources