Skip to content

Commit 1e8fa6e

Browse files
committed
fixed hive docker
1 parent 6f69f1b commit 1e8fa6e

File tree

8 files changed

+101
-36
lines changed

8 files changed

+101
-36
lines changed

packaging/src/docker/Dockerfile

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,17 @@ RUN tar -xzvf /opt/hadoop-$HADOOP_VERSION.tar.gz -C /opt/ && \
5959

6060
FROM eclipse-temurin:21.0.3_9-jre-ubi9-minimal AS run
6161

62+
ARG UID=1000
6263
ARG HADOOP_VERSION
6364
ARG HIVE_VERSION
6465
ARG TEZ_VERSION
65-
COPY --from=env /opt/hadoop-$HADOOP_VERSION /opt/hadoop
66-
COPY --from=env /opt/apache-hive-$HIVE_VERSION-bin /opt/hive
67-
COPY --from=env /opt/apache-tez-$TEZ_VERSION-bin /opt/tez
6866

6967
# Install dependencies
7068
RUN set -ex; \
7169
microdnf update -y; \
7270
microdnf -y install procps; \
73-
rm -rf /var/lib/apt/lists/*
71+
microdnf clean all; \
72+
useradd --no-create-home -s /sbin/nologin -c "" --uid $UID hive
7473

7574
# Set necessary environment variables.
7675
ENV HADOOP_HOME=/opt/hadoop \
@@ -80,23 +79,21 @@ ENV HADOOP_HOME=/opt/hadoop \
8079

8180
ENV PATH=$HIVE_HOME/bin:$HADOOP_HOME/bin:$PATH
8281

83-
COPY entrypoint.sh /
84-
COPY conf $HIVE_HOME/conf
85-
RUN chmod +x /entrypoint.sh
82+
COPY --from=env --chown=hive /opt/hadoop-$HADOOP_VERSION $HADOOP_HOME
83+
COPY --from=env --chown=hive /opt/apache-hive-$HIVE_VERSION-bin $HIVE_HOME
84+
COPY --from=env --chown=hive /opt/apache-tez-$TEZ_VERSION-bin $TEZ_HOME
8685

86+
COPY --chown=hive entrypoint.sh /
87+
COPY --chown=hive conf $HIVE_HOME/conf
8788

88-
ARG UID=1000
89-
RUN useradd --no-create-home -s /sbin/nologin -c "" --uid $UID hive && \
90-
chown hive /opt/tez && \
91-
chown hive /opt/hive && \
92-
chown hive /opt/hadoop && \
93-
chown hive /opt/hive/conf && \
94-
mkdir -p /opt/hive/data/warehouse && \
95-
chown hive /opt/hive/data/warehouse && \
89+
RUN chmod +x /entrypoint.sh && \
90+
mkdir -p $HIVE_HOME/data/warehouse && \
91+
chown hive $HIVE_HOME/data/warehouse && \
9692
mkdir -p /home/hive/.beeline && \
9793
chown hive /home/hive/.beeline
9894

9995
USER hive
10096
WORKDIR /opt/hive
10197
EXPOSE 10000 10002 9083
98+
10299
ENTRYPOINT ["sh", "-c", "/entrypoint.sh"]
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Licensed to the Apache Software Foundation (ASF) under one or more
4+
contributor license agreements. See the NOTICE file distributed with
5+
this work for additional information regarding copyright ownership.
6+
The ASF licenses this file to You under the Apache License, Version 2.0
7+
(the "License"); you may not use this file except in compliance with
8+
the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
-->
18+
<configuration>
19+
<!--
20+
<property>
21+
<name>fs.s3a.endpoint</name>
22+
<value>s3.us-west-2.amazonaws.com</value>
23+
</property>
24+
<property>
25+
<name>fs.s3a.access.key</name>
26+
<value>YOUR_AWS_ACCESS_KEY</value>
27+
</property>
28+
<property>
29+
<name>fs.s3a.secret.key</name>
30+
<value>YOUR_AWS_SECRET_KEY</value>
31+
</property>
32+
-->
33+
</configuration>

packaging/src/docker/docker-compose.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ services:
4040
container_name: metastore
4141
hostname: metastore
4242
environment:
43+
HADOOP_CLASSPATH: /opt/hadoop/share/hadoop/tools/lib/*
4344
DB_DRIVER: postgres
4445
SERVICE_NAME: 'metastore'
4546
SERVICE_OPTS: '-Xmx1G -Djavax.jdo.option.ConnectionDriverName=org.postgresql.Driver
@@ -53,6 +54,8 @@ services:
5354
- type: bind
5455
source: ${POSTGRES_LOCAL_PATH}
5556
target: /opt/hive/lib/postgres.jar
57+
# Mount local jars to a temporary staging area (Read-Only)
58+
- ./jars:/tmp/ext-jars:ro
5659
networks:
5760
- hive
5861

@@ -63,6 +66,7 @@ services:
6366
restart: unless-stopped
6467
container_name: hiveserver2
6568
environment:
69+
HADOOP_CLASSPATH: /opt/hadoop/share/hadoop/tools/lib/*
6670
HIVE_SERVER2_THRIFT_PORT: 10000
6771
SERVICE_OPTS: '-Xmx1G -Dhive.metastore.uris=thrift://metastore:9083'
6872
IS_RESUME: 'true'
@@ -72,6 +76,8 @@ services:
7276
- '10002:10002'
7377
volumes:
7478
- warehouse:/opt/hive/data/warehouse
79+
# Mount local jars to a temporary staging area (Read-Only)
80+
- ./jars:/tmp/ext-jars:ro
7581
networks:
7682
- hive
7783

packaging/src/docker/entrypoint.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,21 @@
1919

2020
set -x
2121

22+
# =========================================================================
23+
# DYNAMIC JAR LOADER (AWS/S3 Support)
24+
# =========================================================================
25+
STAGING_DIR="/tmp/ext-jars"
26+
27+
# Checks if /tmp/ext-jars is mounted (via Docker volume).
28+
if [ -d "$STAGING_DIR" ]; then
29+
if ls "$STAGING_DIR"/*.jar 1> /dev/null 2>&1; then
30+
echo "--> Copying custom jars from volume to Hive..."
31+
cp -vf "$STAGING_DIR"/*.jar "${HIVE_HOME}/lib/"
32+
else
33+
echo "--> Volume mounted at $STAGING_DIR, but no jars found."
34+
fi
35+
fi
36+
2237
: "${DB_DRIVER:=derby}"
2338

2439
SKIP_SCHEMA_INIT="${IS_RESUME:-false}"
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
Licensed to the Apache Software Foundation (ASF) under one or more
4+
contributor license agreements. See the NOTICE file distributed with
5+
this work for additional information regarding copyright ownership.
6+
The ASF licenses this file to You under the Apache License, Version 2.0
7+
(the "License"); you may not use this file except in compliance with
8+
the License. You may obtain a copy of the License at
9+
10+
http://www.apache.org/licenses/LICENSE-2.0
11+
12+
Unless required by applicable law or agreed to in writing, software
13+
distributed under the License is distributed on an "AS IS" BASIS,
14+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
See the License for the specific language governing permissions and
16+
limitations under the License.
17+
-->
18+
<configuration>
19+
<!--
20+
<property>
21+
<name>fs.s3a.endpoint</name>
22+
<value>s3.us-west-2.amazonaws.com</value>
23+
</property>
24+
<property>
25+
<name>fs.s3a.access.key</name>
26+
<value>YOUR_AWS_ACCESS_KEY</value>
27+
</property>
28+
<property>
29+
<name>fs.s3a.secret.key</name>
30+
<value>YOUR_AWS_SECRET_KEY</value>
31+
</property>
32+
-->
33+
</configuration>

standalone-metastore/packaging/src/docker/conf/metastore-site.xml

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,4 @@
3232
<name>metastore.catalog.servlet.auth</name>
3333
<value>none</value>
3434
</property>
35-
36-
<!--
37-
<property>
38-
<name>fs.s3a.endpoint</name>
39-
<value>s3.us-west-2.amazonaws.com</value>
40-
</property>
41-
<property>
42-
<name>fs.s3a.access.key</name>
43-
<value>YOUR_AWS_ACCESS_KEY</value>
44-
</property>
45-
<property>
46-
<name>fs.s3a.secret.key</name>
47-
<value>YOUR_AWS_SECRET_KEY</value>
48-
</property>
49-
-->
5035
</configuration>

standalone-metastore/packaging/src/docker/docker-compose.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ services:
4040
container_name: metastore
4141
hostname: metastore
4242
environment:
43+
HADOOP_CLASSPATH: /opt/hadoop/share/hadoop/tools/lib/*
4344
DB_DRIVER: postgres
4445
SERVICE_NAME: 'metastore'
4546
SERVICE_OPTS: '-Xmx1G -Djavax.jdo.option.ConnectionDriverName=org.postgresql.Driver

standalone-metastore/packaging/src/docker/entrypoint.sh

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,11 @@ set -x
2424
# =========================================================================
2525
STAGING_DIR="/tmp/ext-jars"
2626

27-
TOOLS_LIB="${HADOOP_HOME}/share/hadoop/tools/lib"
28-
HIVE_LIB="${HIVE_HOME}/lib/"
29-
3027
# Checks if /tmp/ext-jars is mounted (via Docker volume).
3128
if [ -d "$STAGING_DIR" ]; then
3229
if ls "$STAGING_DIR"/*.jar 1> /dev/null 2>&1; then
3330
echo "--> Copying custom jars from volume to Hive..."
34-
cp -vf "$STAGING_DIR"/*.jar "$HIVE_LIB/"
31+
cp -vf "$STAGING_DIR"/*.jar "${HIVE_HOME}/lib/"
3532
else
3633
echo "--> Volume mounted at $STAGING_DIR, but no jars found."
3734
fi
@@ -74,6 +71,4 @@ if [[ "${SKIP_SCHEMA_INIT}" == "false" ]]; then
7471
fi
7572

7673
export METASTORE_PORT=${METASTORE_PORT:-9083}
77-
78-
echo "Starting Hive Metastore on port $METASTORE_PORT..."
7974
exec "$HIVE_HOME/bin/start-metastore"

0 commit comments

Comments
 (0)