1.拷贝hive的hive-site.xml文件到spark的conf目录下
2.修改spark中hive-site.xml文件
添加以下:
<configuration>
<property>
<name>hive.metastore.uris</name>
<value>thrift://主机名或IP地址:9083</value>
</property>
</configuration>
3.另建窗口启动:
[root@head42 conf]# hive --service metastore
4.启动spark:
[root@head42 conf]# spark-shell
5.测试:
spark.sql("select * from database_name.table_name").show//访问其他数据库的表格
scala> spark.sql("show tables").show
//如果找不到mysql-jar
//在spark安装目录下/conf/spark-env.sh下添加
export HIVE_CONF_DIR=/home/softwares/apache-hive-2.3.4-bin/conf
export SPARK_CLASSPATH=$SPARK_CLASSPATH:/home/softwares/apache-hive-2.3.4-bin/lib/mysql-connector-java-5.1.38.jar
本文详细介绍了如何在Spark中配置并使用Hive元数据,包括拷贝hive-site.xml文件、修改配置、启动metastore服务及spark-shell,以及解决mysql-jar依赖问题的方法。
956

被折叠的 条评论
为什么被折叠?



