Hive1.2.1安装配置

一、前提

-安装好 hadoop集群
-安装好 mysql

二、配置

-配置环境变量

-配置bin下hive-config.sh

export JAVA_HOME=/usr/local/spark/jdk1.8.0_73
export HADOOP_HOME=/usr/local/spark/hadoop-2.6.0
export HIVE_HOME=/usr/local/spark/apache-hive-1.2.1-bin

-配置 conf 下的 hive-site.xml


<configuration>
    <property>
        <name>javax.jdo.option.ConnectionURLname>
        <value>jdbc:mysql://master:3306/hive?createDatabaseInfoNotExist=truevalue> 
    property>

    <property>
        <name>javax.jdo.option.ConnectionDriverNamename>
        <value>com.mysql.jdbc.Drivervalue>
    property>
    <property>
        <name>javax.jdo.option.ConnectionUserNamename>
        <value>rootvalue>
    property>

    <property>
        <name>javax.jdo.option.ConnectionPasswordname>
        <value>123456value>
    property>

    <property>
        <name>hive.metastore.warehouse.dirname>
        <value>/user/hive/warehousevalue>
    property>

configuration>

注:
1.mysql中需要提前建数据库 hive 不然会报错
2.安装过程可能会报以下错

[ERROR] Terminal initialization failed; falling back to unsupported
java.lang.IncompatibleClassChangeError: Found class jline.Terminal, but interface was expected
原因: 
hadoop目录下存在老版本jline: 
/hadoop-2.6.0/share/hadoop/yarn/lib: 
-rw-r--r-- 1 root root   87325 Mar 10 18:10 jline-0.9.94.jar 
解决: 
cp /hive/apache-hive-1.1.0-bin/lib/jline-2.12.jar /hadoop-2.5.2/share/hadoop/yarn/lib 

三、操作

运行 hive进行shell模式

建表

create table employee(id int, name String, salary double, country String) Row Format delimited fields terminated by '\|' lines terminated by '\n';

导入数据

load data local inpath "/usr/local/spark/apache-hive-1.2.1-bin/examples/files/employee_part.txt" into table employee;

overwrite 模式导入数据

load data local inpath "/usr/local/spark/apache-hive-1.2.1-bin/examples/files/employee_part.txt" overwrite into table employee;

查询表

select * from employee;

进入 hdfs查看数据
http://work1:50070/explorer.html#/user/hive/warehouse

你可能感兴趣的:(大数据)