再打开一个客户端窗口启动 hive,会产生 java.sql.SQLException 异常。

> Exception in thread "main" java.lang.RuntimeException:
> java.lang.RuntimeException: Unable to instantiate
> org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient
>     at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:522)
> at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:677)
>     at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:621)
>     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.run(RunJar.java:221) at
> org.apache.hadoop.util.RunJar.main(RunJar.java:136) Caused by:
> java.lang.RuntimeException: Unable to instantiate
> org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient at
> org.apache.hadoop.hive.metastore.MetaStoreUtils.newInstance(MetaStoreUtils.java:1523)
> at
> org.apache.hadoop.hive.metastore.RetryingMetaStoreClient.(RetryingMetaStoreClient.ja
> va:86) at
> org.apache.hadoop.hive.metastore.RetryingMetaStoreClient.getProxy(RetryingMetaStoreClien
> t.java:132) at
> org.apache.hadoop.hive.metastore.RetryingMetaStoreClient.getProxy(RetryingMetaStoreClien
> t.java:104) at
> org.apache.hadoop.hive.ql.metadata.Hive.createMetaStoreClient(Hive.java:3005)
> at org.apache.hadoop.hive.ql.metadata.Hive.getMSC(Hive.java:3024) at
> org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:503)
> ... 8 more

Cause:Metastore默认存储在自带的derby数据库中,而在实际生产中大多数wgetMySQL存储Metastore.

配置Metastore到MySQL

  1. 安装MySQL并拷贝驱动

  2. 在$HIVE_HOME/conf创建一个hive-site.xml

  3. 在$HIVE_HOME/conf创建一个hive-site.xml
    根据官方文档配置参数,拷贝数据到 hive-site.xml 文件中。

     
     javax.jdo.option.ConnectionURL
    jdbc:mysql://hadoop102:3306/metastore?createDatabaseIfNotExist=true JDBC connect string for a JDBC metastore
    
    
    javax.jdo.option.ConnectionDriverName com.mysql.jdbc.Driver
    Driver class name for a JDBC metastore
    
    
    javax.jdo.option.ConnectionUserName root
    username to use against metastore database
    
    
    
    javax.jdo.option.ConnectionPassword 000000
    password to use against metastore database
     
    hive.cli.print.current.db
    true
    Whether to include the current database in the Hive
    prompt. 
    
    hive.cli.print.header
    false
    Whether to print the names of the columns in query output.
     
    

你可能感兴趣的:(解决问题)