hive體系架構(gòu)安裝與hiveql_第1頁
hive體系架構(gòu)安裝與hiveql_第2頁
hive體系架構(gòu)安裝與hiveql_第3頁
hive體系架構(gòu)安裝與hiveql_第4頁
hive體系架構(gòu)安裝與hiveql_第5頁
已閱讀5頁,還剩30頁未讀 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

Hadoop數(shù)據(jù)分析平臺(tái)趙

博士復(fù)旦大學(xué)

學(xué)院wd

PigHadoop客戶端使用類似于SQL的面向數(shù)據(jù)流的語言Pig

LatinPig

Latin可以完成排序,過濾,求和,聚組,關(guān)聯(lián)等操作,可以支持自定義函數(shù)Pig自動(dòng)把PigLatin

為Map-Reduce作業(yè)上傳到集群運(yùn)行,減少用戶編寫Java程序的苦惱三種運(yùn)行方式:Grunt

s

, 方式,Hadoop流:最簡(jiǎn)便的M-RWordcount的例子

bin/hadoop

jarcontrib/streaming/hadoop-0.20.2-streaming.jar

-inputinput

-output

output-mapper

/bin/cat-reducer

/usr/bin/wc注意,命令一定要寫完整的路徑一個(gè)案例:生物數(shù)據(jù)庫BLASTBLASTBLAST的Map-Reduce化BLAST比對(duì)算法,只涉及獨(dú)立的一條基因信息,沒有交叉計(jì)算,非常適合M-RBLAST算法用c實(shí)現(xiàn),代碼龐大,修改困難權(quán)宜之計(jì)可以使用hadoopstream快速實(shí)現(xiàn)Hive數(shù)據(jù)倉庫工具。可以把Hadoop下的原始結(jié)構(gòu)化數(shù)據(jù)變成Hive中的表支持一種與SQL幾乎完全

相同的語言HiveQL。除了不支持更新、索引和事務(wù),幾乎SQL的其它特征都能

支持可以看成是從SQL到Map-Reduce的

器提供s

、JDBC/ODBC、Thrift、Web等接口Hive簡(jiǎn)介

由JeffHammerbacher領(lǐng)導(dǎo)的團(tuán)隊(duì)構(gòu)建在Hadoop上的數(shù)據(jù)倉庫框架設(shè)計(jì)目的是讓SQL技能良好,但Java技能較弱的分析師可以查詢海量數(shù)據(jù)2008年

把hive項(xiàng)目貢獻(xiàn)給ApacheHive的組件與體系架構(gòu)用戶接口:sweb等Thrift服務(wù)器,

thrift,元數(shù)據(jù)庫“Derby,Mysql等解析器Hadoop架構(gòu)圖Hive安裝內(nèi)嵌模式:元數(shù)據(jù)保持在內(nèi)嵌的Derby模式,只允許一個(gè)會(huì)話連接本地獨(dú)立模式:在本地安裝Mysql,把元數(shù)據(jù)放到Mysql內(nèi)

模式:元數(shù)據(jù)放置在

的Mysql數(shù)據(jù)庫Hive安裝:內(nèi)嵌模式1.http://a

/hive/hive-0.8.1/hive-0.8.1.tar.gz2.安裝(1)上傳hive安裝包到機(jī)器上,使用root用戶登陸:tar

-xvf

hive-0.8.1.tar.gz(2)將解壓的hive分別移動(dòng)并改名為/usr/local/hiverm

-rf

/usr/local/hive

mv

hive-0.8.1/usr/local/hive內(nèi)嵌模式3.配置hive(1)修改/usr/local/hive/bin/hive-config.sh在文件末尾加入exportJAVA_HOME=/usr/local/jdk

export

HIVE_HOME=/usr/local/hiveexportHADOOP_HOME=/usr/local/hadoop(2)

根據(jù)hive-default.xml

hive-site.xmlcp

/usr/local/hive/conf/hive-default.xml

/usr/local/hive/conf/hive-site.xml(3)配置hive-site.xml,主要配置項(xiàng)如下:hive.metastore.warehouse.dir:(HDFS上的)數(shù)據(jù)hive.exec.scratchdir:(HDFS上的)臨時(shí)文件hive.metastore.warehouse.dir默認(rèn)值是/user/hive/warehousehive.exec.scratchdir默認(rèn)值是/tmp/hive-${}內(nèi)嵌模式以上是默認(rèn)值,暫時(shí)不改。(4)改變

/usr/local/hive的

所有者為hadoopchown

-R

hadoop:hadoop

/usr/local/hive(5)配置hive的log4j:cp

/usr/loca/hive/conf/hive-perties.template/usr/loca/hive/conf/hive-perties修改/usr/loca/hive/conf/hive-perties將org.apache.hadoop.metrics.jvm.EventCounter改為org.apache.hadoop.log.metrics.EventCounter(6)啟動(dòng)hive使用hadoop用戶登陸,執(zhí)行/usr/local/hive/bin/hiveHive安裝:獨(dú)立模式安裝Mysql并啟動(dòng)服務(wù)在Mysql中為hive建立賬號(hào),并授予足夠的權(quán)限,例如hive賬號(hào),授予all

