hive-2.0安装

版本与前提条件:
hadoop-2.6.0,hive-2.0.0

一、hive安装

1、官网下载地址:http://hive.apache.org/downloads.html

下载后解压到指定目录,例如 /usr/local/hive

tar -xvf apache-hive-2.0.0-bin.tar.gz  ;  mv apache-hive-2.0.0-bin /usr/local/hive

2、配置环境变量

vim /etc/profile

export  HIVE_HOME=/usr/local/hive/

export  PATH=$HIVE_HOME/bin:$PATH 

source /etc/profile

3、创建Hive在HDFS中所需的目录

# cd /usr/local/hadoop/bin
# ./hadoop fs -mkdir /tmp
# ./hadoop fs -mkdir /user/hive/warehouse
# ./hadoop fs -chmod g+w /tmp
# ./hadoop fs -chmod g+w /user/hive/warehouse

二、配置hive

Hive/conf目录下 :

2.1. hive-env.sh配置
cp hive-env.sh.template hive-env.sh

vim hive-env.sh

HADOOP_HOME=/usr/local/hadoop
export HIVE_CONF_DIR=/usr/local/hive/conf
export HIVE_HOME=/usr/local/hive
export HADOOP_HEAPSIZE=2048

2.2. hive-site.xml配置
cp hive-default.xml.template hive-site.xml

vim hive-site.xml

<property>
        <name>javax.jdo.option.ConnectionURLname>
        <value>jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=truevalue>
        <description>JDBC connect string for a JDBC metastoredescription>
property>

<property>
        <name>javax.jdo.option.ConnectionDriverNamename>
        <value>com.mysql.jdbc.Drivervalue>
        <description>Driver class name for a JDBC metastoredescription>
property>

<property>
        <name>javax.jdo.option.ConnectionUserNamename>
        <value>hivevalue>
        <description>username to use against metastore databasedescription>
property>

<property>
        <name>javax.jdo.option.ConnectionPasswordname>
        <value>hivevalue>
        <description>password to use against metastore databasedescription>
property>

<property>
        <name>hive.metastore.warehouse.dirname>
        <value>/user/hive/warehousevalue>
        <description>location of default database for the warehousedescription>
property>

<property>
        <name>hive.metastore.localname>
        <value>truevalue>
property>

这里我们将hive的服务端(Hive Service)和客户端(metadata Service)部署在同一台服务器上。

更多Hive metastore配置方式可以参考:http://blog.csdn.net/reesun/article/details/8556078

2.3 cp mysql-connector-java-5.1.38.jar hive-2.0.0/lib

三、安装mysql创建hive用户

mysql> use mysql;
mysql> update user set password = Password('root') where User = 'root';
mysql> create user 'hive'@'%' identified by 'hive';
mysql> grant all privileges on *.* to 'hive'@'%' with grant option;
mysql> flush privileges;
mysql> exit;

建数据库:

mysql> create database hive;

四、启动hive

$HIVE_HOME/bin hive
hive> show databases;
OK
default
Time taken: 0.907 seconds, Fetched: 1 row(s)

在Hive中创建一张测试表test1

hive> create table test1(name string, age int);
hive> show tables;
hive> desc test1

五、启动hiveserver2服务

jdbc 等需要用此服务

nohup "${HIVE_HOME}"/bin/hive --service hiveserver2  >> "${HIVE_HOME}"/logs/hiveserver.log 2>&1 &
nohup "${HIVE_HOME}"/bin/hive --service metastore  >> "${HIVE_HOME}"/logs/metastore.log 2>&1 &

六、遇到的问题

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
将${system:java.io.tmpdir},替换为/home/hive/tmp/
将不能识别的变量替换成路径

你可能感兴趣的:(hive)