常见的bug---3、没有启动metaStore和Hiveserver2服务导致在本机上的IDEA无法连接上虚拟机上的HIve

news/2024/11/23 5:41:34/

这里写目录标题

  • 问题描述
  • 原因分析:
  • 解决方案:

问题描述

在IEDA连接虚拟机上的Hive报的
Exception in thread “main” org.apache.spark.sql.AnalysisException: org.apache.hadoop.hive.ql.metadata.HiveException: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient
at org.apache.spark.sql.hive.HiveExternalCatalog.withClient(HiveExternalCatalog.scala:110)
at org.apache.spark.sql.hive.HiveExternalCatalog.databaseExists(HiveExternalCatalog.scala:223)
at org.apache.spark.sql.internal.SharedState.externalCatalog l z y c o m p u t e ( S h a r e d S t a t e . s c a l a : 150 ) a t o r g . a p a c h e . s p a r k . s q l . i n t e r n a l . S h a r e d S t a t e . e x t e r n a l C a t a l o g ( S h a r e d S t a t e . s c a l a : 140 ) a t o r g . a p a c h e . s p a r k . s q l . i n t e r n a l . S h a r e d S t a t e . g l o b a l T e m p V i e w M a n a g e r lzycompute(SharedState.scala:150) at org.apache.spark.sql.internal.SharedState.externalCatalog(SharedState.scala:140) at org.apache.spark.sql.internal.SharedState.globalTempViewManager lzycompute(SharedState.scala:150)atorg.apache.spark.sql.internal.SharedState.externalCatalog(SharedState.scala:140)atorg.apache.spark.sql.internal.SharedState.globalTempViewManagerlzycompute(SharedState.scala:170)
at org.apache.spark.sql.internal.SharedState.globalTempViewManager(SharedState.scala:168)
at org.apache.spark.sql.hive.HiveSessionStateBuilder. a n o n f u n anonfun anonfuncatalog 2 ( H i v e S e s s i o n S t a t e B u i l d e r . s c a l a : 70 ) a t o r g . a p a c h e . s p a r k . s q l . c a t a l y s t . c a t a l o g . S e s s i o n C a t a l o g . g l o b a l T e m p V i e w M a n a g e r 2(HiveSessionStateBuilder.scala:70) at org.apache.spark.sql.catalyst.catalog.SessionCatalog.globalTempViewManager 2(HiveSessionStateBuilder.scala:70)atorg.apache.spark.sql.catalyst.catalog.SessionCatalog.globalTempViewManagerlzycompute(SessionCatalog.scala:122)
at org.apache.spark.sql.catalyst.catalog.SessionCatalog.globalTempViewManager(SessionCatalog.scala:122)
at org.apache.spark.sql.catalyst.catalog.SessionCatalog.listTables(SessionCatalog.scala:1031)
at org.apache.spark.sql.catalyst.catalog.SessionCatalog.listTables(SessionCatalog.scala:1017)
at org.apache.spark.sql.catalyst.catalog.SessionCatalog.listTables(SessionCatalog.scala:1009)
at org.apache.spark.sql.execution.datasources.v2.V2SessionCatalog.listTables(V2SessionCatalog.scala:57)
at org.apache.spark.sql.execution.datasources.v2.ShowTablesExec.run(ShowTablesExec.scala:40)
at org.apache.spark.sql.execution.datasources.v2.V2CommandExec.result l z y c o m p u t e ( V 2 C o m m a n d E x e c . s c a l a : 43 ) a t o r g . a p a c h e . s p a r k . s q l . e x e c u t i o n . d a t a s o u r c e s . v 2. V 2 C o m m a n d E x e c . r e s u l t ( V 2 C o m m a n d E x e c . s c a l a : 43 ) a t o r g . a p a c h e . s p a r k . s q l . e x e c u t i o n . d a t a s o u r c e s . v 2. V 2 C o m m a n d E x e c . e x e c u t e C o l l e c t ( V 2 C o m m a n d E x e c . s c a l a : 49 ) a t o r g . a p a c h e . s p a r k . s q l . e x e c u t i o n . Q u e r y E x e c u t i o n lzycompute(V2CommandExec.scala:43) at org.apache.spark.sql.execution.datasources.v2.V2CommandExec.result(V2CommandExec.scala:43) at org.apache.spark.sql.execution.datasources.v2.V2CommandExec.executeCollect(V2CommandExec.scala:49) at org.apache.spark.sql.execution.QueryExecution lzycompute(V2CommandExec.scala:43)atorg.apache.spark.sql.execution.datasources.v2.V2CommandExec.result(V2CommandExec.scala:43)atorg.apache.spark.sql.execution.datasources.v2.V2CommandExec.executeCollect(V2CommandExec.scala:49)atorg.apache.spark.sql.execution.QueryExecution a n o n f u n anonfun anonfuneagerlyExecuteCommands 1. 1. 1.anonfun$applyOrElse 1 ( Q u e r y E x e c u t i o n . s c a l a : 98 ) a t o r g . a p a c h e . s p a r k . s q l . e x e c u t i o n . S Q L E x e c u t i o n 1(QueryExecution.scala:98) at org.apache.spark.sql.execution.SQLExecution 1(QueryExecution.scala:98)atorg.apache.spark.sql.execution.SQLExecution. a n o n f u n anonfun anonfunwithNewExecutionId 6 ( S Q L E x e c u t i o n . s c a l a : 109 ) a t o r g . a p a c h e . s p a r k . s q l . e x e c u t i o n . S Q L E x e c u t i o n 6(SQLExecution.scala:109) at org.apache.spark.sql.execution.SQLExecution 6(SQLExecution.scala:109)atorg.apache.spark.sql.execution.SQLExecution.withSQLConfPropagated(SQLExecution.scala:169)
at org.apache.spark.sql.execution.SQLExecution . . .anonfun$withNewExecutionId 1 ( S Q L E x e c u t i o n . s c a l a : 95 ) a t o r g . a p a c h e . s p a r k . s q l . S p a r k S e s s i o n . w i t h A c t i v e ( S p a r k S e s s i o n . s c a l a : 779 ) a t o r g . a p a c h e . s p a r k . s q l . e x e c u t i o n . S Q L E x e c u t i o n 1(SQLExecution.scala:95) at org.apache.spark.sql.SparkSession.withActive(SparkSession.scala:779) at org.apache.spark.sql.execution.SQLExecution 1(SQLExecution.scala:95)atorg.apache.spark.sql.SparkSession.withActive(SparkSession.scala:779)atorg.apache.spark.sql.execution.SQLExecution.withNewExecutionId(SQLExecution.scala:64)
at org.apache.spark.sql.execution.QueryExecutionKaTeX parse error: Can't use function '$' in math mode at position 8: anonfun$̲eagerlyExecuteC…anonfun$eagerlyExecuteCommands 1. a p p l y O r E l s e ( Q u e r y E x e c u t i o n . s c a l a : 94 ) a t o r g . a p a c h e . s p a r k . s q l . c a t a l y s t . t r e e s . T r e e N o d e . 1.applyOrElse(QueryExecution.scala:94) at org.apache.spark.sql.catalyst.trees.TreeNode. 1.applyOrElse(QueryExecution.scala:94)atorg.apache.spark.sql.catalyst.trees.TreeNode.anonfun$transformDownWithPruning 1 ( T r e e N o d e . s c a l a : 584 ) a t o r g . a p a c h e . s p a r k . s q l . c a t a l y s t . t r e e s . C u r r e n t O r i g i n 1(TreeNode.scala:584) at org.apache.spark.sql.catalyst.trees.CurrentOrigin 1(TreeNode.scala:584)atorg.apache.spark.sql.catalyst.trees.CurrentOrigin.withOrigin(TreeNode.scala:176)
at org.apache.spark.sql.catalyst.trees.TreeNode.transformDownWithPruning(TreeNode.scala:584)
at org.apache.spark.sql.catalyst.plans.logical.LogicalPlan.org a p a c h e apache apachespark s q l sql sqlcatalyst p l a n s plans planslogical A n a l y s i s H e l p e r AnalysisHelper AnalysisHelper s u p e r super supertransformDownWithPruning(LogicalPlan.scala:30)
at org.apache.spark.sql.catalyst.plans.logical.AnalysisHelper.transformDownWithPruning(AnalysisHelper.scala:267)
at org.apache.spark.sql.catalyst.plans.logical.AnalysisHelper.transformDownWithPruning ( A n a l y s i s H e l p e r . s c a l a : 263 ) a t o r g . a p a c h e . s p a r k . s q l . c a t a l y s t . p l a n s . l o g i c a l . L o g i c a l P l a n . t r a n s f o r m D o w n W i t h P r u n i n g ( L o g i c a l P l a n . s c a l a : 30 ) a t o r g . a p a c h e . s p a r k . s q l . c a t a l y s t . p l a n s . l o g i c a l . L o g i c a l P l a n . t r a n s f o r m D o w n W i t h P r u n i n g ( L o g i c a l P l a n . s c a l a : 30 ) a t o r g . a p a c h e . s p a r k . s q l . c a t a l y s t . t r e e s . T r e e N o d e . t r a n s f o r m D o w n ( T r e e N o d e . s c a l a : 560 ) a t o r g . a p a c h e . s p a r k . s q l . e x e c u t i o n . Q u e r y E x e c u t i o n . e a g e r l y E x e c u t e C o m m a n d s ( Q u e r y E x e c u t i o n . s c a l a : 94 ) a t o r g . a p a c h e . s p a r k . s q l . e x e c u t i o n . Q u e r y E x e c u t i o n . c o m m a n d E x e c u t e d (AnalysisHelper.scala:263) at org.apache.spark.sql.catalyst.plans.logical.LogicalPlan.transformDownWithPruning(LogicalPlan.scala:30) at org.apache.spark.sql.catalyst.plans.logical.LogicalPlan.transformDownWithPruning(LogicalPlan.scala:30) at org.apache.spark.sql.catalyst.trees.TreeNode.transformDown(TreeNode.scala:560) at org.apache.spark.sql.execution.QueryExecution.eagerlyExecuteCommands(QueryExecution.scala:94) at org.apache.spark.sql.execution.QueryExecution.commandExecuted (AnalysisHelper.scala:263)atorg.apache.spark.sql.catalyst.plans.logical.LogicalPlan.transformDownWithPruning(LogicalPlan.scala:30)atorg.apache.spark.sql.catalyst.plans.logical.LogicalPlan.transformDownWithPruning(LogicalPlan.scala:30)atorg.apache.spark.sql.catalyst.trees.TreeNode.transformDown(TreeNode.scala:560)atorg.apache.spark.sql.execution.QueryExecution.eagerlyExecuteCommands(QueryExecution.scala:94)atorg.apache.spark.sql.execution.QueryExecution.commandExecutedlzycompute(QueryExecution.scala:81)
at org.apache.spark.sql.execution.QueryExecution.commandExecuted(QueryExecution.scala:79)
at org.apache.spark.sql.Dataset.(Dataset.scala:220)
at org.apache.spark.sql.Dataset . . .anonfun$ofRows 2 ( D a t a s e t . s c a l a : 100 ) a t o r g . a p a c h e . s p a r k . s q l . S p a r k S e s s i o n . w i t h A c t i v e ( S p a r k S e s s i o n . s c a l a : 779 ) a t o r g . a p a c h e . s p a r k . s q l . D a t a s e t 2(Dataset.scala:100) at org.apache.spark.sql.SparkSession.withActive(SparkSession.scala:779) at org.apache.spark.sql.Dataset 2(Dataset.scala:100)atorg.apache.spark.sql.SparkSession.withActive(SparkSession.scala:779)atorg.apache.spark.sql.Dataset.ofRows(Dataset.scala:97)
at org.apache.spark.sql.SparkSession. a n o n f u n anonfun anonfunsql$1(SparkSession.scala:622)
at org.apache.spark.sql.SparkSession.withActive(SparkSession.scala:779)
at org.apache.spark.sql.SparkSession.sql(SparkSession.scala:617)
at inputandoutput.Test05_Hive.main(Test05_Hive.java:27)

