Created 08-07-2018 11:13 PM
How can I connect to Hive with a UNIX/HDFS user via beeline?
Let's say I have a UNIX user named "newuser". I tried the following, but apparently I am doing something wrong.
% su - newuser % beeline beeline>!connect -n newuser -p jdbc:mysql://my.host.com/hive
Created on 08-07-2018 11:33 PM - edited 08-17-2019 08:09 PM
What error are you gettin while connecting to hive using beeling?
Are you sure that the URL which you entered is correct... Becaue looks like you are trying to connect to MySQL database instead of hiveServer2.
Following is what i tried:
# useradd test # usermod -G hadoop test # su - hdfs -c "hdfs dfs -mkdir /user/test" # su - hdfs -c "hdfs dfs -chown -R test:hadoop /user/test"
.
The connect to Beeline using test user:
# su - test $ beeline Beeline version 1.2.1000.2.6.5.0-292 by Apache Hive beeline> !connect jdbc:hive2://newhwx1.example.com:2181,newhwx2.example.com:2181,newhwx3.example.com:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2
.
Execute queries:
beeline> !connect jdbc:hive2://newhwx1.example.com:2181,newhwx2.example.com:2181,newhwx3.example.com:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2 Connecting to jdbc:hive2://newhwx1.example.com:2181,newhwx2.example.com:2181,newhwx3.example.com:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2 Enter username for jdbc:hive2://newhwx1.example.com:2181,newhwx2.example.com:2181,newhwx3.example.com:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2: Enter password for jdbc:hive2://newhwx1.example.com:2181,newhwx2.example.com:2181,newhwx3.example.com:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2: Connected to: Apache Hive (version 1.2.1000.2.6.5.0-292) Driver: Hive JDBC (version 1.2.1000.2.6.5.0-292) Transaction isolation: TRANSACTION_REPEATABLE_READ 0: jdbc:hive2://newhwx1.example.com:2181,newh> show databases; +----------------+--+ | database_name | +----------------+--+ | default | +----------------+--+ 1 row selected (0.627 seconds)
Here the URL needs to be correct. For example in above case i am connecting to HiveServer2 using the Zookeepre quorum which i found in the Ambari Hive Summary page.
jdbc:hive2://newhwx1.example.com:2181,newhwx2.example.com:2181,newhwx3.example.com:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2
.
Hive URL you can get from here in Ambari UI:
.
Created on 08-07-2018 11:33 PM - edited 08-17-2019 08:09 PM
What error are you gettin while connecting to hive using beeling?
Are you sure that the URL which you entered is correct... Becaue looks like you are trying to connect to MySQL database instead of hiveServer2.
Following is what i tried:
# useradd test # usermod -G hadoop test # su - hdfs -c "hdfs dfs -mkdir /user/test" # su - hdfs -c "hdfs dfs -chown -R test:hadoop /user/test"
.
The connect to Beeline using test user:
# su - test $ beeline Beeline version 1.2.1000.2.6.5.0-292 by Apache Hive beeline> !connect jdbc:hive2://newhwx1.example.com:2181,newhwx2.example.com:2181,newhwx3.example.com:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2
.
Execute queries:
beeline> !connect jdbc:hive2://newhwx1.example.com:2181,newhwx2.example.com:2181,newhwx3.example.com:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2 Connecting to jdbc:hive2://newhwx1.example.com:2181,newhwx2.example.com:2181,newhwx3.example.com:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2 Enter username for jdbc:hive2://newhwx1.example.com:2181,newhwx2.example.com:2181,newhwx3.example.com:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2: Enter password for jdbc:hive2://newhwx1.example.com:2181,newhwx2.example.com:2181,newhwx3.example.com:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2: Connected to: Apache Hive (version 1.2.1000.2.6.5.0-292) Driver: Hive JDBC (version 1.2.1000.2.6.5.0-292) Transaction isolation: TRANSACTION_REPEATABLE_READ 0: jdbc:hive2://newhwx1.example.com:2181,newh> show databases; +----------------+--+ | database_name | +----------------+--+ | default | +----------------+--+ 1 row selected (0.627 seconds)
Here the URL needs to be correct. For example in above case i am connecting to HiveServer2 using the Zookeepre quorum which i found in the Ambari Hive Summary page.
jdbc:hive2://newhwx1.example.com:2181,newhwx2.example.com:2181,newhwx3.example.com:2181/;serviceDiscoveryMode=zooKeeper;zooKeeperNamespace=hiveserver2
.
Hive URL you can get from here in Ambari UI:
.