1:解压
tar zxf hive-0.12.0-bin.tar.gz
mv hive-0.12.0-bin hadoop
移动到hadoop目录
2:配置环境变量
[jifeng@jifeng02 hive-0.12.0-bin]$ cat ../../.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
export PATH
export JAVA_HOME=$HOME/jdk1.7.0_45
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export HADOOP_HOME=$HOME/hadoop/hadoop-1.2.1
export ANT_HOME=$HOME/apache-ant-1.9.4
export HIVE_HOME=$HOME/hadoop/hive-0.12.0-bin
export HBASE_HOME=$HOME/hbase-0.94.21
export PIG_HOME=$HOME/pig-0.12.0
export PIG_CLASSPATH=$HOME/hadoop/hadoop-1.2.1/conf/
export PATH=$PATH:$ANT_HOME/bin:$HIVE_HOME/bin::$HBASE_HOME/bin:$PIG_HOME/bin:$HADOOP_HOME/bin
[jifeng@jifeng02 hive-0.12.0-bin]$
使用配置生效 source ../../.bash_profile
3:配置Hive
修改conf目录下的文件
[jifeng@jifeng02 hive-0.12.0-bin]$ cd conf
[jifeng@jifeng02 conf]$ mv hive-env.sh.template hive-env.sh
[jifeng@jifeng02 conf]$ mv hive-default.xml.template hive-site.xml
修改bin目录下的文件
[jifeng@jifeng02 conf]$ cd ..
[jifeng@jifeng02 hive-0.12.0-bin]$ cd bin
[jifeng@jifeng02 bin]$ cat hive-config.sh
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# processes --config option from command line
#
this="$0"
while [ -h "$this" ]; do
ls=`ls -ld "$this"`
link=`expr "$ls" : '.*-> \(.*\)$'`
if expr "$link" : '.*/.*' > /dev/null; then
this="$link"
else
this=`dirname "$this"`/"$link"
fi
done
# convert relative path to absolute path
bin=`dirname "$this"`
script=`basename "$this"`
bin=`cd "$bin"; pwd`
this="$bin/$script"
# the root of the Hive installation
if [[ -z $HIVE_HOME ]] ; then
export HIVE_HOME=`dirname "$bin"`
fi
#check to see if the conf dir is given as an optional argument
while [ $# -gt 0 ]; do # Until you run out of parameters . . .
case "$1" in
--config)
shift
confdir=$1
shift
HIVE_CONF_DIR=$confdir
;;
--auxpath)
shift
HIVE_AUX_JARS_PATH=$1
shift
;;
*)
break;
;;
esac
done
# Allow alternate conf dir location.
HIVE_CONF_DIR="${HIVE_CONF_DIR:-$HIVE_HOME/conf}"
export HIVE_CONF_DIR=$HIVE_CONF_DIR
export HIVE_AUX_JARS_PATH=$HIVE_AUX_JARS_PATH
# Default to use 256MB
export HADOOP_HEAPSIZE=${HADOOP_HEAPSIZE:-256}
export JAVA_HOME=$HOME/jdk1.7.0_45
export HIVE_HOME=$HOME/hadoop/hive-0.12.0-bin
export HADOOP_HOME=$HOME/hadoop/hadoop-1.2.1
[jifeng@jifeng02 bin]$
最后新加三行
export JAVA_HOME=$HOME/jdk1.7.0_45
export HIVE_HOME=$HOME/hadoop/hive-0.12.0-bin
export HADOOP_HOME=$HOME/hadoop/hadoop-1.2.1
4:启动Hive
先启动hadoop
[jifeng@jifeng02 bin]$ cd ..
[jifeng@jifeng02 hive-0.12.0-bin]$ cd ..
[jifeng@jifeng02 hadoop]$ hive
Logging initialized using configuration in jar:file:/home/jifeng/hadoop/hive-0.12.0-bin/lib/hive-common-0.12.0.jar!/hive-log4j.properties
hive>
注意:报错—请修改hive-site.xml:(vi编辑下: /auth)
[Fatal Error] hive-site.xml:2002:16: 元素类型 "value" 必须由匹配的结束标记 "</value>" 终止。
14/08/19 15:32:58 FATAL conf.Configuration: error parsing conf file: org.xml.sax.SAXParseException; systemId: file:/home/jifeng/hadoop/hive-0.12.0-bin/conf/hive-site.xml; lineNumber: 2000; columnNumber: 16; 元素类型 "value" 必须由匹配的结束标记 "</value>" 终止。
14/08/19 15:32:58 FATAL conf.Configuration: error parsing conf file: org.xml.sax.SAXParseException; systemId: file:/home/jifeng/hadoop/hive-0.12.0-bin/conf/hive-site.xml; lineNumber: 2000; columnNumber: 16; 元素类型 "value" 必须由匹配的结束标记 "</value>" 终止。
在2002行第16字符那里 <value>auth</auth>
修改为: <value>auth</value>
hive>show tables;
此时还报错:
FAILED:Execution Error, return code 1 from org.apache.hadoop.hive.ql.exec.DDLTask.java.lang.RuntimeException: Unable to instantiateorg.apache.hadoop.hive.metastore.HiveMetaStoreClient
最后将hive-site.xml 里面hive.metastore.schema.verification 的值改为 false后,就没出现错误了。