原因分析:

看报的异常是org.apache.hadoop.hive.ql.metadata.HiveException,说明是我Hive的metastore服务的问题,应该是启动,然后我又因为是在本机连接虚拟机中的Hive,所以应该还要开启Hiveserver2这个服务

解决方案:

开启metastore服务和Hiveserver2服务即可
开启脚本:

vim hiveservices.sh 

插入如下内容:

#!/bin/bashHIVE_LOG_DIR=$HIVE_HOME/logs
if [ ! -d $HIVE_LOG_DIR ]
thenmkdir -p $HIVE_LOG_DIR
fi#检查进程是否运行正常,参数1为进程名,参数2为进程端口
function check_process()
{pid=$(ps -ef 2>/dev/null | grep -v grep | grep -i $1 | awk '{print $2}')ppid=$(netstat -nltp 2>/dev/null | grep $2 | awk '{print $7}' | cut -d '/' -f 1)echo $pid[[ "$pid" =~ "$ppid" ]] && [ "$ppid" ] && return 0 || return 1
}function hive_start()
{metapid=$(check_process HiveMetastore 9083)cmd="nohup hive --service metastore >$HIVE_LOG_DIR/metastore.log 2>&1 &"[ -z "$metapid" ] && eval $cmd || echo "Metastroe服务已启动"server2pid=$(check_process HiveServer2 10000)cmd="nohup hive --service hiveserver2 >$HIVE_LOG_DIR/hiveServer2.log 2>&1 &"[ -z "$server2pid" ] && eval $cmd || echo "HiveServer2服务已启动"
}function hive_stop()
{
metapid=$(check_process HiveMetastore 9083)[ "$metapid" ] && kill $metapid || echo "Metastore服务未启动"server2pid=$(check_process HiveServer2 10000)[ "$server2pid" ] && kill $server2pid || echo "HiveServer2服务未启动"
}case $1 in
"start")hive_start;;
"stop")hive_stop;;
"restart")hive_stopsleep 2hive_start;;
"status")check_process HiveMetastore 9083 >/dev/null && echo "Metastore服务运行正常" || echo "Metastore服务运行异常"check_process HiveServer2 10000 >/dev/null && echo "HiveServer2服务运行正常" || echo "HiveServer2服务运行异常";;
*)echo Invalid Args!echo 'Usage: '$(basename $0)' start|stop|restart|status';;
esac

