> Linux集群 > Hadoop >

centos6.5配置hadoop+hive

1,下载hive
 
  1. #cd /usr/local/  
  2. #wget -c http://mirror.esocc.com/apache/hive/hive-0.12.0/hive-0.12.0.tar.gz  
  3. #tar zxvf hive-0.12.0.tar.gz  

 
  1. #vim /etc/profile  
 
  1. HIVE_HOME=/usr/local/hive-0.12.0  
  2. HADOOP_HOME=/usr/local/hadoop-2.2.0  
  3. JAVA_HOME=/usr/local/jdk1.6.0_26  
  4. PATH=$JAVA_HOME/bin:$HIVE_HOME/bin:$HADOOP_HOME/bin:$PATH  
  5. CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$HIVE_HOME/lib:$JAVA_HOME/lib/tools.jar  
  6. export HADOOP_HOME  
  7. export JAVA_HOME  
  8. export HIVE_HOME  
  9. export PATH  
  10. export CLASSPATH   
 
  1. #source /etc/profile  



2,编辑配置文件

 
  1. #vim <span style="font-family: Arial, Helvetica, sans-serif;">hive-0.12.0/</span><span style="font-family: Arial, Helvetica, sans-serif;">conf/hive-site.xml    //加入如下内容,修改mysql连接信息</span>  
 
  1. <?xml version="1.0"?>  
  2. <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>  
  3. <configuration>  
  4. <property>  
  5. <name>hive.metastore.local</name>  
  6. <value>true</value>  
  7. </property>  
  8. <property>  
  9. <name>javax.jdo.option.ConnectionURL</name>  
  10. <value>jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true</value>  
  11. </property>  
  12. <property>  
  13. <name>javax.jdo.option.ConnectionDriverName</name>  
  14. <value>com.mysql.jdbc.Driver</value>  
  15. </property>  
  16. <property>  
  17. <name>javax.jdo.option.ConnectionUserName</name>  
  18. <value>root</value>  
  19. </property>  
  20. <property>  
  21. <name>javax.jdo.option.ConnectionPassword</name>  
  22. <value>123456</value>  
  23. </property>  
  24. </configuration>  

3,安装成功

 

  1. #hadoop fs -mkdir /test  
  2. #hadoop fs -put txl.txt /test/  

 

 

  1. #hive  
#hive> CREATE TABLE user_test(nick STRING, tel BIGINT, qq BIGINT,weixin STRING,email STRING ) ROW FORMAT DELIMITED FIELDS TERMINATED BY '\t' LINES TERMINATED BY '\n' STORED AS TEXTFILE;

 

 

  1. #load data inpath '/test/txl.txt' overwrite into table user_test;   
 
  1. #select * from user_test  
 
  1. thor 181111111 64438136 hadesthor 64438136@qq.com  
  2. OK  
  3. Time taken: 0.048 seconds  

(责任编辑:IT)