Hive学习2_错误: The specified datastore driver ("com.mysql.jdbc.Driver") was not found in the CLASSPATH

来源:互联网 发布:timcat如何绑定域名 编辑:程序博客网 时间:2024/05/18 01:05

在启动Hive时,报错:

The specified datastore driver ("com.mysql.jdbc.Driver") was not found in the CLASSPATH

详细描述见一篇英文文档。

I'm trying to install Apache Hive, I insert HIVE_HOME and HADOOP_HOME into hive_config.sh and I copy some hive jar into the $HADOOP_HOME/lib But when to lunch it, by using hive command this error appear :

Exception in thread "main" java.lang.RuntimeException: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.metastore.HiveMetaStoreClientat org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:346)at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:681)at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:625)at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)at java.lang.reflect.Method.invoke(Method.java:606)at org.apache.hadoop.util.RunJar.main(RunJar.java:156)Caused by: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.metastore.HiveMetaStoreClientat org.apache.hadoop.hive.metastore.MetaStoreUtils.newInstance(MetaStoreUtils.java:1412)at org.apache.hadoop.hive.metastore.RetryingMetaStoreClient.<init>(RetryingMetaStoreClient.java:62)at org.apache.hadoop.hive.metastore.RetryingMetaStoreClient.getProxy(RetryingMetaStoreClient.java:72)at org.apache.hadoop.hive.ql.metadata.Hive.createMetaStoreClient(Hive.java:2453)at org.apache.hadoop.hive.ql.metadata.Hive.getMSC(Hive.java:2465)at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:340)... 7 moreCaused by: java.lang.reflect.InvocationTargetExceptionat sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57)at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)at java.lang.reflect.Constructor.newInstance(Constructor.java:526)at org.apache.hadoop.hive.metastore.MetaStoreUtils.newInstance(MetaStoreUtils.java:1410)... 12 moreCaused by: javax.jdo.JDOFatalInternalException: Error creating transactional connection factoryNestedThrowables:java.lang.reflect.InvocationTargetExceptionetc ...

ANY HELP PLEASE !


相关回答:

Your hadoop should be in running condition. untar the downloaded hive and give the permission to the directory. Go to the hive/conf directory. Make hive-env.sh.template file to hive-env.sh and hive-default.xml.template file to hive-site.xml. Open hive-evn.sh and set JAVA_HOME in hive-env.sh and HADOOP_HOME and also set the hive path by.

export HIVE_HOME=/usr/local/hive

then open hive terminal by

hive

by default hive takes Derby database, if it gives error of metastore at the time of create table, go to metastore/metastore_db and delete the *.lck files.

Add the JAVA_HOME, HADOOP_HOME, HIVE_HOME in .bashrc or .bash_profile.

$cd ~$vi .bashrcpaste following to the end of the file#Hadoop variablesexport JAVA_HOME=/usr/lib/jvm/jdk/export PATH=$PATH:$JAVA_HOME/binexport HADOOP_HOME=/usr/local/hadoopexport PATH=$PATH:$HADOOP_INSTALL/binexport PATH=$PATH:$HADOOP_INSTALL/sbinexport HADOOP_MAPRED_HOME=$HADOOP_INSTALLexport HADOOP_COMMON_HOME=$HADOOP_INSTALLexport HADOOP_HDFS_HOME=$HADOOP_INSTALLexport YARN_HOME=$HADOOP_INSTALLexport HIVE_HOME=/usr/local/hiveexport PATH=$PATH:$HIVE_HOME/bin###end of paste

简单翻译:

Hadoop应该处于运行状态;

用户有对Hive文件的权限;

进入hive安装目录下的conf文件夹,由hive-env.sh.template文件复制出hive-env.sh文件,由hive-default.xml.template文件复制出hive-site.xml文件,在hive-site.xml文件中,设置JAVA_HOME、HADOOP_HOME和HIVE_HOME;

如果Hive使用的是Derby数据库,在创建table时报metastore错误,去metastore/metastore_db 目录,删除*.lck文件;

在.bashrc 或 .bash_profile加入JAVA_HOME, HADOOP_HOME, HIVE_HOME;


参考自:

http://stackoverflow.com/questions/28695444/apache-hive-unable-to-instantiate-org-apache-hadoop-hive-metastore-hivemetasto


错误原因:

未正确放置mysql jdbc jar 包

正确方法:

wget http://cdn.mysql.com//Downloads/Connector-J/mysql-connector-java-5.1.37.tar.gztar xvzf mysql-connector-java-5.1.37.tar.gzcp mysql-connector-java-5.1.37/mysql-connector-java-5.1.37-bin.jar $HIVE_HOME/lib

目的是将mysql-connector-java-5.1.37/mysql-connector-java-5.1.37-bin.jar放在$HIVE_HOME/lib


0 0
原创粉丝点击