Hive是由Facebook的数据组开发维护的,在Facebook内部使用之后,被移交给Apache基金会。
Hive是建立在Hadoop之上的数据仓库,其使用MapReduce对存储于HDFS之上的数据进行分析。
sudo tar -zxvf apache-hive-1.0.0-bin.tar.gz -C /opt
sudo mv apache-hive-1.0.0-bin/ hive
export HIVE_HOME=/opt/hive export PATH=$HIVE_HOME/bin:$HIVE_HOME/conf:$PATH在当前终端输入source /etc/profile 使环境变量对当前终端生效。
cd $HIVE_HOME/conf cp hive-default.xml.template hive-site.xml
hive-default.xml.template为系统提供给的配置文档模板,其中填写的是默认的配置参数。
cd /opt/hive/conf/ cp hive-env.sh.template hive-env.sh然后在hive-env.sh文件里加下面的内容:
export HADOOP_HOME=/opt/hadoop/
再次执行bin/hive后出现如下错误:
Logging initialized using configuration in jar:file:/opt/hive/lib/hive-common-1.0.0.jar!/hive-log4j.propertiesException in thread "main" java.lang.RuntimeException: java.lang.RuntimeException:
The root scratch dir: /tmp/hive on HDFS should be writable. Current permissions are: rwx--x--x
......错误报告要赋予HDFS上/tmp/hive写权限,进行如下操作赋予/tmp/hive写权限,
caiyong@caiyong:/opt/hadoop$ bin/hadoop fs -ls /tmp/
Exception in thread "main" java.lang.RuntimeException: java.lang.IllegalArgumentException: java.net.URISyntaxException:
Relative path in absolute URI: ${system:java.io.tmpdir%7D/$%7Bsystem:user.name%7D
......错误表明在此不能使用相对路径,要修改hive-site.xml的配置。具体操作如下:
<property> <name>hive.exec.scratchdir</name> <value>/tmp/hive</value> <description>HDFS root scratch dir for Hive jobs which gets created with write all (733) permission. For each connecting user, an HDFS scratch dir: ${hive.exec.scratchdir}/<username> is created, with ${hive.scratch.dir.permission}.</description> </property>
<property> <name>hive.exec.local.scratchdir</name> <value>/home/caiyong/hive/tmp</value> <description>Local scratch space for Hive jobs</description> </property>
<property> <name>hive.downloaded.resources.dir</name> <value>/home/caiyong/hive/resources</value> <description>Temporary local directory for added resources in the remote file system.</description> </property>最后执行bin/hive后,出现如下结果,说明启动Hive成功。
在以后启动Hadoop后接着启动Hive,可能会出现如下错误:
caiyong@caiyong:/opt/hive$ bin/hive
Logging initialized using configuration in jar:file:/opt/hive/lib/hive-common-1.0.0.jar!/hive-log4j.properties
Exception in thread "main" java.lang.RuntimeException: org.apache.hadoop.ipc.RemoteException:
org.apache.hadoop.hdfs.server.namenode.SafeModeException: Cannot create directory /tmp/hive/caiyong/03415c24-adee-4998-bd6f-e4173b7b17be.
Name node is in safe mode.
......
原因是 Name node is in safe mode.,所以要等name node退出safe mode 后再启动Hive.