Hive01_安装部署

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>
      
      <property>
      	<name>javax.jdo.option.ConnectionURLname>
      	<value>jdbc:mysql://node1:3306/metastore?createDatabaseIfNotExist=true&useSSL=false&useUnicode=true&characterEncoding=UTF-8value>
      property>
      
      <property>
      	<name>javax.jdo.option.ConnectionDriverNamename>
      	<value>com.mysql.jdbc.Drivervalue>
      property>
      
      <property>
      	<name>javax.jdo.option.ConnectionUserNamename>
      	<value>rootvalue>
      property>
      
      <property>
      	<name>javax.jdo.option.ConnectionPasswordname>
      	<value>123456value>
      property>
      
      
      <property>
          <name>hive.server2.thrift.bind.hostname>
          <value>node1value>
      property>
      
      
      <property>
          <name>hive.metastore.urisname>
          <value>thrift://node1:9083value>
      property>
      
       
      <property>
          <name>hive.metastore.event.db.notification.api.authname>
          <value>falsevalue>
      property>     
      
      <property>
      	<name>hive.metastore.warehouse.dirname>
      	<value>/user/hive/warehousevalue>
      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

# 启动metastore服务
[root@node1 hive]$ bin/hive --service metastore &
[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;

你可能感兴趣的:(hive,hive)