首页 > 大数据 > Hadoop > Hive安装(本地独立模式,MySql为元数据库)
部署环境:
|
系统 |
Red hat linux 6.4 |
|
Hadoop版本 |
1.2.1 |
|
Hive版本 |
0.11.0 |
|
Mysql数据库版本 |
5.6.15 |
目前Hive已经更新到0.13.1版本
安装步骤:
1. 安装mysql
2. 安装hive
3. 测试
1. 由于部署系统使用的是Red hat linux 6.4 ,所以要先删除系统系带的Mysql。
2. 安装Mysql server

3. 安装Mysql client

查看一下:

4. 启动Mysql服务
不启动登陆会报错:

启动服务:

5. 登陆mysql 并修改密码
这个密码是随机生成的,在一个隐藏文件件(各种查资料都说不用初始密码…但我装好后必须要用这个随机密码,找这个密码文件真是泪流满面…最后才发现时隐藏文件)

修改密码并用新密码登陆:
使用mysqladmin -u root -p password root修改root用户密码

6. 创建hive元数据库
create database hive; --元数据要看 hive配置文件配置的数据库名
7. 对Hadoopuser授权
注意,此处的密码必须和hive-site.xml 中javax.jdo.option.ConnectionPassword的密码一致
grant all on hive.* to 'hadoopuser'@'localhost' identified by 'root';
1. 复制一份hive-env.sh.template 模板重命名为hive-env.sh
cp hive-env.sh.template hive-env.sh
2. 更改hive-env.sh 内容
3. 复制一份hive-default.xml.template重命名为hive-site.xml
cp hive-default.xml.template hive-site.xml
4. 更改hive-site.xml 内容

注意:
标红位置是使用的mysql数据库名字,所以一定要赋予mysql用户对hive_metastore的全部权限。
这里是配置用户名和密码,mysql 的

最后这部分可以不添加(我使用的版本不需要),有些本版需要,有些版本不需要…
详细的配置方式可参考:
http://blog.csdn.net/reesun/article/details/8556078
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
./hive -hiveconf hive.root.logger=DEBUG,console 进行debug
问题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' ;
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/28929558/viewspace-1192693/ ,如需转载,请注明出处,否则将追究法律责任。