栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

Hive的安装与环境配置

Hive的安装与环境配置

一、Hive的安装
  1. 上传安装包到/export/server/文件夹下(listenwind102)

    tar zxvf apache-hive-3.1.2-bin.tar.gz

  2. 解压文件夹(listenwind102)

    tar zxvf apache-hive-3.1.2-bin.tar.gz
    
二、环境配置
  1. 替换guava文件解决Hive与Hadoop之间guava版本差异(listenwind102)

    cd /export/server/apache-hive-3.1.2-bin/
    rm -rf lib/guava-19.0.jar
    cp /export/server/hadoop-3.3.0/share/hadoop/common/lib/guava-27.0-jre.jar ./lib/
    
  2. 修改配置文件(listenwind102)

    cd /export/server/apache-hive-3.1.2-bin/conf
    mv hive-env.sh.template hive-env.sh
    vim hive-env.sh
    
    # 新加入的代码
    export HADOOP_HOME=/export/server/hadoop-3.3.0
    export HIVE_CONF_DIR=/export/server/apache-hive-3.1.2-bin/conf
    export HIVE_AUX_JARS_PATH=/export/server/apache-hive-3.1.2-bin/lib
    
    vim hive-site.xml
    
    configuration>
        
        
            javax.jdo.option.ConnectionURL
            jdbc:mysql://listenwind102:3306/hive3?createDatabaseIfNotExist=true&useSSL=false
        
    
        
            javax.jdo.option.ConnectionDriverName
            com.mysql.jdbc.Driver
        
    
        
            javax.jdo.option.ConnectionUserName
            root
        
    
        
            javax.jdo.option.ConnectionPassword
            hadoop
        
    
        
        
            hive.server2.thrift.bind.host
            listenwind102
        
    
        
        
            hive.metastore.uris
            thrift://listenwind102:9083
        
    
         
        
            hive.metastore.event.db.notification.api.auth
            false
        
        
    
  3. 上传mysql jdbc驱动到hive安装包lib下(listenwind102)

    cd /export/server/apache-hive-3.1.2-bin/lib
    

    mysql-connector-java-5.1.32.jar

  4. 初始化元数据(listenwind102)

    cd /export/server/apache-hive-3.1.2-bin/
    bin/schematool -initSchema -dbType mysql -verbos
    
  5. 在hdfs创建hive存储目录(listenwind102)

    hadoop fs -mkdir /tmp
    hadoop fs -mkdir -p /user/hive/warehouse
    hadoop fs -chmod g+w /tmp
    hadoop fs -chmod g+w /user/hive/warehouse
    
  6. 配置环境变量(listenwind102)

    vim /etc/profile
    
    # 新加入的代码
    export HIVE_HOME=/export/server/apache-hive-3.1.2-bin
    export PATH=$PATH:$HIVE_HOME/bin:$HIVE_HOME/sbin
    
  7. 分发环境变量(listenwind102)

    scp /etc/profile listenwind103:/etc/profile
    scp /etc/profile listenwind104:/etc/profile
    
  8. 分发Hive文件(listenwind102)

    scp -r /export/server/apache-hive-3.1.2-bin listenwind103:/export/server/apache-hive-3.1.2-bin
    scp -r /export/server/apache-hive-3.1.2-bin listenwind104:/export/server/apache-hive-3.1.2-bin
    
  9. 重置环境变量(listenwind102listenwind103listenwind104)

    source /etc/profile
    
三、启动Hive
  1. 三种启动方式

    #前台启动  关闭ctrl+c
    /export/server/apache-hive-3.1.2-bin/bin/hive --service metastore
    
    #前台启动开启debug日志
    /export/server/apache-hive-3.1.2-bin/bin/hive --service metastore --hiveconf hive.root.logger=DEBUG,console  
    
    #后台启动 进程挂起  关闭使用jps+ kill -9
    nohup /export/server/apache-hive-3.1.2-bin/bin/hive --service metastore &
    
  2. 启动hiveserver2服务

     nohup /export/server/apache-hive-3.1.2-bin/bin/hive --service hiveserver2 &
    
      #注意 启动hiveserver2需要一定的时间  不要启动之后立即beeline连接 可能连接不上
    
  3. beeline客户端连接

    # 拷贝node1安装包到beeline客户端机器上(listenwind104)
    scp -r /export/server/apache-hive-3.1.2-bin/ listenwind104:/export/server/
    
  4. 连接访问

    /export/server/apache-hive-3.1.2-bin/bin/beeline
    
    beeline> ! connect jdbc:hive2://listenwind102:10000
    beeline> root
    beeline> 直接回车
    
转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/329694.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号