Sign inSign up

seathegood/hive-metastore

By seathegood

Updated 12 months ago

Lightweight Hive Metastore with PostgreSQL

Image
0

2.4K

seathegood/hive-metastore repository overview

Hive Metastore Docker Image (PostgreSQL Backend)

Docker Cloud Build Status License: MIT CI Publish Docker Pulls GitHub Stars

A minimal, production-ready Docker image for running the Apache Hive Metastore backed by an external PostgreSQL database. Designed for security, observability, and automation in container environments.


Features

  • Uses official Hive release (default: 4.0.1)
  • Minimal base image (eclipse-temurin:21-jdk-alpine)
  • Multi-arch support (via GitHub Actions)
  • Hardened image:
    • Non-root hive user
    • Only essential packages installed
    • File permissions locked down
  • Automatic schema initialization on first run
  • Thrift-based healthcheck support
  • Graceful shutdown handling
  • Environment-driven configuration
  • Supports custom hive-site.xml via volume mount

Usage

Pull from Docker Hub
docker pull seathegood/hive-metastore:latest
Quickstart
docker run -d \
  -e POSTGRES_USER=hive \
  -e POSTGRES_PASSWORD=hivepassword \
  -e METASTORE_DB_HOST=postgres.local \
  -e METASTORE_DB_PORT=5432 \
  -e METASTORE_PORT=9083 \
  -p 9083:9083 \
  seathegood/hive-metastore:latest

This image includes the PostgreSQL JDBC driver and does not require manual copying.


Configuration

Required Environment Variables
VariableDescription
POSTGRES_USERUsername for the metastore DB
POSTGRES_PASSWORDPassword for the metastore DB
METASTORE_DB_HOSTHostname of the PostgreSQL database
METASTORE_DB_PORTPort of the PostgreSQL database (default: 5432)
METASTORE_PORTPort to expose Hive Metastore (default: 9083)

You may optionally set METASTORE_DB_URL to override the full JDBC connection string.


Healthcheck

This image includes a healthcheck that:

  • Verifies TCP port availability on the configured host/port
  • Sends a minimal Thrift ping request to confirm service responsiveness
HEALTHCHECK --interval=30s --timeout=10s --start-period=60s \
  CMD ["/usr/local/bin/healthcheck.sh"]

Logging

Hive Metastore logs are sent to stdout and stderr, making them accessible via:

docker logs <container>

No log files are written to disk by default.


Graceful Shutdown

The container traps SIGTERM and SIGINT to ensure the Hive process shuts down cleanly.


Kubernetes Security Context (Example)

To further harden the container in orchestration environments:

securityContext:
  runAsUser: 999
  readOnlyRootFilesystem: true
  allowPrivilegeEscalation: false

Building Locally

docker build -t hive-metastore:local \
  --build-arg HIVE_VERSION=4.0.1 \
  --build-arg HADOOP_VERSION=3.4.1 \
  .

CI/CD

  • ci.yml: Linting and validation
  • publish.yml: Builds and pushes Docker images on tagged releases
  • check-upstream.yml: Monitors for Hive releases, bumps versions, and creates pull requests/releases

Deployment Examples

Docker Compose
version: '3.8'

services:
  postgres:
    image: postgres:15
    environment:
      POSTGRES_USER: hive
      POSTGRES_PASSWORD: hivepassword
      POSTGRES_DB: metastore_db
    ports:
      - 5432:5432

  hive-metastore:
    image: seathegood/hive-metastore:latest
    depends_on:
      - postgres
    environment:
      POSTGRES_USER: hive
      POSTGRES_PASSWORD: hivepassword
      METASTORE_DB_HOST: postgres
      METASTORE_DB_PORT: 5432
      METASTORE_PORT: 9083
    ports:
      - 9083:9083
    healthcheck:
      test: ["CMD", "/usr/local/bin/healthcheck.sh"]
      interval: 30s
      timeout: 10s
      retries: 3
Kubernetes Deployment (Minimal)
apiVersion: apps/v1
kind: Deployment
metadata:
  name: hive-metastore
spec:
  replicas: 1
  selector:
    matchLabels:
      app: hive-metastore
  template:
    metadata:
      labels:
        app: hive-metastore
    spec:
      containers:
        - name: metastore
          image: seathegood/hive-metastore:latest
          ports:
            - containerPort: 9083
          env:
            - name: POSTGRES_USER
              value: hive
            - name: POSTGRES_PASSWORD
              value: hivepassword
            - name: METASTORE_DB_HOST
              value: postgres.default.svc.cluster.local
            - name: METASTORE_DB_PORT
              value: "5432"
            - name: METASTORE_PORT
              value: "9083"
          readinessProbe:
            exec:
              command: ["/usr/local/bin/healthcheck.sh"]
            initialDelaySeconds: 30
            periodSeconds: 15
---
apiVersion: v1
kind: Service
metadata:
  name: hive-metastore
spec:
  ports:
    - port: 9083
      targetPort: 9083
  selector:
    app: hive-metastore
Helm Values Snippet
hiveMetastore:
  enabled: true
  image:
    repository: seathegood/hive-metastore
    tag: latest
  env:
    POSTGRES_USER: hive
    POSTGRES_PASSWORD: hivepassword
    METASTORE_DB_HOST: postgres
    METASTORE_DB_PORT: 5432
    METASTORE_PORT: 9083
  service:
    type: ClusterIP
    port: 9083

Contributing

We welcome contributions! See CONTRIBUTING.md for details on local setup, testing, and release process.


License

MIT License — see the LICENSE file.

This project includes software distributed under the Apache License 2.0, including Apache Hive and Apache Hadoop. See the LICENSES directory for more details. NOTICE files are also included to meet Apache License 2.0 requirements. See the top-level NOTICE file and licenses/ directory.

For a full list of included components and their licenses, see THIRD_PARTY.md.

Tag summary

Content type

Image

Digest

sha256:e56511fda

Size

502.8 MB

Last updated

12 months ago

docker pull seathegood/hive-metastore