Hive安装(本地独立模式,MySQL为元数据库)

3. 复制一份hive-default.xml.template重命名为hive-site.xml

cp hive-default.xml.template hive-site.xml

4. 更改hive-site.xml 内容

注意:

javax.jdo.option.ConnectionURL

jdbc:mysql://localhost/hive_metastore?createDatabaseIfNotExist=true

JDBC connect string for a JDBC metastore

标红位置是使用的mysql数据库名字,所以一定要赋予mysql用户对hive_metastore的全部权限。

这里是配置用户名和密码,mysql 的

最后这部分可以不添加(我使用的版本不需要),有些本版需要,有些版本不需要…

详细的配置方式可参考:

[url=http://blog.csdn.net/reesun/article/details/8556078]http://blog.csdn.net/reesun/article/details/8556078[/url]

5. 添加lib目录下缺少的mysql-connector-java-5.1.29.tar 包。

到官网下载即可

6. 配置环境变量

7. 切换进hvie目录,启动thrift服务

./bin/hive --service hiveserver 注意:两个杠

切换进hvie目录,进入hive

./bin/hive

验证启动成功,效果应如下图:

Show tables;

Create table;

hive> create table t_demo(d_id string,d_str string)

> row format delimited

> fields terminated by '|'

> stored as textfile

> ;

查看Hadoop hdfs 是否生成了文件

三.过程中可能遇到的问题

hive> show tables;

FAILED: Error in metadata: java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.metastore.HiveMetaStoreClient

FAILED: Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask

用下面的命令,重新启动hive

[b]./hive -hiveconf hive.root.logger=DEBUG,console [/b][b]进行[/b][b]debug[/b]

问题1.

Caused by: org.datanucleus.store.rdbms.datasource.DatastoreDriverNotFoundException: The specified datastore driver ("com.mysql.jdbc.Driver") was not found in the CLASSPATH. Please check your CLASSPATH specification, and the name of the driver.

解决方法:

这说明没有添或者添加错了mysql-connector-java-5.1.29.jar 包添加jar包即可

问题2.

Caused by: com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException: Access denied for user 'hadoopuser'@'localhost' to database 'hive_metastore'

解决方法:

这是因为mysql数据库用户hadoopuser 的权限不足,赋予权限

grant all on hive_metastore.* to 'hadoopuser'@'localhost' ;

Hive 的详细介绍请点这里
Hive 的下载地址请点这里

猜你喜欢

转载自blog.csdn.net/wscrf/article/details/80233178