1,下载hive
-
#cd /usr/local/
-
#wget -c http://mirror.esocc.com/apache/hive/hive-0.12.0/hive-0.12.0.tar.gz
-
#tar zxvf hive-0.12.0.tar.gz
#cd /usr/local/
#wget -c http://mirror.esocc.com/apache/hive/hive-0.12.0/hive-0.12.0.tar.gz
#tar zxvf hive-0.12.0.tar.gz
#vim /etc/profile
-
HIVE_HOME=/usr/local/hive-0.12.0
-
HADOOP_HOME=/usr/local/hadoop-2.2.0
-
JAVA_HOME=/usr/local/jdk1.6.0_26
-
PATH=$JAVA_HOME/bin:$HIVE_HOME/bin:$HADOOP_HOME/bin:$PATH
-
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$HIVE_HOME/lib:$JAVA_HOME/lib/tools.jar
-
export HADOOP_HOME
-
export JAVA_HOME
-
export HIVE_HOME
-
export PATH
-
export CLASSPATH
HIVE_HOME=/usr/local/hive-0.12.0
HADOOP_HOME=/usr/local/hadoop-2.2.0
JAVA_HOME=/usr/local/jdk1.6.0_26
PATH=$JAVA_HOME/bin:$HIVE_HOME/bin:$HADOOP_HOME/bin:$PATH
CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$HIVE_HOME/lib:$JAVA_HOME/lib/tools.jar
export HADOOP_HOME
export JAVA_HOME
export HIVE_HOME
export PATH
export CLASSPATH
#source /etc/profile
2,编辑配置文件
-
#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>
#vim hive-0.12.0/conf/hive-site.xml //加入如下内容,修改mysql连接信息
-
<?xml version="1.0"?>
-
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
-
<configuration>
-
<property>
-
<name>hive.metastore.local</name>
-
<value>true</value>
-
</property>
-
<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>root</value>
-
</property>
-
<property>
-
<name>javax.jdo.option.ConnectionPassword</name>
-
<value>123456</value>
-
</property>
-
</configuration>
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
<configuration>
<property>
<name>hive.metastore.local</name>
<value>true</value>
</property>
<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>root</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>123456</value>
</property>
</configuration>
3,安装成功
-
#hadoop fs -mkdir /test
-
#hadoop fs -put txl.txt /test/
#hadoop fs -mkdir /test
#hadoop fs -put txl.txt /test/
#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;
-
#load data inpath '/test/txl.txt' overwrite into table user_test;
#load data inpath '/test/txl.txt' overwrite into table user_test;
#select * from user_test
-
thor 181111111 64438136 hadesthor 64438136@qq.com
-
OK
-
Time taken: 0.048 seconds
(责任编辑:IT) |