Hive基于PostgreSQL安装与配置

Hive基于PostgreSQL安装与配置

软件依赖与版本号

安装Hive的前提条件是已经部署了Hadoop和PostgreSQL。具体安装Hadoop的方法见前面发的文章Hadoop伪分布式安装,安装PostgreSQL的方法见前面发的文章PostgreSQL学习笔记(一):安装篇。部署软件版本号如下所示:

软件名称 版本号
Hadoop 2.9.2
Hive 2.3.6
PostgreSQL 12.0.0

安装步骤

  • 第一步:下载安装包apache-hive-2.3.6-bin.tar.gz并上传到服务器;

  • 第二步:解压缩后,将安装文件拷贝到/usr/local/目录下。

    tar xzvf apache-hive-2.3.6-bin.tar.gz
    mv apache-hive-2.3.6-bin /usr/local/hive
    
  • 第三步:打开/etc/profile,配置环境变量。

    vi /etc/profile
    

    输入以下内容:

    export HIVE_HOME=/usr/local/hive
    export PATH=$HIVE_HOME/bin:$PATH
    

    保存后生效:

    source /etc/profile
    
  • 第四步:配置PostgreSQL作为元数据库

    • 进入/usr/local/hive/conf/目录,执行如下操作

      cp hive-default.xml.template hive-site.xml
      vi hive-site.xml
      
    • 找到如下内容的name并修改对应的value

      <property>
          <name>javax.jdo.option.ConnectionURL</name>
          <value>jdbc:postgresql://{hostname}:5432/{hivedatabase}?createDatabaseIfNotExist=true</value>
      </property>
      <property>
          <name>javax.jdo.option.ConnectionDriverName</name>
          <value>org.postgresql.Driver</value>
          <description>Driver class name for a JDBC metastore</description>
      </property>
      <property>
          <name>javax.jdo.option.ConnectionPassword</name>
          <value>{hivepassword}</value>
          <description>password to use against metastore database</description>
      </property>
      <property>
          <name>javax.jdo.option.ConnectionUserName</name>
          <value>{hiveusername}</value>
          <description>Username 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>hive.exec.local.scratchdir</name>
          <value>/usr/local/hive/tmp</value>
          <description>Local scratch space for Hive jobs</description>
      </property>
      <property>
          <name>hive.downloaded.resources.dir</name>
          <value>/usr/local/hive/tmp/resources</value>
          <description>Temporary local directory for added resources in the remote file system.</description>
      </property>
      <property>
          <name>hive.querylog.location</name>
          <value>/usr/local/hive/tmp</value>
          <description>Location of Hive run time structured log file</description>
      </property>
      <property>
          <name>hive.server2.logging.operation.log.location</name>
          <value>/usr/local/hive/tmp/operation_logs</value>
          <description>Top level directory where operation logs are stored if logging functionality is enabled</description>
      </property>
      
  • 第五步:使用schematool 初始化metastore的schema

    schematool -dbType postgres -initSchema
    
  • 第六步:启动hive

    # hive
    
发布了45 篇原创文章 · 获赞 69 · 访问量 7万+

猜你喜欢

转载自blog.csdn.net/twypx/article/details/102521498