为什么hive需要mysql作为数据库_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. ? ? ? 測試
一.安裝Mysql
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';
二.安裝Hive
2.1解壓安裝Hive
2.2修改配置文件
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內容
注意:
javax.jdo.option.ConnectionURL
jdbc:mysql://localhost/hive_metastore?createDatabaseIfNotExist=true
JDBC connect string for a JDBC
metastore
標紅位置是使用的mysql數據庫名字,所以一定要賦予mysql用戶對hive_metastore的全部權限。
這里是配置用戶名和密碼,mysql的
最后這部分可以不添加(我使用的版本不需要),有些本版需要,有些版本不需要…
詳細的配置方式可參考:
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' ;
與50位技術專家面對面20年技術見證,附贈技術全景圖總結
以上是生活随笔為你收集整理的为什么hive需要mysql作为数据库_Hive安装(本地独立模式,MySql为元数据库)的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 中国中钢是国企吗
- 下一篇: centos mysql下载64位_Ce