Hive01_安装部署

2023-12-25 08:30:12
Hive的安装
  • 上传安装包 解压

    tar zxvf apache-hive-3.1.2-bin.tar.gz
    mv apache-hive-3.1.2-bin hive
    
  • 解决Hive与Hadoop之间guava版本差异

    cd /export/software/hive/
    rm -rf lib/guava-19.0.jar
    
    cp cp /export/software/hadoop/hadoop-3.3.0/share/hadoop/common/lib/guava-27.0-jre.jar /export/software/hive/lib
    
  • 修改配置文件

    • hive-env.sh

      cd /export/software/hive/conf
      mv hive-env.sh.template hive-env.sh
      
      vim hive-env.sh
      export HADOOP_HOME=/export/software/hadoop/hadoop-3.3.0
      export HIVE_CONF_DIR=/export/software/hive/conf
      export HIVE_AUX_JARS_PATH=/export/software/hive/lib
      
    • hive-site.xml

      vim hive-site.xml
      
      <configuration>
      <!-- 存储元数据mysql相关配置 -->
      <property>
      	<name>javax.jdo.option.ConnectionURL</name>
      	<value>jdbc:mysql://node1:3306/metastore?createDatabaseIfNotExist=true&amp;useSSL=false&amp;useUnicode=true&amp;characterEncoding=UTF-8</value>
      </property>
      
      <property>
      	<name>javax.jdo.option.ConnectionDriverName</name>
      	<value>com.mysql.jdbc.Driver</value>
      </property>
      
      <property>
      	<name>javax.jdo.option.ConnectionUserName</name>
      	<value>root</value>
      </property>
      
      <property>
      	<name>javax.jdo.option.ConnectionPassword</name>
      	<value>123456</value>
      </property>
      
      <!-- H2S运行绑定host -->
      <property>
          <name>hive.server2.thrift.bind.host</name>
          <value>node1</value>
      </property>
      
      <!-- 远程模式部署metastore metastore地址 -->
      <property>
          <name>hive.metastore.uris</name>
          <value>thrift://node1:9083</value>
      </property>
      
      <!-- 关闭元数据存储授权  --> 
      <property>
          <name>hive.metastore.event.db.notification.api.auth</name>
          <value>false</value>
      </property>     
      <!-- Hive 默认在 HDFS 的工作目录 -->
      <property>
      	<name>hive.metastore.warehouse.dir</name>
      	<value>/user/hive/warehouse</value>
      </property> 
         
      </configuration>
      
      
  • 上传mysql jdbc驱动到hive安装包lib下

    mysql-connector-java-5.1.32.jar
    
  • 初始化元数据

    cd /export/software/hive
    
    bin/schematool -initSchema -dbType mysql -verbos
    #初始化成功会在mysql中创建74张表
    
  • 在hdfs创建hive存储目录(如存在则不用操作)

    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
    

1)启动 Hive

[root@node1 hive]$ bin/hive

2)使用 Hive

hive> show databases;
hive> show tables;
hive> create table test (id int);
hive> insert into test values(1);
hive> select * from test;

文章来源:https://blog.csdn.net/tonyshi1989/article/details/135190503
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。