http://www.ppmy.cn/news/848100.html

相关文章

其实你也可以制作一款专属的书架app,信不信看看就知道

什么“一键书架”? “一键书架”相当于一个迷你图书馆,可以管理9本图书,在线制作,离线阅读。 “一键书架”特色 1、它彻底打破了以往的技术门槛,用户不需要有任何编程基础和UI设计知识,只要有一个创意&…

大学我都是自学走来的,这些私藏的实用工具/学习网站我贡献出来了,建议收藏精品推荐

作者 | Jeskson 来源 | 达达前端小酒馆 1 https://www.h5jun.com/archives/ 十年踪迹的博客 2 https://www.zhangxinxu.com/ 3 http://www.ruanyifeng.com/home.html 4 https://www.cnblogs.com/yexiaochai/ 5 https://www.cnblogs.com/rubylouvre/ 6 https://www.cnblogs.…

我自己制作的导航页网站,源码分享~

演示地址:http://hang.fang1688.cn/ pc端如下图: 移动端如下图: 把自己的源码上传到云服务器或虚拟主机,也可以制作成本地地址index.html那个文件。导航源码可以在本地环境打开。源码目录如下: 可以把它添加到浏览器的…

130 个相见恨晚的超实用网站(学习、资源、工具、设计),一次性分享出来

