为什么hive需要mysql作为数据库_Hive安装(本地独立模式,MySql为元数据库)
部署環(huán)境:
系統(tǒng)
Red
hat linux 6.4
Hadoop版本
1.2.1
Hive版本
0.11.0
Mysql數(shù)據(jù)庫版本
5.6.15
目前Hive已經(jīng)更新到0.13.1版本
安裝步驟:
1.安裝mysql
2.安裝hive
3. ? ? ? 測試
一.安裝Mysql
1.由于部署系統(tǒng)使用的是Red hat linux 6.4,所以要先刪除系統(tǒng)系帶的Mysql。
2.安裝Mysql? server
3.安裝Mysql client
查看一下:
4.啟動(dòng)Mysql服務(wù)
不啟動(dòng)登陸會(huì)報(bào)錯(cuò):
啟動(dòng)服務(wù):
5.登陸mysql并修改密碼
這個(gè)密碼是隨機(jī)生成的,在一個(gè)隱藏文件件(各種查資料都說不用初始密碼…但我裝好后必須要用這個(gè)隨機(jī)密碼,找這個(gè)密碼文件真是淚流滿面…最后才發(fā)現(xiàn)時(shí)隱藏文件)
修改密碼并用新密碼登陸:
使用mysqladmin -u root -p password root修改root用戶密碼
6.創(chuàng)建hive元數(shù)據(jù)庫
create database hive; ?--元數(shù)據(jù)要看 hive配置文件配置的數(shù)據(jù)庫名
7.對(duì)Hadoopuser授權(quán)
注意,此處的密碼必須和hive-site.xml
中javax.jdo.option.ConnectionPassword的密碼一致
grant all on hive.*
to 'hadoopuser'@'localhost' identified by 'root';
二.安裝Hive
2.1解壓安裝Hive
2.2修改配置文件
1.復(fù)制一份hive-env.sh.template模板重命名為hive-env.sh
cp hive-env.sh.template hive-env.sh
2.更改hive-env.sh內(nèi)容
3.復(fù)制一份hive-default.xml.template重命名為hive-site.xml
cp
hive-default.xml.template hive-site.xml
4.更改hive-site.xml內(nèi)容
注意:
javax.jdo.option.ConnectionURL
jdbc:mysql://localhost/hive_metastore?createDatabaseIfNotExist=true
JDBC connect string for a JDBC
metastore
標(biāo)紅位置是使用的mysql數(shù)據(jù)庫名字,所以一定要賦予mysql用戶對(duì)hive_metastore的全部權(quán)限。
這里是配置用戶名和密碼,mysql的
最后這部分可以不添加(我使用的版本不需要),有些本版需要,有些版本不需要…
詳細(xì)的配置方式可參考:
5.添加lib目錄下缺少的mysql-connector-java-5.1.29.tar包。
到官網(wǎng)下載即可
6.配置環(huán)境變量
7.切換進(jìn)hvie目錄,啟動(dòng)thrift服務(wù)
./bin/hive --service hiveserver注意:兩個(gè)杠
切換進(jìn)hvie目錄,進(jìn)入hive
./bin/hive
驗(yàn)證啟動(dòng)成功,效果應(yīng)如下圖:
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
用下面的命令,重新啟動(dòng)hive
./hive -hiveconf
hive.root.logger=DEBUG,console進(jìn)行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.
解決方法:
這說明沒有添或者添加錯(cuò)了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'
解決方法:
這是因?yàn)閙ysql數(shù)據(jù)庫用戶hadoopuser的權(quán)限不足,賦予權(quán)限
grant all on hive_metastore.* to
'hadoopuser'@'localhost' ;
與50位技術(shù)專家面對(duì)面20年技術(shù)見證,附贈(zèng)技術(shù)全景圖總結(jié)
以上是生活随笔為你收集整理的为什么hive需要mysql作为数据库_Hive安装(本地独立模式,MySql为元数据库)的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 中国中钢是国企吗
- 下一篇: linux cmake编译源码,linu