To add Elsaticsearch-hadoop-2.1.2.jar as an example, describe several ways to add a third-party jar to a hive.
1, add in hive Shell
[Hadoop@hadoopcluster78 bin]$./hive
Logging initialized using configuration in file:/home/hadoop/apache/ Hive-0.13.1/conf/hive-log4j.properties
hive> add Jar/home/hadoop/elasticsearch-hadoop-hive-2.1.2.jar; The Elasticsearch-hadoop-hive-2.1.2.jar is placed in the/home/hadoop directory of the local file system.
Added/home/hadoop/elasticsearch-hadoop-hive-2.1.2.jar to class path
Added resource:/home/hadoop/elasticsearch-hadoop-hive-2.1.2.jar
Connection mode
|
is valid
|
Hive Shell
|
No need to restart the Hive service is available
|
Hive Server
|
Invalid
|
2,jar into the ${hive_home}/auxlib directory
Create the folder Auxlib in ${hive_home}, and then put the custom jar file in the folder.
This method adds no need to reboot the hive. and more convenient.
Connection mode
|
is valid
|
Hive Shell
|
No need to restart the Hive service is available
|
Hive Server
|
Restart the Hive service before it takes effect
|
3,hive.aux.jars.path and Hive.aux.jars.pathThe Hive.aux.jars.path configuration of the HIVE.AUX.JARS.PATH and Hive-site.xml in hive-env.sh is invalid for the server, only valid for the current hive shell, and different hive shells do not affect each other. Each hive shell needs to be configured and can be configured into a folder format.
HIVE. AUX. JARS. Path and Hive.aux.jars.path only support local files. Can be configured as a file, or it can be configured as a folder.
Configure under ${hive_home}/conf/hive-env.sh:
Export Hive_aux_jars_path=/home/hadoop/apache/hive-0.13.1/lib/mysql-connector-java-5.1.7-bin.jar #本地文件路径, HDFs Path not supported
Similarly, it can be configured under ${hive_home}/conf/hive-site.xml:
<property>
<name>hive.aux.jars.path</name>
<value>/home/hadoop/ Elasticsearch-hadoop-hive-2.1.2.jar</value>
</property>
Connection mode
|
is valid
|
Hive Shell
|
Restarting the Hive service takes effect and the different hive shells do not affect each other
|
Hive Server
|
Invalid
|
Note: The Hive_aux_jars_path and hive-site.xml configuration Hive.aux.jars.path parameters configured in hive-env.sh will conflict and should be used with special attention.
4, add the jar directly to the ${hive_home}/lib directory
Connection mode
|
is valid
|
Hive Shell
|
Restart the Hive service before it takes effect
|
Hive Server
|
Restart the Hive service before it takes effect
|
Summary: Only the 2nd and 4th ways can be effective in hive server. Other in the hive server is invalid, read some articles online, said Hive-site.xml configuration Hive.aux.jars.path can work, but tried many times are useless, miss his sister, look forward to the great God answer.