hive安装

需要提前安装好hadoop,mysql

1.下载hive软件

Index of /apache/hive/hive-3.1.3 (tsinghua.edu.cn)

2.解压缩

tar -zxvf ./apache-hive-3.1.3-bin.tar.gz -C /export/software/

cd /export/sofware

mv apache-hive-3.1.3-bin/  c

3.配置环境变量

vim /etc/profile

export HIVE_HOME=/export/software/hive3.1.3
export PATH=$PATH:$HIVE_HOME/bin
export HADOOP_HOME=/export/software/hadoop

souce /etc/profile

4.修改配置文件

  1. cd /export/software/hive3.1.3/conf
  2. mv hive-default.xml.template hive-default.xml

   然后,使用vim编辑器新建一个配置文件hive-site.xml,命令如下:

  1. vim hive-site.xml
  2. 内容为
  3. <?xml version="1.0" encoding="UTF-8" standalone="no"?>
    
    <?xml-stylesheet type="text/xsl" href="configuration.xsl"?>
    
    <configuration>
      <property>
        <name>javax.jdo.option.ConnectionURL</name>
    <value>jdbc:mysql://localhost:3306/hive?useSSL=false&createDatabaseIfNotExist=true</value>
        <description>JDBC connect string for a JDBC metastore</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.ConnectionUserName</name>
    
        <value>root</value>
    
        <description>username to use against metastore database</description>
    
      </property>
    
      <property>
    
        <name>javax.jdo.option.ConnectionPassword</name>
    
        <value>Fuhong119@</value>
    
        <description>password to use against metastore database</description>
    
      </property>
    
      <property>
    
            <name>hive.metastore.schema.verification</name>
    
            <value>false</value>
    
            <description> Enforce metastore schema version consistency. True: Verify that version information stored in is compatible with one from Hive jars.  Also disable automatic schema migration attempt. Users are required to manually migrate schema after Hive upgrade which ensures   proper metastore schema migration. (Default); False: Warn if the version information stored in metastore doesn't match with one from in Hive jars.
    
            </description>
    
            </property>
    
            <property>
    
            <name>datanucleus.schema.autoCreateAll</name>
    
            <value>true</value>
    
            </property>
    
    <property>
    
       <name>hive.conf.validation</name>
    
       <value>false</value>
    
       <description>Enables type checking for registered Hive configurations</description>
    
     </property>
    
    </configuration>
  4. 遇到问题

    Exception in thread “main“ java.lang.NoSuchMethodError: com.google.common.base.Preconditions.checkAr

    删除hive中低版本的guava-19.0.jar包,将hadoop中的/export/software/hadoop-3.2.4/share/hadoop/common/lib/guava-27.0-jre.jar复制到hive的lib目录下即可

  5. java.lang.RuntimeException: Unable to instantiate org.apache.hadoop.hive.ql.metadata.SessionHiveMetaStoreClient

  6. 将mysql-connector-java-5.1.37.jar放入到hive-3.1.2/lib

  7. Hive-site.xml  数据库连接要加useSSL=false

  8. 启动

    ./hive --service metastore &

  9. 执行hive命令

    ./hive

    create table test(id int);

    insert into test values(1);

    select * from test;

  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值