Schema initialization FAILED! Metastore state would be inconsistent !!

[root@node3 hive-2.3.4]# schematool -dbType mysql -initSchema
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/opt/hive-2.3.4/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/opt/hadoop-2.6.5/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Metastore connection URL:	 jdbc:mysql://node1:3306/hive?createDatabaseIfNotExist=true
Metastore Connection Driver :	 com.mysql.jdbc.Driver
Metastore connection User:	 root
Starting metastore schema initialization to 2.3.0
Initialization script hive-schema-2.3.0.mysql.sql
Error: Duplicate key name 'PCS_STATS_IDX' (state=42000,code=1061)
org.apache.hadoop.hive.metastore.HiveMetaException: Schema initialization FAILED! Metastore state would be inconsistent !!
Underlying cause: java.io.IOException : Schema script failed, errorcode 2
Use --verbose for detailed stacktrace.
*** schemaTool failed ***

在hive重新进行初始化时,出现以上错误。

Schema initialization FAILED! Metastore state would be inconsistent !!
架构初始化失败! Metastore状态会不一致!!

在出现以上错误时,解决方法如下

  1. 删除metastore_db文件

  2. 删除数据库中对应的database

    
            javax.jdo.option.ConnectionURL
            jdbc:mysql://node1:3306/hive_new?createDatabaseIfNotExist=true
    
    

在配置文件中如果配置的数据库名字是:hive_new,则将该数据库删除即可。

进行以上操作后,进行重新初始化

 schematool -dbType mysql -initSchema

你可能感兴趣的:(大数据,hive)