Hive Kafka连接:

vddsk6oq  于 2023-06-21  发布在  Apache
关注(0)|答案(1)|浏览(110)

当我连接到hive并尝试阅读一个主题Kafka时,我总是得到这个消息,

hive> CREATE EXTERNAL TABLE kafka_table
    >   (`timestamp` timestamp , `page` string,  `newPage` boolean,
    >   added int, deleted bigint, delta double)
    >   STORED BY 'org.apache.hadoop.hive.kafka.KafkaStorageHandler'
    >   TBLPROPERTIES
    >   ("kafka.topic" = "test-topic", "kafka.bootstrap.servers"="node2:9092");

''''
''''
       WARN: Please see http://www.slf4j.org/codes.html#release for an explanation. Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/hadoop/hive/metastore/DefaultHiveMetaHook         at java.lang.ClassLoader.defineClass1(Native Method)         at java.lang.ClassLoader.defineClass(ClassLoader.java:763)          at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142)         at java.net.URLClassLoader.defineClass(URLClassLoader.java:467)         at java.net.URLClassLoader.access$100(URLClassLoader.java:73)         at java.net.URLClassLoader$1.run(URLClassLoader.java:368)         at java.net.URLClassLoader$1.run(URLClassLoader.java:362)         at java.security.AccessController.doPrivileged(Native Method)         at java.net.URLClassLoader.findClass(URLClassLoader.java:361)         at java.lang.ClassLoader.loadClass(ClassLoader.java:424)         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)         at java.lang.ClassLoader.loadClass(ClassLoader.java:411)         at java.lang.ClassLoader.loadClass(ClassLoader.java:357)         at java.lang.Class.forName0(Native Method)         at java.lang.Class.forName(Class.java:348)         at org.apache.hadoop.hive.ql.parse.ParseUtils.ensureClassExists(ParseUtils.java:225)         at org.apache.hadoop.hive.ql.parse.StorageFormat.fillStorageFormat(StorageFormat.java:64)         at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.analyzeCreateTable(SemanticAnalyzer.java:10905)         at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.genResolvedParseTree(SemanticAnalyzer.java:10143)         at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.analyzeInternal(SemanticAnalyzer.java:10224)         at org.apache.hadoop.hive.ql.parse.SemanticAnalyzer.analyzeInternal(SemanticAnalyzer.java:10109)         at org.apache.hadoop.hive.ql.parse.BaseSemanticAnalyzer.analyze(BaseSemanticAnalyzer.java:223)         at org.apache.hadoop.hive.ql.Driver.compile(Driver.java:560)         at org.apache.hadoop.hive.ql.Driver.compileInternal(Driver.java:1358)         at org.apache.hadoop.hive.ql.Driver.runInternal(Driver.java:1475)         at org.apache.hadoop.hive.ql.Driver.run(Driver.java:1287)         at org.apache.hadoop.hive.ql.Driver.run(Driver.java:1277)         at org.apache.hadoop.hive.cli.CliDriver.processLocalCmd(CliDriver.java:226)         at org.apache.hadoop.hive.cli.CliDriver.processCmd(CliDriver.java:175)         at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:389)         at org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:781)         at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:699)         at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:634)         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)         at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)         at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)         at java.lang.reflect.Method.invoke(Method.java:498)         at org.apache.hadoop.util.RunJar.run(RunJar.java:226)         at org.apache.hadoop.util.RunJar.main(RunJar.java:141) Caused by: java.lang.ClassNotFoundException: org.apache.hadoop.hive.metastore.DefaultHiveMetaHook         at java.net.URLClassLoader.findClass(URLClassLoader.java:381)         at java.lang.ClassLoader.loadClass(ClassLoader.java:424)         at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:335)         at java.lang.ClassLoader.loadClass(ClassLoader.java:357)         ... 39 more
olmpazwi

olmpazwi1#

错误是说你的类路径中缺少这个包,这个包只在Hive4的alpha版本(不是真正的版本)中可用
https://mvnrepository.com/artifact/org.apache.hive/hive-standalone-metastore-common
我不建议使用Hive来实现这一点,而不是ksqlDB、FlinkSQL、SparkSQL、Presto或Apache Drill(按个人偏好的顺序)。

相关问题