1 Hive JDBC Service Setup
1.1 JDBC Service configuration
Edit ~/hive/conf/hive-site.xml
file and add parameters to configure IP and port to bind JDBC Server service:
~/hive/conf/hive-site.xml
<property> <name>hive.server2.thrift.bind.host</name> <value>hadoop1</value> </property> <property> <name>hive.server2.thrift.port</name> <value>10000</value> </property>
1.2 JDBC Security
By default HiveServer2 performs the query processing as the user who submitted the query. But if the hive.server2.enable.doAs parameter is set to false, the query will run as the user that the hiveserver2 process runs as.
This allow to overide security permissions and execute JDBC operations without security setup.
Edit file ~/hive/conf/hive-site.xml and change parameter hive.server2.enable.doAs to false:
~/hive/conf/hive-site.xml
<property> <name>hive.server2.enable.doAs</name> <value>false</value> <description> Setting this property to true will have HiveServer2 execute Hive operations as the user making the calls to it. </description> </property>
1.3 Start JDBC Server Service
To start JDBC service you should start hiveserver2 service. No other hive client should be running in same machine to allow hiveserver2 service to run.
$ hive --service hiveserver2
To run service in background, you can start it in background mode:
$ nohup hive --service hiveserver2 &
1.3.1 Auto Start-Stop using systemd
You can create a systemd service creating file: /etc/systemd/system/hive.service
[Unit] Description=Hive SQL Server 2 for Hadoop Requires=network-online.target After=hadoop.service [Service] User=hadoop Group=hadoop Type=forking WorkingDirectory=/home/hadoop ExecStart=/bin/sh -a -c 'source /home/hadoop/.bash_profile && cd /home/hadoop && (hive --service hiveserver2 &)' Environment=JAVA_HOME=/usr/lib/jvm/java-1.8.0 Environment=HIVE_HOME=/home/hadoop/hive #TimeoutStartSec=2min Restart=on-failure #PIDFile=/tmp/hadoop-hive-server2.pid [Install] WantedBy=multi-user.target
1.4 JDBC Client
To execute a JDBC client to test JDBC connection, you can use beeline
client
$ beeline -u jdbc:hive2://localhost:10000
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/hadoop/hive/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/hadoop/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Connecting to jdbc:hive2://localhost:10000
Connected to: Apache Hive (version 2.3.2)
Driver: Hive JDBC (version 2.3.2)
Transaction isolation: TRANSACTION_REPEATABLE_READ
Beeline version 2.3.2 by Apache Hive
0: jdbc:hive2://localhost:10000>
To check JDBC connection works properly, you can get JDBC connection info by executing: !dbinfo in beeline:
0: jdbc:hive2://localhost:10000> !dbinfo ;
allProceduresAreCallable Error: Method not supported (state=,code=0)
allTablesAreSelectable true
dataDefinitionCausesTransactionCommit Error: Method not supported (state=,code=0)
dataDefinitionIgnoredInTransactions Error: Method not supported (state=,code=0)
doesMaxRowSizeIncludeBlobs Error: Method not supported (state=,code=0)
getCatalogSeparator .
getCatalogTerm instance
getDatabaseProductName Apache Hive
getDatabaseProductVersion 2.3.2
getDefaultTransactionIsolation 0
getDriverMajorVersion 2
getDriverMinorVersion 3
getDriverName Hive JDBC
getDriverVersion 2.3.2
getExtraNameCharacters
getIdentifierQuoteString
getMaxBinaryLiteralLength Error: Method not supported (state=,code=0)
getMaxCatalogNameLength Error: Method not supported (state=,code=0)
getMaxCharLiteralLength Error: Method not supported (state=,code=0)
getMaxColumnNameLength 128
getMaxColumnsInGroupBy Error: Method not supported (state=,code=0)
getMaxColumnsInIndex Error: Method not supported (state=,code=0)
getMaxColumnsInOrderBy Error: Method not supported (state=,code=0)
getMaxColumnsInSelect Error: Method not supported (state=,code=0)
getMaxColumnsInTable Error: Method not supported (state=,code=0)
getMaxConnections Error: Method not supported (state=,code=0)
getMaxCursorNameLength Error: Method not supported (state=,code=0)
getMaxIndexLength Error: Method not supported (state=,code=0)
getMaxProcedureNameLength Error: Method not supported (state=,code=0)
getMaxRowSize Error: Method not supported (state=,code=0)
getMaxSchemaNameLength Error: Method not supported (state=,code=0)
getMaxStatementLength Error: Method not supported (state=,code=0)
getMaxStatements Error: Method not supported (state=,code=0)
getMaxTableNameLength Error: Method not supported (state=,code=0)
getMaxTablesInSelect Error: Method not supported (state=,code=0)
getMaxUserNameLength Error: Method not supported (state=,code=0)
getNumericFunctions
getProcedureTerm UDF
getSchemaTerm database
getSearchStringEscape \
getSQLKeywords Error: Method not supported (state=,code=0)
....