hive初始化mysql数据库失败的原因

时间:2024-03-17 08:24:23

在配置好hive-site.xml后执行初始化数据:schematool -initSchema -dbType mysql

然而搞程序的都知道不会那么顺利的:报错信息如下
which: no hbase in (/home/jdk/jdk1.8.0_192/bin:/home/hadoop-2.7.7/bin:/home/hadoop-2.7.7/sbin:/home/jdk/jdk1.8.0_192/bin:/home/hadoo
p-2.7.7/bin:/home/hadoop-2.7.7/sbin:/home/jdk/jdk1.8.0_192/bin:/home/hadoop-2.7.7/bin:/home/hadoop-2.7.7/sbin:/usr/local/sbin:/usr/l
ocal/bin:/usr/sbin:/usr/bin:/home/hive/hive-2.3.3/bin:/root/bin:/home/hive/hive-2.3.3/bin:/home/hive/hive-2.1.0/bin)
Metastore connection URL: jdbc:derby:;databaseName=metastore_db;create=true
Metastore Connection Driver : org.apache.derby.jdbc.EmbeddedDriver
Metastore connection User: APP
Starting metastore schema initialization to 2.1.0
Initialization script hive-schema-2.1.0.mysql.sql
Error: Syntax error: Encountered “” at line 1, column 64. (state=42X01,code=30000)
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 ***

可以看到报错的log中hive还是去读取默认的数据库而不是mysql
出现这个错误是因为本人也是查看的袁类所写的文章
执行命令:cp hive-default.xml.template ./hive-site.xml 复制文件并在hive-site.xml文件里配置关于mysql的一些连接信息的配置
问题就是处在hive-site
hive初始化mysql数据库失败的原因
刚刚接触到hive 对hive也不是特别了解 也是参考网上的配置文章 进行配置 然后就是一直入坑!!!
hive-default.xml.template 的开头就写明了 WARNING!!!对该文件的任何更改都将被Hive忽略
其实hive-site.xml是用户定义的配置文件 hive在启动的时候会读取两个文件一个是hive-default.xml.template 还有一个就是hive-site.xml 当执行cp复制命令时 hive-site.xml 里就有了hive-default.xml.template的内容 当你继续写入关于mysql的配置保存后进行初始化hive mysql时就会报这个错误,然后hive的Metastore 服务起不来。
解决办法
在复制的hive-site.xml里保存你写的配置项,然后将其他的删掉
hive-site.xml只能写你自己的配置项,其他删掉
执行之前的初始化命令
hive初始化mysql数据库失败的原因
从log中已经可以看到初始化已经读取的mysql的配置连接URL和连接驱动,出现这个 那可以初始化成功了
hive初始化mysql数据库失败的原因
当然我也不能保证会不会出现其他的错误 坑是一直在的, bug是不会消失的
关于hive的其他报错 请参考其他的技术大牛文章