privileges用上述賬號(hào)登陸mysql,然后創(chuàng)建數(shù)據(jù)庫,比如名叫hive,用于存放hive的元數(shù)據(jù)在本地安裝mysql客戶端配置hive-site.xml文件, 使用本地Mysql數(shù)據(jù)庫,已經(jīng)連接協(xié)議,賬號(hào)、口令等把mysql-connector-java-x.x.x.jar下到hive的lib啟動(dòng)hive能進(jìn)入s

表示安裝成功Hive安裝:

模式在本地模式的基礎(chǔ)上修改hive-site.xml文件,設(shè)置hive.metastore.local為false,并指向

mysql數(shù)據(jù)庫即可hive-site.xml文件內(nèi)容<property><name>hive.metastore.local</name><value>false</value>

<description>controls

whether

to

connect

to

remove

metastoreserveror

open

a

new

metastore

server

in

Hive

ClientJVM</description></property><property><name>javax.jdo.option.ConnectionURL</name><value>jdbc:mysql://mysql_server_host:3306/hivedb?createDatabaseIfNotExist=true&useUnicode=true&characterEncoding=latin1</value>

<description>JDBC

connect

string

for

a

JDBCmetastore</description></property>hive-site.xml文件內(nèi)容<property><name>javax.jdo.option.ConnectionDriverName</name><value>com.mysql.jdbc.Driver</value><description>Driver

class

name

for

a

JDBC

metastore</description></property><property><name>javax.jdo.option.ConnectionUserName</name><value>mysql_username</value><description>username

to

use

againstmetastore

database</description></property><property><name>javax.jdo.option.ConnectionPassword</name><value>mysql_password</value><description>password

to

use

against

metastore

database</description></property>hive-site.xml文件內(nèi)容<property><name>hive.stats.dbconnectionstring</name><value>jdbc:mysql://mysql_server_host:3306/hive_stats?useUnicode=true&characterEncoding=latin1&user=mysql_username&password=mysql_password&createDatabaseIfNotExist=true</value><description>The

default

connection

string

for

the

database

that

storestemporary

hive

statistics.</description></property><property><name>hive.stats.dbconnectionstring</name><value>jdbc:mysql://mysql_server_host:3306/hive_stats?useUnicode=true&characterEncoding=utf8&user=mysql_username&password=mysql_password&createDatabaseIfNotExist=true</value>

<description>The

default

connection

string

for

the

database

that

storestemporary

hive

statistics.</description></property>hive-site.xml文件內(nèi)容<property><name>hive.stats.dbclass</name><value>jdbc:mysql</value><description>The

defaustatistics.</description></property><property>atabase

that

stores

temporary

hive<name>hive.stats.jdbcdriver</name><value>com.mysql.jdbc.Driver</value>

<description>The

JDBC

driver

for

the

database

that

stores

temporaryhivestatistics.</description></property><property><name>hive.metastore.uris</name><value>thrift://:9083</value></property>Hive

s執(zhí)行HiveQL(大約相當(dāng)于SQL

92標(biāo)準(zhǔn))查看或臨時(shí)設(shè)置Hive參數(shù),只對(duì)當(dāng)前會(huì)話有效創(chuàng)建函數(shù)導(dǎo)入jar包創(chuàng)建表創(chuàng)建表數(shù)據(jù)查詢表連接JDBC/ODBC接口用戶可以像連接傳統(tǒng)關(guān)系數(shù)據(jù)庫一樣使用JDBC或ODBC連接Hive目前還不成熟JDBC的具體連接過程1.使用jdbc的方式連接Hive,首先做的事情就是需要啟動(dòng)hive的ThriftServer,否則連接hive的時(shí)候會(huì)報(bào)connectionrefused的錯(cuò)誤。啟動(dòng)命令如下:hive

--service

hiveserver2.新建java項(xiàng)目,然后將hive/lib下的所有jar包和hadoop的

jar包hadoop-0.20.2-core.jar添加到項(xiàng)目的類路徑上樣板代碼public

static

void

main(String[]

args)

throws

Exception

{//

TODO

Auto-generated

method

stubClass.forName("org.apache.hadoop.hive.jdbc.HiveDriver");String

dropSql="drop

table

pokes";String

createSql="create

table

pokes

(foo

int,bar

string)";String

insertSql="load

data

local

inpath

'/home/zhangxin/hive/kv1.txt'

overwrite

into

tablepokes";String

querySql="select

bar

from

pokes

limit

5";Connectionconnection=Driv

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒有圖紙預(yù)覽就沒有圖紙。
  • 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
  • 5. 人人文庫網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
  • 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
  • 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。

最新文檔

評(píng)論

0/150

提交評(píng)論