首页 > 代码库 > Ubuntu 14.10 下安装伪分布式hive-0.14.0

Ubuntu 14.10 下安装伪分布式hive-0.14.0

本地独立模式,MySQL作为元数据库

1 安装环境准备

  1.1 安装JDK,在安装hadoop时候已经安装了,参考http://www.cnblogs.com/liuchangchun/p/4097286.html

  1.2 安装hadoop,参考http://www.cnblogs.com/liuchangchun/p/4097286.html

  1.3 安装MySQL数据库,参考http://www.cnblogs.com/liuchangchun/p/4099003.html

  1.4 新建hive数据库,用户,赋予权限

mysql -u root -pinsert into user(Host,User,Password) values("localhost","hive",password("hive"));FLUSH PRIVILEGES;GRANT ALL PRIVILEGES ON *.*  TO hive@localhost IDENTIFIED BY hive;FLUSH PRIVILEGES;
create database hive;

2 安装hive

  2.1 下载最新hive,网址http://mirror.bit.edu.cn/apache/hive/,我下载的是apache-hive-0.14.0-bin

  2.2 解压到合适的目录

  2.3 配置hive环境变量

sudo nano /etc/profile
export JAVA_HOME=/usr/dev/jdk1.7.0_51export LD_LIBRARY_PATH=/home/lcc/software/dev/protobuf-2.5.0export ANT_HOME=/usr/dev/apache-ant-1.9.4export HADOOP_HOME=/home/lcc/software/hadoop/hadoop-2.5.0export HBASE_HOME=/home/lcc/software/hadoop/hbase-0.99.0 export HIVE_HOME=/home/lcc/software/hadoop/apache-hive-0.14.0-bin export PATH=$PATH:$ANT_HOME/bin:$JAVA_HOME/bin:$HADOOP_HOME/bin:$HBASE_HOME/bin:$HIVE_HOME/binexport CLASSPATH=$CLASSPATH:$JAVA_HOME/lib

  2.4 修改hive/conf下的几个template模板,并重命名为其他

cp hive-env.sh.template hive-env.shcp hive-default.xml.template hive-site.xml

  2.5 配置hive-env.sh文件,指定HADOOP_HOME

HADOOP_HOME=/home/lcc/software/hadoop/hadoop-2.5.0

  2.6 修改hive-site.xml文件,指定MySQL数据库驱动、数据库名、用户名及密码,修改的内容如下所示

<property>  <name>javax.jdo.option.ConnectionURL</name>  <value>jdbc:mysql://localhost:3306/hive?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>hive</value>  <description>username to use against metastore database</description></property><property>  <name>javax.jdo.option.ConnectionPassword</name>  <value>hive</value>  <description>password to use against metastore database</description></property><property>  <name>hive.metastore.local</name>  <value>true</value>  <description></description></property>

  2.7 修改hive/bin下的hive-config.sh文件,设置JAVA_HOME,HADOOP_HOME

export JAVA_HOME=/usr/dev/jdk1.7.0_51export HADOOP_HOME=/home/lcc/software/hadoop/hadoop-2.5.0export HIVE_HOME=/home/lcc/software/hadoop/apache-hive-0.14.0-bin

  2.8 下载mysql-connector-java-5.1.27-bin.jar文件,并放到$HIVE_HOME/lib目录下

  2.9 在HDFS中创建/tmp和/user/hive/warehouse并设置权限

hadoop fs -mkdir /tmphadoop fs -mkdir /user/hive/warehousehadoop fs -chmod g+w /tmphadoop fs -chmod g+w /user/hive/warehouse

  2.10 启动hadoop。进入hive shell,输入一些命令查看

hiveshow databases;show tables;

  2.11 可以在hadoop中查看hive生产的文件

hadoop dfs -ls /user/hive/warehouse

-----------------------------------------------------------------------------------------------------------------

按理说在mysql中会存储hive的元数据啥的,但是我这mysql中没有,不知道为啥。。。。

 

Ubuntu 14.10 下安装伪分布式hive-0.14.0