http://blog.csdn.net/u014695188/article/details/54646575
在运行
- #数据库的初始化。
- bin/schematool -initSchema -dbType mysql
报错
./schematool -initSchema -dbType mysql
which: no hbase in (/home/hadoop/hive/bin:/home/hadoop/hive/conf:/home/hadoop/hadoop-2.7.1/sbin:/home/hadoop/hadoop-2.7.1/bin:/home/hadoop/jdk1.7.0_79/bin:/home/hadoop/hadoop-2.7.1/sbin:/home/hadoop/hadoop-2.7.1/bin:/home/hadoop/jdk1.7.0_79/bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/hadoop/apache-maven-3.2.1/bin:/home/hadoop/apache-ant-1.9.4/bin:/home/hadoop/findbugs-3.0.1/bin:/home/hadoop/hive/bin:/home/hadoop/bin:/home/hadoop/apache-maven-3.2.1/bin:/home/hadoop/apache-ant-1.9.4/bin:/home/hadoop/findbugs-3.0.1/bin)
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/hadoop/apache-hive-2.1.1-bin/lib/log4j-slf4j-impl-2.4.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/hadoop/hadoop-2.7.1/share/hadoop/common/lib/slf4j-log4j12-1.7.10.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://192.168.137.17:3306/hive?createDatabaseIfNotExist=true
Metastore Connection Driver : com.mysql.jdbc.Driver
Metastore connection User: root
org.apache.hadoop.hive.metastore.HiveMetaException: Failed to get schema version.
Underlying cause: java.sql.SQLException : Access denied for user 'root'@'localhost' (using password: YES)
SQL Error code: 1045
Use --verbose for detailed stacktrace.
*** schemaTool failed ***
在执行 mysql -hlocalhost -uroot -p
报错ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
判断是由于mysql远程登录的问题造成的
参照http://jingyan.baidu.com/article/636f38bb21d883d6b946106f.html
问题解决
在执行初始化命令时,如果遇到下开错误
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.
可以先停止mysql服务,再执行初始化命令