<code id="qf3hh"></code>
  • <menuitem id="qf3hh"></menuitem>
  • <strike id="qf3hh"><label id="qf3hh"></label></strike>

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

      Hive安裝

      日期:2015年1月29日  作者:zhjw  來源:Hive安裝    點(diǎn)擊:907

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

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

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

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

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

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

        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默認(rèn)的數(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;


      二、獨(dú)立模式安裝

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

        1、啟動(dòng)MySQL

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

        2、為Hive建立相應(yīng)的MySQL賬號(hào)

      復(fù)制代碼
      [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 ~]# 
      復(fù)制代碼

          然后從客戶端用hive賬號(hào)登陸MySQL

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

      mysql>create database hive;

        4、配置Hive

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

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

      復(fù)制代碼
      <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>
      復(fù)制代碼

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

        6、進(jìn)入Hive,沒報(bào)錯(cuò)說明獨(dú)立模式安裝成功

      復(fù)制代碼
      [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;
      復(fù)制代碼

       

      国产一级婬片AAA毛,无码中文精品视视在线观看,欧美日韩a人成v在线动漫,五月丁香青草久久
      <code id="qf3hh"></code>
    • <menuitem id="qf3hh"></menuitem>
    • <strike id="qf3hh"><label id="qf3hh"></label></strike>