• <th id="kadjp"></th>

            1. ?
                開發(fā)技術(shù) / Technology

                Hive安裝

                日期:2015年1月29日  作者:zhjw  來源:Hive安裝    點擊:713

                  數(shù)據(jù)倉庫工具,可以把Hadoop下的原始結(jié)構(gòu)化數(shù)據(jù)變成Hive中的表。

                  支持一種與SQL幾乎完全相同的語言HiveQL,除了不支持更新、索引和事務。

                  可以看成是從SQL到Map-Reduce的映射器。

                  提供shell、JDBC/ODBC、thrift、Web等接口。

                一、內(nèi)嵌模式安裝

                  這樣安裝的元數(shù)據(jù)保持在內(nèi)嵌的Derby數(shù)據(jù)庫中,只能允許一個會話連接,只適用于簡單的測試。

                  1、解壓Hive

                [coder@h1 ~]$ tar -zxvf hive-0.10.0.tar.gz

                  2、配置環(huán)境變量/etc/profile

                    加入Hive的安裝目錄,并把Hive的bin目錄配置到PATH

                HIVE_HOME=/home/coder/hive-0.10.0
                PATH=$HADOOP_INSTALL/bin:$PIG_INSTALL/bin:$JAVA_HOME/bin:$HIVE_HOME/bin:$PATH

                    執(zhí)行 source /etc/profile命令,使得配置生效

                  3、新建Hive所需目錄

                    在HDFS上建立/tmp和/user/hive/warehouse目錄,并賦予組用戶寫權(quán)限。這是Hive默認的數(shù)據(jù)文件存放目錄,可以在hive-site.xml文件中配置。

                [coder@h1 hadoop-0.20.2]$ bin/hadoop fs -mkdir /tmp
                [coder@h1 hadoop-0.20.2]$ bin/hadoop fs -mkdir /user/hive/warehouse
                [coder@h1 hadoop-0.20.2]$ bin/hadoop fs -chmod g+w /tmp
                [coder@h1 hadoop-0.20.2]$ bin/hadoop fs -chmod g+w /user/hive/warehouse

                  4、輸入hive命令,出現(xiàn)類似下面的內(nèi)容,說明安裝成功。

                [coder@h1 hadoop-0.20.2]$ hive
                Logging initialized using configuration in jar:file:/home/coder/hive-0.10.0/lib/hive-common-0.10.0.jar!/hive-log4j.properties
                Hive history file=/tmp/coder/hive_job_log_coder_201305072118_1272944282.txt
                hive> 
                hive> show tables;
                OK
                Time taken: 24.479 seconds
                hive> exit;


                二、獨立模式安裝

                  支持多用戶會話,需要一個獨立的元數(shù)據(jù)庫,常用的是使用MySQL作為元數(shù)據(jù)庫。

                  1、啟動MySQL

                [root@h1 ~]# service mysqld start
                Starting mysqld:  [  OK  ]
                [root@h1 ~]# 

                  2、為Hive建立相應的MySQL賬號

                復制代碼
                [root@h1 ~]# mysql
                Welcome to the MySQL monitor.  Commands end with ; or g.
                Your MySQL connection id is 2
                Server version: 5.1.66 Source distribution
                
                Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
                
                Oracle is a registered trademark of Oracle Corporation and/or its
                affiliates. Other names may be trademarks of their respective
                owners.
                
                Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
                
                mysql> create user 'hive' identified by '123456';
                Query OK, 0 rows affected (0.00 sec)
                
                mysql> GRANT ALL PRIVILEGES ON *.* TO 'hive'@'localhost' IDENTIFIED BY '123456' WITH GRANT OPTION; 
                Query OK, 0 rows affected (0.00 sec)
                
                mysql> flush privileges;
                Query OK, 0 rows affected (0.00 sec)
                
                mysql> exit
                Bye
                [root@h1 ~]# 
                復制代碼

                    然后從客戶端用hive賬號登陸MySQL

                  3、建立Hive專用元數(shù)據(jù)庫

                mysql>create database hive;

                  4、配置Hive

                    在Hive安裝目錄的conf目錄下,將hive-default.xml.template復制一份命名為:hive-site.xml

                  修改以下內(nèi)容,配置上mysql數(shù)據(jù)連接、驅(qū)動、用戶名和密碼

                復制代碼
                <property>
                   <name>javax.jdo.option.ConnectionURL</name>
                   <value>jdbc:mysql://localhost:3306/hive?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>hive</value>
                </property>
                <property>
                   <name>javax.jdo.option.ConnectionPassword</name>
                   <value>123456</value>
                </property>
                復制代碼

                  5、把mysql的驅(qū)動包拷貝到Hive安裝路徑下的lib目錄

                  6、進入Hive,沒報錯說明獨立模式安裝成功

                復制代碼
                [coder@h1 ~]$ hive
                Logging initialized using configuration in jar:file:/home/coder/hive-0.10.0/lib/hive-common-0.10.0.jar!/hive-log4j.properties
                Hive history file=/tmp/coder/hive_job_log_coder_201305072212_717503278.txt
                hive> show tables;
                OK
                Time taken: 24.783 seconds
                hive> exit;
                復制代碼

                 

                国产欧美在线观看,国产精品白浆冒出视频,91精品国产91热久久久福利,大伊香蕉在线精品视频97 国产精品美女久久福利 国产精品黄的免费观看
              • <th id="kadjp"></th>