Changes between Version 4 and Version 5 of waue/2009/0506


Ignore:
Timestamp:
May 6, 2009, 5:01:26 PM (16 years ago)
Author:
waue
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • waue/2009/0506

    v4 v5  
    1313= 安裝 =
    1414
    15 
     15在 hadoop 0.19.1 的 contrib 內已有 hive 的專案,先匯入環境變數後在進到此資料夾執行hive就可以使用了
     16{{{
     17$ export HADOOP=/opt/hadoop/
     18$ export HIVE_HOME=/opt/hadoop/contrib/hive/
     19$ cd /opt/hadoop/contrib/hive
     20$ bin/hive
     21hive>
     22}}}
    1623
    1724= 測試 =
    18 {{{
    19 [hadoop@gp1 bin]$ export HADOOP=/home/hadoop/hadoop-0.19.1
    20 [hadoop@gp1 bin]$ export HIVE_HOME=/home/hadoop/hadoop-0.19.1/contrib/hive/
    21 
    22 [hadoop@gp1 bin]$ cd $HIVE_HOME
    23 [hadoop@gp1 hive]$ bin/hive
    24 
     25
     26
     27{{{
    2528hive> CREATE TABLE pokes (foo INT, bar STRING);
     29}}}
     30 *
     31{{{
    2632OK
    2733Time taken: 0.251 seconds
     34}}}
     35
     36{{{
    2837hive> CREATE TABLE invites (foo INT, bar STRING) PARTITIONED BY (ds STRING);
     38}}}
     39 *
     40{{{
    2941OK
    3042Time taken: 0.106 seconds
     43}}}
     44
     45{{{
    3146hive> SHOW TABLES;
     47}}}
     48 *
     49{{{
    3250OK
    3351invites pokes
    3452Time taken: 0.107 seconds
     53}}}
     54
     55{{{
    3556hive> DESCRIBE invites;
     57}}}
     58 *
     59{{{
    3660OK
    3761foo     int
     
    3963ds      string
    4064Time taken: 0.151 seconds
     65}}}
     66
     67{{{
    4168hive> ALTER TABLE pokes ADD COLUMNS (new_col INT);
     69}}}
     70 *
     71{{{
    4272OK
    4373Time taken: 0.117 seconds
    44 hive> ALTER TABLE invites ADD COLUMNS (new_col2 INT COMMENT 『a comment');
     74}}}
     75
     76{{{
     77hive> ALTER TABLE invites ADD COLUMNS (new_col2 INT COMMENT 'a comment');
     78}}}
     79 *
     80{{{
    4581OK
    4682Time taken: 0.152 seconds
    47 hive> LOAD DATA LOCAL INPATH 『./examples/files/kv1.txt' OVERWRITE INTO TABLE pokes;
     83}}}
     84
     85{{{
     86hive> LOAD DATA LOCAL INPATH './examples/files/kv1.txt'
     87OVERWRITE INTO TABLE pokes;
     88}}}
     89 *
     90{{{
    4891Copying data from file:/home/hadoop/hadoop-0.19.1/contrib/hive/examples/files/kv1.txt
    4992Loading data to table pokes
    5093OK
    5194Time taken: 0.288 seconds
    52 hive> LOAD DATA LOCAL INPATH 『./examples/files/kv2.txt' OVERWRITE INTO TABLE invites PARTITION (ds=』2008-08-15′);
     95}}}
     96
     97{{{
     98hive> LOAD DATA LOCAL INPATH './examples/files/kv2.txt'
     99OVERWRITE INTO TABLE invites PARTITION (ds='2008-08-15');
     100}}}
     101 *
     102{{{
    53103Copying data from file:/home/hadoop/hadoop-0.19.1/contrib/hive/examples/files/kv2.txt
    54104Loading data to table invites partition {ds=2008-08-15}
    55105OK
    56106Time taken: 0.524 seconds
    57 hive> LOAD DATA LOCAL INPATH 『./examples/files/kv3.txt' OVERWRITE INTO TABLE invites PARTITION (ds=』2008-08-08′);
     107}}}
     108
     109{{{
     110hive> LOAD DATA LOCAL INPATH './examples/files/kv3.txt'
     111OVERWRITE INTO TABLE invites PARTITION (ds='2008-08-08');
     112}}}
     113 *
     114{{{
    58115Copying data from file:/home/hadoop/hadoop-0.19.1/contrib/hive/examples/files/kv3.txt
    59116Loading data to table invites partition {ds=2008-08-08}
    60117OK
    61118Time taken: 0.406 seconds
    62 
    63 hive> INSERT OVERWRITE DIRECTORY 『/tmp/hdfs_out' SELECT a.* FROM invites a;
     119}}}
     120
     121{{{
     122hive> INSERT OVERWRITE DIRECTORY '/tmp/hdfs_out'
     123SELECT a.* FROM invites a;
     124}}}
     125 *
     126{{{
    64127Total MapReduce jobs = 1
    65128Starting Job = job_200902261245_0002, Tracking URL = http://gp1:50030/jobdetails.jsp?jobid=job_200902261245_0002
     
    72135OK
    73136Time taken: 18.551 seconds
    74 
     137}}}
     138
     139{{{
    75140hive> select count(1) from pokes;
     141}}}
     142 *
     143{{{
    76144Total MapReduce jobs = 2
    77145Number of reducers = 1
     
    96164500
    97165Time taken: 57.285 seconds
    98 
    99 hive> INSERT OVERWRITE DIRECTORY 『/tmp/hdfs_out' SELECT a.* FROM invites a;
     166}}}
     167
     168{{{
     169hive> INSERT OVERWRITE DIRECTORY '/tmp/hdfs_out' SELECT a.* FROM invites a;
     170}}}
     171 *
     172{{{
    100173Total MapReduce jobs = 1
    101174Starting Job = job_200902261245_0005, Tracking URL = http://gp1:50030/jobdetails.jsp?jobid=job_200902261245_0005
     
    108181OK
    109182Time taken: 18.349 seconds
    110 
    111 hive>  INSERT OVERWRITE DIRECTORY 『/tmp/reg_5′ SELECT COUNT(1) FROM invites a;
     183}}}
     184
     185{{{
     186hive>  INSERT OVERWRITE DIRECTORY '/tmp/reg_5' SELECT COUNT(1) FROM invites a;
     187}}}
     188 *
     189{{{
    112190Total MapReduce jobs = 2
    113191Number of reducers = 1