130 余个相见恨晚的超实用网站 文末没有公众号,只求 点赞 关注 目录 130 余个相见恨晚的超实用网站 搞学习 冷知识 / 黑科技 资源搜索 小工具 导航页(工具集) 看视频 学设计 搞文档 找图片 搞学习 知乎:www.zhihu.com …

杂志停刊通知计算机光盘,计算机期刊《计算机光盘软件与应用》

该楼层疑似违规已被系统折叠 隐藏此楼查看此楼 《计算机光盘软件与应用》杂志是由中国科学院主管、大恒电子音像出版社主办的国内外公开发行的综合性国家级学术期刊。本刊致力于创办以创新、准确、实用为特色,突出综述性、科学性、实用性,及时报道国内外…

APP软件应用下载导航网站源码+搭建教程

APP软件应用下载导航网站源码/APP分享下载页引流导航网站源码带后台版。 功能简介: 1、源码包中带有安装教程 2、网站自适应PC手机自适应 3、用户可以自行封装成app应用引流导航 4、可以在网站中插入自己的广告内容 5、此网站带有后台,方便用户随时…

校园资料分享平台的设计与开发、资料分享

目录 1、使用框架和技术 2、功能展示与说明 3、系统展示 3.1 使用到技术 3.2 前台展示 3.3 后台界面 4. 论文资料和程序 在教育领域,使用IT技术可以使任何人、任何地方和任意的时间,都可以获得需要的资料。但现在的校园大多是综合性的网站&#x…

自学OpenGL网站与书籍推荐

网站: http://www.opengl-tutorial.org/ 难度适中,英文也比较简单 http://ogldev.atspace.co.uk/index.html 知乎推荐,后面有一些skybox,shadow volume 等实现技巧的教程 http://www.scratchapixel.com/ 知乎推荐,倾向于计算…