说明:转载我同事关于hadoop的文章,给大家分享下~
地址:
《Hive1.0.0安装》
1、Hive的安装
用命令“tar -zxvf”命令将gz压缩文件解压。笔者Hive的安装目录为:“/home/hadoop”,解压后的Hive目录为“/home/hadoop/apache-hive-1.0.0-bin。仅需安装在Master机器上。
2、配置Hive的环境变量
成功安装Hive后,接下来要做的事情就是配置Hive的环境变量,并通过命令“source “/etc/profile”命令使修改后的配置生效,如下所示:
Shell代码
#HIVE
export HIVE_HOME=/home/hadoop/apache-hive-1.0.0-bin
export PATH=$PATH:$HIVE_HOME/bin
3、修改Hive的配置文件
首先将hive-env.sh.template和hive-default.xml.template进行复制并改名为hive-env.sh和hive-site.xml。
/home/hadoop/apache-hive-1.0.0-bin/conf/hive-env.sh修改,如下所示:
Shell代码
export HADOOP_HEAPSIZE=1024
# Set HADOOP_HOME to point to a specific hadoop install directory
HADOOP_HOME=/home/hadoop/hadoop-2.5.2
# Hive Configuration Directory can be controlled by:
export HIVE_CONF_DIR=/home/hadoop/apache-hive-1.0.0-bin/conf
# Folder containing extra ibraries required for hive compilation/execution can be controlled by:
export HIVE_AUX_JARS_PATH=/home/hadoop/apache-hive-1.0.0-bin/lib
/home/hadoop/apache-hive-1.0.0-bin/conf/hive-site.xml修改,如下所示:
Xml代码
<property>
<name>hive.metastore.warehouse.dir</name>
<value>hdfs://Master:9000/hbase</value>
</property>
<property>
<name>hive.querylog.location</name>
<value>/usr/hadoop/hive/log</value>
<description>
存放hive相关日志的目录
</description>
</property>
需要在“hive.querylog.location”变量所指定的位置创建对应的目录用于存放hive日志。至于存放Hive元数据,笔者为了掩饰方便就没用使用外围RDBMS,而是使用缺省的Derby数据库。
4、启动Hive
Shell代码
[hadoop@Master bin]$ hive
Logging initialized using configuration in jar:file:/home/hadoop/apache-hive-1.0.0-bin/lib/hive-common-1.0.0.jar!/hive-log4j.properties
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/hadoop/hadoop-2.5.2/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/hadoop/apache-hive-1.0.0-bin/lib/hive-jdbc-1.0.0-standalone.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.slf4j.impl.Log4jLoggerFactory]
hive> show tables;
OK
table_name
Time taken: 0.906 seconds, Fetched: 1 row(s)
hive>