Ubuntu16.04 install apache-hive-2.3.0-bin.tar.gz

安装mysql-server
    apt-get install mysql-server

下载hive
        sudo wget http://mirrors.hust.edu.cn/apache/hive/hive-2.3.0/apache-hive-2.3.0-bin.tar.gz
解压hive
    sudo tar zxvf apache-hive-2.3.0-bin.tar.gz
    sudo mv apache-hive-2.3.0-bin.tar.gz /opt/hive

环境变量
    sudo vim /etc/profile.d/hive-en.sh

        export HIVE_HOME=/opt/hive
        export HCAT_HOME=$HIVE_HOME/hcatalog
        export HIVE_CONF=$HIVE_HOME/conf
        export PATH=$PATH:$HIVE_HOME/bin

    source /etc/profile.d/hive-en.sh
    echo $HIVE_HOME

hive配置
    cd /opt/hive/conf/
配置hive.site.xml
    cp hive-default.xml.template hive.site.xml

    sudo gedit hive-site.xml

    配置:
        javax.jdo.option.ConnectionPassword
        root
        
        javax.jdo.option.ConnectionURL
            jdbc:mysql://localhost:3306/hive?createDatabaseIfNotExist=true

        javax.jdo.option.ConnectionDriverName
            com.mysql.jdbc.Driver

        hive.metastore.schema.verification
            false

        javax.jdo.option.ConnectionUserName
            root

    下面几个配置没有的复制到倒数第二行:

    datanucleus.schema.autoCreateSchema
    true



    datanucleus.schema.autoCreateSchema
    true



    datanucleus.schema.autoCreateTables
    true



    datanucleus.schema.autoCreateColumns
    true


    将${system:java.io.tmpdir}替换/tmp
    将${system:user.name}替换root


检查jdbc包
    cd /opt/hive/lib

    https://dev.mysql.com/downloads/connector/j/
    下载解压拷贝到

创建hive数据库
    hive
    show tables;
    
    gedit /tmp/donny/hive.log 查看异常

mysql查看
    新开窗口
    mysql -uroot -p
    show databases;

Hive实现WordCount


CREATE TABLE docs (line string);

show create table docs;

load data local inpath "/data/project/lesson-demo/assembly.xml" into table docs;

dfs -ls /user/hive/warehouse/docs;

select * from docs limit 1;

select * from docs limit 2;

select t.word, count(1) from (SELECT explode(split(line,'\s')) AS word from docs) t group by word

CREATE TABLE word_counts AS select t.word, count(1) from (SELECT explode(split(line,'\s')) AS word from docs) t group by word order by word;

转载于:https://www.cnblogs.com/DowneyJr/p/7635053.html

你可能感兴趣的:(Ubuntu16.04 install apache-hive-2.3.0-bin.tar.gz)