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

6 篇文章 0 订阅

在启动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.HiveMetaStoreClient
at 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.HiveMetaStoreClient
at 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 more
Caused by: java.lang.reflect.InvocationTargetException
at 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 more
Caused by: javax.jdo.JDOFatalInternalException: Error creating transactional connection factory
NestedThrowables:
java.lang.reflect.InvocationTargetException
etc ...

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

paste following to the end of the file



#Hadoop variables
export JAVA_HOME=/usr/lib/jvm/jdk/
export PATH=$PATH:$JAVA_HOME/bin
export HADOOP_HOME=/usr/local/hadoop
export PATH=$PATH:$HADOOP_INSTALL/bin
export PATH=$PATH:$HADOOP_INSTALL/sbin
export HADOOP_MAPRED_HOME=$HADOOP_INSTALL
export HADOOP_COMMON_HOME=$HADOOP_INSTALL
export HADOOP_HDFS_HOME=$HADOOP_INSTALL
export YARN_HOME=$HADOOP_INSTALL
export HIVE_HOME=/usr/local/hive
export 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.gz
tar xvzf mysql-connector-java-5.1.37.tar.gz
cp 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


  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值