==作者:YB-Chi==
[toc]
准备软件
apache-hive-1.2.1-bin.tar.gz
安装步奏
将文件解压在/usr/local/下并改名hive_1.2.1
#配置系统环境变量/etc/profile
# Hive Environment Variables
export HIVE_HOME=/usr/local/hive_1.2.1
export PATH=$PATH:$HIVE_HOME/bin:$HIVE_HOME/conf
source /etc/profile 使刚刚的配置生效
#配置Hive
hive的配置文件放在$HIVE_HOME/conf下,里面有4个默认的配置文件模板
hive-default.xml.template 默认模板
hive-env.sh.template hive-env.sh默认配置
hive-exec-log4j.properties.template exec默认配置
hive-log4j.properties.template log默认配置
可不做任何修改hive也能运行,默认的配置元数据是存放在Derby数据库里面的,
大多数人都不怎么熟悉,我们得改用mysql来存储我们的元数据,
以及修改数据存放位置和日志存放位置等使得我们必须配置自己的环境,下面介绍如何配置。
(1)创建配置文件,直接copy默认配置文件再修改即可,用户自定义配置会覆盖默认配置
cp $HIVE_HOME/conf/hive-default.xml.template $HIVE_HOME/conf/hive-site.xml
cp $HIVE_HOME/conf/hive-env.sh.template $HIVE_HOME/conf/hive-env.sh
cp $HIVE_HOME/conf/hive-exec-log4j.properties.template $HIVE_HOME/conf/hive-exec-log4j.properties
cp $HIVE_HOME/conf/hive-log4j.properties.template $HIVE_HOME/conf/hive-log4j.properties
(2)修改 hive-env.sh
vi $HIVE_HOME/conf/hive-env.sh
export HADOOP_HOME=/usr/local/hadoop
export HIVE_CONF_DIR=/usr/local/hive_1.2.1/conf
(3)修改 hive-log4j.properties
mkdir $HIVE_HOME/logs
vi $HIVE_HOME/conf/hive-log4j.properties
hive.log.dir=/usr/local/hive_1.2.1/logs
(4)修改 hive-site.xml
vi $HIVE_HOME/conf/hive-site.xml
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/usr/local/hive_1.2.1/warehouse</value>
<description>location of default database for the warehouse</description>
</property>
<property>
<name>hive.exec.scratchdir</name>
<value>/usr/local/hive_1.2.1/scratchdir</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.querylog.location</name>
<value>/usr/local/hive_1.2.1/logs</value>
<description>Location of Hive run time structured log file</description>
</property>
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jjdbc:mysql://192.168.15.131:3306/hivedb?createDatabaseIfNotExist=true</value>
<description>JDBC connect string for a JDBC metastore</description>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
<description>Driver class name for a JDBC metastore</description>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>root</value>
<description>Username to use against metastore database</description>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>root</value>
<description>password to use against metastore database</description>
</property>