hive安装测试及Hive 元数据的三种存储方式
生活随笔
收集整理的這篇文章主要介紹了
hive安装测试及Hive 元数据的三种存储方式
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
一 ?hive安裝測試
1、下載解壓
tar -xf hive-x.y.z.tar.gz(本次安裝為hive-0.8.1.tar.gz) 將解壓后的hive-0.8.1文件放在系統(tǒng)的/home/hadooptest/中。 2、環(huán)境變量配置
在.bash_profile中添加: export HIVE_HOME=/home/hadooptest/hive-0.8.1 export PATH=$HIVE_HOME/bin:$PATH 另外環(huán)境變量中需要有JAVA_HOME,HADOOP_HOME 3、配置文件拷貝 ? ? ?復(fù)制conf目錄下的.template生成對應(yīng)的.xml或.properties文件:
???? cp hive-default.xml.template hive-site.xml?
???? cp hive-log4j.properties.template hive-log4j.properties
4、修改配置文件
? ? ?將org.apache.hadoop.metrics.jvm.EventCounter改成:org.apache.hadoop.log.metrics.EventCounter?, 這樣將解決異常:
???? WARNING: org.apache.hadoop.metrics.jvm.EventCounter is deprecated.??
???? Please use org.apache.hadoop.log.metrics.EventCounter in all the log4j.properties files.
二、hive元數(shù)據(jù)的三種存儲方式 ? ? Hive 將元數(shù)據(jù)存儲在 RDBMS 中,有三種模式可以連接到數(shù)據(jù)庫,其中1、2均屬于本地存儲,3屬于遠端存儲,對于使用外部數(shù)據(jù)庫存儲元數(shù)據(jù)的情況,我們在此將會以mysql舉例說明。 1、Single User Mode:
默認安裝hive,hive是使用derby內(nèi)存數(shù)據(jù)庫保存hive的元數(shù)據(jù),這樣是不可以并發(fā)調(diào)用hive的,
? 這種模式時hive默認的存儲模式,。 使用derby存儲方式時,運行hive會在當(dāng)前目錄生成一個derby文件和一個metastore_db目錄。這種存儲方式的弊端是在同一個目錄下同時只能有一個hive客戶端能使用數(shù)據(jù)庫,配置文件中的“hive.metastore.warehouse.dir”指出了倉庫的存儲位置(注意對于hive來說,數(shù)據(jù)是存儲在hdfs上的,元數(shù)據(jù)存儲在數(shù)據(jù)庫),默認屬性值為/user/hive/warehouse,假如利用hive CLI創(chuàng)建表records,則在hdfs上會看到如下目錄:/user/hive/warehouse/records/ 此目錄下存放數(shù)據(jù)。命令:load data local inpath 'input/test.txt' overwrite into table records; 這一命令會告訴hive把指定的本地文件放到它的倉庫位置,此操作只是一個文件的移動操作,去掉local的load命令為把hdfs中的文件進行移動。
2、Multi User Mode: 通過網(wǎng)絡(luò)連接到一個數(shù)據(jù)庫中,是最經(jīng)常使用到的模式。假設(shè)使用本機mysql服務(wù)器存儲元數(shù)據(jù)。這種存儲方式需要在本地運行一個mysql服務(wù)器,并作如下配置(需要將mysql的jar包拷貝到$HIVE_HOME/lib目錄下)。
(1)mysql配置 這種情況需要在mysql中配置對應(yīng)的hive用戶,使用以下命令創(chuàng)建hadoop用戶并授予權(quán)限 create user 'hadoop'@'%' identified by 'hadoop'; grant all privileges on *.* to 'hadoop'@'%' with grant option; 通過以下命令可以查看mysql的所有用戶情況 SELECT DISTINCT CONCAT('User: ''',user,'''@''',host,''';') AS query FROM mysql.user;
(2)需要在hive_site.xml對應(yīng)的配置進行修改,其中hive_remote是數(shù)據(jù)倉庫名 <property> ??<name>hive.metastore.warehouse.dir</name> ??<value>/user/hive_remote/warehouse</value> </property> <property> ??<name>hive.metastore.local</name> ??<value>true</value> </property> <property> ??<name>javax.jdo.option.ConnectionURL</name> ??<value>jdbc:mysql://localhost/hive_remote?createDatabaseIfNotExist=true</value> </property> <property> ??<name>javax.jdo.option.ConnectionDriverName</name> ??<value>com.mysql.jdbc.Driver</value> </property> <property> ??<name>javax.jdo.option.ConnectionUserName</name> ??<value>hadoop</value> </property> <property> ??<name>javax.jdo.option.ConnectionPassword</name> ??<value>hadoop</value> </property>
啟動hive 在cli命令行下創(chuàng)建表student,在mysql中通過 use hive_remote(切換到hive_remote數(shù)據(jù)庫),通過select * from TBLS 可以看到我們新創(chuàng)建的數(shù)據(jù)庫,這表明獨立mysql存儲元數(shù)據(jù)搭建成功。
3、Remote Server Mode: ? ? 在服務(wù)器端啟動一個 MetaStoreServer,客戶端利用 Thrift 協(xié)議通過 MetaStoreServer 訪問元數(shù)據(jù)庫。 ? ? ??
客戶端重要配置是hive.metastore.urls,用于通過thrift連接metastore,默認?metastore端口是9083(hadoop指南說可以通過設(shè)置METASTORE_PORT環(huán)境變量來修改metastore默認端口,但是我沒有連接成功)。 ? ? 這種方式要單獨啟動metastore,命令為hive --service metastore
?通過cli執(zhí)行show tables,成功則表示remote server mode配置成功?
轉(zhuǎn)自:http://blog.csdn.net/yangyan19870319/article/details/8694571
總結(jié)
以上是生活随笔為你收集整理的hive安装测试及Hive 元数据的三种存储方式的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 移动namenode、secondary
- 下一篇: Hadoop在MapReduce中使用压