• hive搭建配置


    1. 下载
      cd /data0/software/hive
      wget http://mirror.bit.edu.cn/apache/hive/hive-0.12.0/hive-0.12.0-bin.tar.gz
      另一个hive-0.12.0.tar.gz,里面有docs和src文件夹
    2. 解压
      tar zxvf /data0/software/hive/hive-0.12.0-bin.tar.gz -C /home/app/act/hive/
      ln -s /home/app/act/hive/hive-0.12.0 /home/app/srv/hive
    3. 配置环境变量
      export HIVE_HOME=/home/app/srv/hive
      export PATH=$PATH:$HIVE_HOME/bin
      export CLASSPATH=$CLASSPATH:$HIVE_HOME/lib
    4. 配置配置文件
      - hive-env.sh
      配置HADOOP_HOME=/home/app/srv/hadoop
      - cd /home/app/srv/hive/conf/
        cp hive-default.xml hive-site.xml
      修改:

      <name>javax.jdo.option.ConnectionURL</name>
        <!--<value>jdbc:derby:;databaseName=metastore_db;create=true</value> -->
        <value>jdbc:mysql://10.1.16.2:3306/hive?createDatabaseIfNotExist=true</value>
        <description>JDBC connect string for a JDBC metastore</description>
      </property>
      默认使用enbed方式,元数据保存在Derby中,只允许一个会话连接;
      远程模式:元数据放置在远程mysql
      本地模式:元数据放置在本地mysql

      修改到mysql,添加
      jdbc:mysql://<ip>:3306/hive?createDatabaseIfNotExist=true<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>

    5. 启动
      帮助模式: hive --help显示hive支持的类型

      Usage ./hive <parameters> --service serviceName <service parameters>
      Service List: beeline cli help hiveserver2 hiveserver hwi jar lineage metastore metatool orcfiledump rcfilecat schemaTool
      Parameters parsed:
      --auxpath : Auxillary jars
      --config : Hive configuration directory
      --service : Starts specific service/component. cli is default
      Parameters used:
      HADOOP_HOME or HADOOP_PREFIX : Hadoop install directory
      HIVE_OPT : Hive options
      For help on a particular service:
      ./hive --service serviceName --help
      Debug help: ./hive --debug --help
      hive --service help显示支持的服务类型
      Usage ./hive <parameters> --service serviceName <service parameters>

      Service List: beeline cli help hiveserver2 hiveserver hwi jar lineage metastore metatool orcfiledump rcfilecat schemaTool
      Parameters parsed:
      --auxpath : Auxillary jars
      --config : Hive configuration directory
      --service : Starts specific service/component. cli is default
      Parameters used:
      HADOOP_HOME or HADOOP_PREFIX : Hadoop install directory
      HIVE_OPT : Hive options
      For help on a particular service:
      ./hive --service serviceName --help
      Debug help: ./hive --debug --help
      启动脚本

      app@H1:~/srv/hive/bin$ cat hive-metastore.sh
      #!/bin/sh
      nohup /home/app/srv/hive/bin/hive --service metastore >> /tmp/metastore.log 2>&1 &
      echo $! > /tmp/hive-metastore.pid

      app@H1:~/srv/hive/bin$ cat hive-server.sh
      #!/bin/sh
      nohup /home/app/srv/hive/bin/hive --service hiveserver >> /tmp/hiveserver.log 2>&1 &
      echo $! > /tmp/hive-server.pid

    6. 数据操作,hive的数据来源于hadoop的hdf,先要将数据put到hdf
      1. 创建一个普通文件aa.txt
      2.hadoop dfs -put './aa.txt' '/user/app/testinput/‘
      3.hive ==》进入hive交互命令行
      create database test;
      use test;
      create table test1 (id int, name string );
      LOAD DATA  Local INPATH '/user/app/testinput/aa.txt' OVERWRITE INTO TABLE test;
      select * from test;
      drop table test;

    https://cwiki.apache.org/confluence/display/Hive/GettingStarted

    https://cwiki.apache.org/confluence/display/Hive/AdminManual+MetastoreAdmin

  • 相关阅读:
    浅析c#中new、override、virtual关键字的区别
    数据解析1113
    Silverlight中xaml之间的跳转方案之一
    silverlight读取client文件的完整路径
    (Transfered)WPF Tutorial:Beginning
    数据解析1112
    邮件发送1
    TortoiseSVN Settings Subversion
    德信无线10Q4净利润同比增进187%
    欧盟中止对我数据卡双反调查
  • 原文地址:https://www.cnblogs.com/silenceli/p/3437487.html
Copyright © 2020-2023  润新知