hive(元数据存储在mysql) 启动
Exception in thread "main" java.lang.RuntimeException: Hive metastore database is not initialized. Please use schematool (e.g. ./schematool -initSchema -dbType ...) to create the schema. If needed, don't forget to include the option to auto-create the underlying database in your JDBC connection string (e.g. ?createDatabaseIfNotExist
=true for mysql)
看解释是hive元数据库没有初始化的原因,
第一次需要执行初始化命令:
schematool -dbType mysql -initSchema
查看初始化后信息 schematool -dbType mysql -info
这时候你再查看mysql中 hive 数据库的表,会有一大堆表生成,如图
执行完成之后,可以重启一下mysql服务,service mysqld restart
之后又报错,
Exception in thread "main" java.lang.IllegalArgumentException
: java.net.URISyntaxException: Relative path in absolute URI: ${system:java.io.tmpdir}/${system:user.name}
at org.apache.hadoop.fs.Path.initialize(Path.java:206)
at org.apache.hadoop.fs.Path.(Path.java:172)
at org.apache.hadoop.hive.ql.session.SessionState.createSessionDirs(SessionState.java:606)
at org.apache.hadoop.hive.ql.session.SessionState.start(SessionState.java:526)
at org.apache.hadoop.hive.ql.session.SessionState.beginStart(SessionState.java:494)
at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:709)
at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:645)
at sun.reflect.NativeMethodAccessorImpl
.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl
.invoke(NativeMethodAccessorImpl
.java:57)
at sun.reflect.DelegatingMethodAccessor
Impl.invoke(DelegatingMethodAccessor
Impl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.hadoop.util.RunJar.run(RunJar.java:221)
at org.apache.hadoop.util.RunJar.main(RunJar.java:136)
Caused by: java.net.URISyntaxException: Relative path in absolute URI: ${system:java.io.tmpdir}
这个错误的原因是
${system:java.io.tmpdir} 设置的路径不存在还是怎么回事,那么在hive-site.xml中去查找
${system:java.io.tmpdir} ,将该路径替换成你本地的缓存目录,这个目录你可以自己建,可以在hive目录下建立一个tmp目录,替换成这个路径。
执行bin/hive
成功。
metastore一共有三种模式,
http://www.micmiu.com/bigdata/hive/hive-metastore-config/