Hive安裝(本地獨立模式,MySql為後設資料庫)

呆呆笨笨的魚發表於2014-06-24

部署環境:

系統

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

 

 


最後這部分可以不新增(我使用的版本不需要),有些本版需要,有些版本不需要

 

 詳細的配置方式可參考:

  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部落格 ” ,連結:http://blog.itpub.net/29439655/viewspace-1378886/,如需轉載,請註明出處,否則將追究法律責任。

相關文章