西马大数据:hive 源码解读(1)-环境搭建
1、将项目导入到idea
2、启动hive metastore
hive --service metastore
3、找到cli项目文件,这个文件是hive client 项目文件,直接运行CliDriver的话,会报很多莫名其妙的错,需要创建resources文件夹,将resources文件夹设置为Sources类型
- 将hdfs-site.xml core-site.xml yarn-site.xml mapred-site.xml hive-site.xml 放到hive-cli 目录resources
4、找到client driver类 ,运行
- 会报如下错误
问题:
Exception in thread "main" java.lang.RuntimeException: org.apache.hadoop.hive.ql.metadata.HiveException: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient
at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:591)
at org.apache.hadoop.hive.ql.session.SessionState.beginStart(SessionState.java:531)
at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:705)
at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:641)
Caused by: org.apache.hadoop.hive.ql.metadata.HiveException: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient
解决方案
修改hive-site.xml 配置
<property>
<name>hive.metastore.local</name>
<value>true</value>
</property>
<property>
<name>hive.metastore.uris</name>
<value>thrift://localhost:9083</value>
<description>Thrift URI for the remote metastore. Used by metastore client to connect to remote metastore.
</description>
5、在运行CliDriver ,看到这个界面说明代码跑成功了
![a51745a030e6a9110e452695316b0e5d.png](https://i-blog.csdnimg.cn/blog_migrate/cd66fad9fb6e4d4df64ae00179370a5a.png)