hadoop 配置单元无法连接到MySQL

q3aa0525  于 2022-11-01  发布在  Hadoop
关注(0)|答案(1)|浏览(266)

我尝试在我的虚拟机上安装Hive,Hadoop和MySQL已经成功安装。我按照说明将mysql-connector-java.jar添加到/usr/local/hive/lib中,但是,它不起作用。它总是说加载驱动程序失败。hive数据库已经在MySQL中成功创建。
我使用的是openjdk(版本1.8.0_3.1.2)、hive(版本3.1.2)和Hadoop(版本3.3.1)。
请给我一些帮助,谢谢。
schematool -dbType mysql -initSchema --verbose

  1. SLF4J: Class path contains multiple SLF4J bindings.
  2. SLF4J: Found binding in [jar:file:/usr/local/hive/lib/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
  3. SLF4J: Found binding in [jar:file:/usr/local/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.30.jar!/org/slf4j/impl/StaticLoggerBinder.class]
  4. SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
  5. SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
  6. Metastore connection URL: jdbc:mysql://localhost:3306/hive
  7. Metastore Connection Driver : com.mysql.jdbc.Driver
  8. Metastore connection User: root
  9. org.apache.hadoop.hive.metastore.HiveMetaException: Failed to load driver
  10. Underlying cause: java.lang.ClassNotFoundException : com.mysql.jdbc.Driver
  11. org.apache.hadoop.hive.metastore.HiveMetaException: Failed to load driver
  12. at org.apache.hadoop.hive.metastore.tools.HiveSchemaHelper.getConnectionToMetastore(HiveSchemaHelper.java:97)
  13. at org.apache.hive.beeline.HiveSchemaTool.getConnectionToMetastore(HiveSchemaTool.java:169)
  14. at org.apache.hive.beeline.HiveSchemaTool.testConnectionToMetastore(HiveSchemaTool.java:475)
  15. at org.apache.hive.beeline.HiveSchemaTool.doInit(HiveSchemaTool.java:581)
  16. at org.apache.hive.beeline.HiveSchemaTool.doInit(HiveSchemaTool.java:567)
  17. at org.apache.hive.beeline.HiveSchemaTool.main(HiveSchemaTool.java:1517)
  18. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  19. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  20. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  21. at java.lang.reflect.Method.invoke(Method.java:498)
  22. at org.apache.hadoop.util.RunJar.run(RunJar.java:323)
  23. at org.apache.hadoop.util.RunJar.main(RunJar.java:236)
  24. Caused by: java.lang.ClassNotFoundException: com.mysql.jdbc.Driver
  25. at java.net.URLClassLoader.findClass(URLClassLoader.java:387)
  26. at java.lang.ClassLoader.loadClass(ClassLoader.java:418)
  27. at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:352)
  28. at java.lang.ClassLoader.loadClass(ClassLoader.java:351)
  29. at java.lang.Class.forName0(Native Method)
  30. at java.lang.Class.forName(Class.java:264)
  31. at org.apache.hadoop.hive.metastore.tools.HiveSchemaHelper.getConnectionToMetastore(HiveSchemaHelper.java:85)
  32. ... 11 more
  33. ***schemaTool failed***

hive

  1. SLF4J: Class path contains multiple SLF4J bindings.
  2. SLF4J: Found binding in [jar:file:/usr/local/hbase/lib/slf4j-log4j12-1.7.25.jar!/org/slf4j/impl/StaticLoggerBinder.class]
  3. SLF4J: Found binding in [jar:file:/usr/local/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.30.jar!/org/slf4j/impl/StaticLoggerBinder.class]
  4. SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
  5. SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
  6. SLF4J: Class path contains multiple SLF4J bindings.
  7. SLF4J: Found binding in [jar:file:/usr/local/hive/lib/log4j-slf4j-impl-2.10.0.jar!/org/slf4j/impl/StaticLoggerBinder.class]
  8. SLF4J: Found binding in [jar:file:/usr/local/hadoop/share/hadoop/common/lib/slf4j-log4j12-1.7.30.jar!/org/slf4j/impl/StaticLoggerBinder.class]
  9. SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
  10. SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
  11. Hive Session ID = 4a4a5ab1-5ac3-4228-85cc-7ac2f91dda8d
  12. Logging initialized using configuration in jar:file:/usr/local/hive/lib/hive-common-3.1.2.jar!/hive-log4j2.properties Async: true
  13. Exception in thread "main" java.lang.NoSuchMethodError: org.apache.hadoop.conf.Configuration.getTimeDuration(Ljava/lang/String;JLjava/util/concurrent/TimeUnit;Ljava/util/concurrent/TimeUnit;)J
  14. at org.apache.hadoop.hdfs.client.impl.DfsClientConf.<init>(DfsClientConf.java:249)
  15. at org.apache.hadoop.hdfs.DFSClient.<init>(DFSClient.java:324)
  16. at org.apache.hadoop.hdfs.DFSClient.<init>(DFSClient.java:308)
  17. at org.apache.hadoop.hdfs.DistributedFileSystem.initDFSClient(DistributedFileSystem.java:201)
  18. at org.apache.hadoop.hdfs.DistributedFileSystem.initialize(DistributedFileSystem.java:186)
  19. at org.apache.hadoop.fs.FileSystem.createFileSystem(FileSystem.java:3354)
  20. at org.apache.hadoop.fs.FileSystem.access$200(FileSystem.java:124)
  21. at org.apache.hadoop.fs.FileSystem$Cache.getInternal(FileSystem.java:3403)
  22. at org.apache.hadoop.fs.FileSystem$Cache.get(FileSystem.java:3371)
  23. at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:477)
  24. at org.apache.hadoop.fs.FileSystem.get(FileSystem.java:226)
  25. at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:624)
  26. at org.apache.hadoop.hive.ql.session.SessionState.beginStart(SessionState.java:591)
  27. at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:747)
  28. at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:683)
  29. at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  30. at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  31. at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  32. at java.lang.reflect.Method.invoke(Method.java:498)
  33. at org.apache.hadoop.util.RunJar.run(RunJar.java:323)
  34. at org.apache.hadoop.util.RunJar.main(RunJar.java:236)
jw5wzhpr

jw5wzhpr1#

原来是mysql连接器的版本不兼容,重新安装正确版本后问题解决。

相关问题