初始化HIVE時,執行bin/schematool -dbType mysql -initSchema
報錯
異常一:
Metastore connection URL: jdbc:mysql://192.168.56.112/hive-demo?createDatabaseIfNotExist=true&useSSL=false
Metastore Connection Driver : com.mysql.jdbc.Driver
Metastore connection User: root
org.apache.hadoop.hive.metastore.HiveMetaException: Failed to load driver
Underlying cause: java.lang.ClassNotFoundException : com.mysql.jdbc.Driver
Use --verbose for detailed stacktrace.
這個是說沒有找到jdbc的驅動包。
解決辦法:
驅動拷貝:將mysql-connector-java-5.1.47-bin.jar放到hive/lib/下解決問題。
異常二:
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Metastore connection URL: jdbc:derby:;databaseName=metastore_db;create=true
Metastore Connection Driver: org.apache.derby.jdbc.EmbeddedDriver
Metastore Connection User: APP
這個是說hive在初始化的時候連接的數據庫URL是derby而不是自己的數據庫,這是由於hive/conf/hive-site.xml,沒有寫,或者名字有誤,在初始化的過程中還是默認使用的hive-default.xml.template 。記得一定要細心(上次看別人寫成了hive-site.sh就一直報這個錯)。
異常三:
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Metastore connection URL: jdbc:mysql://192.168.56.112/hive-demo?createDatabaseIfNotExist=true&useSSL=false
Metastore Connection Driver : com.mysql.jdbc.Driver
Metastore connection User: root
org.apache.hadoop.hive.metastore.HiveMetaException: Failed to get schema version.
Underlying cause: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘-demo’ at line 1
這個問題是說配置文件中的URL路徑有錯,是因爲hive-demo,一個 - 的問題,hive幫你創建元數據庫hive-demo數據庫的時候識別不出 -。
解決方案:自己創建一個hive-demo數據庫或者把數據庫名改掉就行,比如改成hive。