环境:
CentOS6.6 hadoop1.2.1 mysql5.1.73
1、下载
[grid@hadoop1 ~]$ wget http://mirrors.cnnic.cn/apache/hive/hive-1.0.0/apache-hive-1.0.0-bin.tar.gz
2、解压
[grid@hadoop1 ~]$ tar -zxf apache-hive-1.0.0-bin.tar.gz
3、设置环境变量
[grid@hadoop1 ~]$ vim .bash_profile
HIVE_HOME=/home/grid/apache-hive-1.0.0-bin
PATH=$PATH:$HIVE_HOME/bin
CLASSPATH=$CLASSPATH:$HIVE_HOME/lib
export HIVE_HOME PATH CLASSPATH
[grid@hadoop1 ~]$ source .bash_profile
4、编辑Hive配置文件
a、编辑 hive-env.sh ,指定 HADOOP_HOME 、HIVE_CONF_DIR
[grid@hadoop1 conf]$ pwd
/home/grid/apache-hive-1.0.0-bin/conf
[grid@hadoop1 conf]$ cp hive-env.sh.template hive-env.sh
[grid@hadoop1 conf]$ vim hive-env.sh
# Set HADOOP_HOME to point to a specific hadoop install directory
HADOOP_HOME=/home/grid/hadoop-1.2.1
# Hive Configuration Directory can be controlled by:
export HIVE_CONF_DIR=/home/grid/apache-hive-1.0.0-bin/conf
b、编辑 hive-site.xml ,修改数据库连接属性(javax.jdo.option.ConnectionURL/ConnectionDriverName/ConnectionUserName/ConnectionPassword)
[grid@hadoop1 conf]$ cp hive-default.xml.template hive-site.xml
[grid@hadoop1 conf]$ vi hive-site.xml
<property>
<name>javax.jdo.option.ConnectionURL</name>
<value>jdbc:mysql://192.168.0.103:3306/hivedb</value>
</property>
<property>
<name>javax.jdo.option.ConnectionDriverName</name>
<value>com.mysql.jdbc.Driver</value>
</property>
<property>
<name>javax.jdo.option.ConnectionUserName</name>
<value>hive</value>
</property>
<property>
<name>javax.jdo.option.ConnectionPassword</name>
<value>123456</value>
</property>
<property>
<name>hive.metastore.uris</name>
<value>thrift://192.168.0.104:9083</value>
<description>Thrift URI for the remote metastore. Used by metastore client to connect to remote metastore.</description>
</property>
<property>
<name>hive.metastore.warehouse.dir</name>
<value>/user/hive/warehouse</value>
<description>location of default database for the warehouse</description>
</property>
5、复制MySQL的JDBC驱动包到Hive的lib目录下
6、启动Hive(hadoop已启动)
启动服务端
[grid@hadoop1 ~]$ hive --service metastore
Starting Hive Metastore Server
启动客户端
[grid@hadoop1 ~]$ hive
Logging initialized using configuration in jar:file:/home/grid/apache-hive-1.0.0-bin/lib/hive-common-1.0.0.jar!/hive-log4j.properties
hive>
使用远程mysql作为元数据库安装Hive
原文:http://my.oschina.net/zc741520/blog/378683