Hive-1.2.2安装(本地模式)

原创
2017/06/14 20:16
阅读数 241

Hive-1.2.2安装(本地模式)

  • 必要条件
    • Java 1.7 (Hive 1.2 及以上版本需要 Java 1.7 或更高版本)
    • Hadoop 2.x (推荐), 1.x (不支持 Hive 2.0.0 以上版本).
    • 配置好环境变量HADOOP_HOME=<hadoop-install-dir>,或HADOOP_PREFIX=<hadoop-install-dir>,或添加<hadoop-install-dir>/bin至PATH中

使用一个稳定发行版安装包安装 Hive

  1. 安装配置MySQL-server,用于存储Hive metadata

    1. 安装mySQL-server,省略
    2. 创建database:hive_meta,user:hive,password:hive
      create database hive_meta;
      create user hive;
      grant all on hive_meta.* to hive@'%' identified by 'hive';
      flush privileges;
      
  2. 从官网下载hive-1.2.2安装包

    wget http://apache.fayea.com/hive/hive-1.2.2/apache-hive-1.2.2-bin.tar.gz
    
  3. 解压

    tar -zxvf apache-hive-1.2.2-bin.tar.gz
    
  4. 设置环境变量HIVE_HOME指向hive安装目录,添加$HIVE_HOME/bin至环境变量PATH中

    vi /etc/profile
    # 添加以下两行内容
    export HIVE_HOME=<hive-install-dir>
    export PATH=$HIVE_HOME/bin:$PATH
    
  5. 配置hive-site.xml

    # 进入hive安装目录
    cd $HIVE_HOME
    # conf文件夹下的hive-default.xml.template文件仅作为文档查看,要更改hive的默认配置,需要在conf文件夹下新建文件hive-site.xml
    vi conf/hive-site.xml
    # 增加以下内容(具体配置项要根据具体环境作相应修改)
    <configuration>
      <property>
        <name>hive.metastore.warehouse.dir</name>
        <value>/user/hive/warehouse</value>
        <description>location of default database for the warehouse</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.ConnectionURL</name>
        <value>jdbc:mysql://172.16.117.61:3306/hive_meta?createDatabaseIfNotExist=true</value>
        <description>JDBC connect string 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>
    </configuration>
    
  6. 添加MySQL JDBC驱动包到$HIVE_HOME/lib文件夹中

    1. 下载MySQL JDBC驱动包
      wget https://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.42.tar.gz
      
    2. 解压
      tar -zxvf mysql-connector-java-5.1.42.tar.gz
      
    3. 拷贝MySQL JDBC驱动包到$HIVE_HOME/lib文件夹中
      cp mysql-connector-java-5.1.42/mysql-connector-java-5.1.42-bin.jar $HIVE_HOME/lib
      
  7. 进入hive-Cli

    hive
    

FAQ

  1. 异常信息:
[ERROR] Terminal initialization failed; falling back to unsupported
java.lang.IncompatibleClassChangeError: Found class jline.Terminal, but interface was expected
at jline.TerminalFactory.create(TerminalFactory.java:101)
at jline.TerminalFactory.get(TerminalFactory.java:158)
at jline.console.ConsoleReader.<init>(ConsoleReader.java:229)
at jline.console.ConsoleReader.<init>(ConsoleReader.java:221)
at jline.console.ConsoleReader.<init>(ConsoleReader.java:209)
at org.apache.hadoop.hive.cli.CliDriver.setupConsoleReader(CliDriver.java:787)
at org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:721)
at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:681)
at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:621)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.hadoop.util.RunJar.run(RunJar.java:221)
at org.apache.hadoop.util.RunJar.main(RunJar.java:136)
  • 异常原因:$HIVE_HOME/lib/jline-*.jar与$HADOOP_HOME/share/hadoop/yarn/lib/jline-*.jar冲突
  • 解决办法:使用高版本jline替换掉低版本jar
    rm -f $HADOOP_HOME/share/hadoop/yarn/lib/jline-0.9.94.jar
    cp $HIVE_HOME/lib/jline-2.12.jar $HADOOP_HOME/share/hadoop/yarn/lib/
    
  1. 异常信息:
ERROR [main]: exec.DDLTask (DDLTask.java:failed(520)) - org.apache.hadoop.hive.ql.metadata.HiveException: MetaException(message:file:/user/hive/warehouse/test is not a directory or unable to create one)
at org.apache.hadoop.hive.ql.metadata.Hive.createTable(Hive.java:720)
at org.apache.hadoop.hive.ql.exec.DDLTask.createTable(DDLTask.java:4135)
at org.apache.hadoop.hive.ql.exec.DDLTask.execute(DDLTask.java:306)
at org.apache.hadoop.hive.ql.exec.Task.executeTask(Task.java:160)
at org.apache.hadoop.hive.ql.exec.TaskRunner.runSequential(TaskRunner.java:88)
at org.apache.hadoop.hive.ql.Driver.launchTask(Driver.java:1676)
at org.apache.hadoop.hive.ql.Driver.execute(Driver.java:1435)
at org.apache.hadoop.hive.ql.Driver.runInternal(Driver.java:1218)
at org.apache.hadoop.hive.ql.Driver.run(Driver.java:1082)
at org.apache.hadoop.hive.ql.Driver.run(Driver.java:1072)
at org.apache.hadoop.hive.cli.CliDriver.processLocalCmd(CliDriver.java:213)
at org.apache.hadoop.hive.cli.CliDriver.processCmd(CliDriver.java:165)
at org.apache.hadoop.hive.cli.CliDriver.processLine(CliDriver.java:376)
at org.apache.hadoop.hive.cli.CliDriver.executeDriver(CliDriver.java:736)
at org.apache.hadoop.hive.cli.CliDriver.run(CliDriver.java:681)
at org.apache.hadoop.hive.cli.CliDriver.main(CliDriver.java:621)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.apache.hadoop.util.RunJar.run(RunJar.java:221)
at org.apache.hadoop.util.RunJar.main(RunJar.java:136)
  • 解决办法:配置环境变量 HADOOP_DEV_HOME=<hadoop-install-dir>
展开阅读全文
打赏
0
0 收藏
分享
加载中
更多评论
打赏
0 评论
0 收藏
0
分享
返回顶部
顶部