Run Apache Hive inside docker container in pseudo-distributed mode
607
Metastore
For a quick start, launch the Metastore with Derby,
docker run -d -p 9083:9083 --env SERVICE_NAME=metastore --name metastore-standalone apachehive/hive:4.0.0-SNAPSHOT
Everything would be lost when the service is down. In order to save the Hive table's schema and data, start the container with an external Postgres and Volume to keep them respectively,
docker run -d -p 9083:9083 --env SERVICE_NAME=metastore \
--env DB_DRIVER=postgres \
--env SERVICE_OPTS="-Djavax.jdo.option.ConnectionDriverName=org.postgresql.Driver -Djavax.jdo.option.ConnectionURL=jdbc:postgresql://postgres:5432/metastore_db -Djavax.jdo.option.ConnectionUserName=hive -Djavax.jdo.option.ConnectionPassword=password" \
--mount source=warehouse,target=/opt/hive/data/warehouse \
--name metastore-standalone apachehive/hive:4.0.0-SNAPSHOT
If you want to use you own hdfs-site.xml or yarn-site.xml for the service, you can provide the environment variable HIVE_CUSTOM_CONF_DIR for the command. For instance, put the custom configuration file under the directory /opt/hive/conf, then run,
docker run -d -p 9083:9083 --env SERVICE_NAME=metastore \
--env DB_DRIVER=postgres -v /opt/hive/conf:/hive_custom_conf --env HIVE_CUSTOM_CONF_DIR=/hive_custom_conf \
--name metastore apachehive/hive:4.0.0-SNAPSHOT
HiveServer2
For a quick start, launch the HiveServer2 with an embedded Metastore,
docker run -d -p 10000:10000 -p 10002:10002 --env SERVICE_NAME=hiveserver2 --name hiveserver2-standalone apachehive/hive:4.0.0-SNAPSHOT
or specify a remote Metastore if it's available,
docker run -d -p 10000:10000 -p 10002:10002 --env SERVICE_NAME=hiveserver2 \
--env SERVICE_OPTS="-Dhive.metastore.uris=thrift://metastore:9083" \
--env IS_RESUME="true" \
--name hiveserver2-standalone apachehive/hive:4.0.0-SNAPSHOT
To save the data between container restarts, you can start the HiveServer2 with a Volume,
docker run -d -p 10000:10000 -p 10002:10002 --env SERVICE_NAME=hiveserver2 \
--env SERVICE_OPTS="-Dhive.metastore.uris=thrift://metastore:9083" \
--mount source=warehouse,target=/opt/hive/data/warehouse \
--env IS_RESUME="true" \
--name hiveserver2 apachehive/hive:4.0.0-SNAPSHOT
Content type
Image
Digest
sha256:74843d718…
Size
933.6 MB
Last updated
about 3 years ago
docker pull apachehive/hive:4.0.0-beta-1-SNAPSHOT