1、在Linux的Spark中集成Hive
1.1 为什么要集成Hive?
-
因为在Linux中的Spark安装包,默认是不能直接读取hive的表的,需要集成hive才能读取hive的库和表。
1.2 怎么做?
-
1、先配置hive环境变量,打开 vim /etc/profile,然后添加两行代码:
export HIVE_HOME=/export/server/hive export PATH=$HIVE_HOME/bin:$PATH
- 2、然后启动hive的metastore
nohup hive --service metastore 2>&1 > /tmp/hive-metastore.log &
- 3、将metastore的进程端口号告诉给Spark,在spark/conf/的hive-site.xml文件中(可以从hive/conf/hive-site.xml文件拷贝过来即可),里面需包括以下的内容:
<!-- 默认数仓的路径 --> <!-- spark保存数据的路径的配置名叫spark.sql.warehouse.dir 如果SparkSQL找到了hive.metastore.warehouse.dir,那么 就用hive.metastore.warehouse.dir的值作为 spark.sql.warehouse.dir 如果找不到hive.metastore.wareho