Skip to content

Commit

Permalink
Some helper docker scripts for easy local distributed hadoop testing
Browse files Browse the repository at this point in the history
  • Loading branch information
jiajunmao committed Feb 6, 2024
1 parent e0f8ea1 commit e0ae69b
Show file tree
Hide file tree
Showing 7 changed files with 146 additions and 0 deletions.
43 changes: 43 additions & 0 deletions dockers/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
# Grabs the hadoop-VERSION-SNAPSHOT.tar.gz from hadoop-dist/target folder and construct a a HDFS docker
# Assume that this script is ran from the dockers folder
FROM eclipse-temurin:11-alpine

# Arguments
ARG VERSION=3.5.0
ARG HADOOP_NAME=hadoop-$VERSION-SNAPSHOT

# Copy over the tar.gz
WORKDIR /opt
COPY ./hadoop-dist/target/$HADOOP_NAME.tar.gz /opt

# Unpack the build artifact
RUN tar -xvf $HADOOP_NAME.tar.gz -C /opt
RUN chmod +x /opt/$HADOOP_NAME/bin/hdfs
RUN mkdir /opt/$HADOOP_NAME/logs
COPY ./dockers/namenode-entrypoint.sh /opt/$HADOOP_NAME/sbin/
RUN chmod +x /opt/$HADOOP_NAME/sbin/namenode-entrypoint.sh

# Create a data directory for HDFS, we will point to this directory in config
RUN mkdir -p /data/dataNode
RUN mkdir -p /data/nameNode

# bash is the preferred shell
RUN apk update
RUN apk add bash openssh sudo

# Configure key based ssh
RUN mkdir ~/.ssh
COPY ./dockers/hadoop-id-rsa /root/.ssh
COPY ./dockers/hadoop-id-rsa.pub /root/.ssh
COPY ./dockers/hadoop-id-rsa.pub /root/.ssh/authorized_keys

# Configure ENV variables
ENV HADOOP_HOME=/opt/$HADOOP_NAME
ENV PATH="$HADOOP_HOME/sbin:$HADOOP_HOME/bin:$PATH"
ENV HDFS_DATANODE_USER=root
ENV HDFS_NAMENODE_USER=root
ENV HDFS_SECONDARYNAMENODE_USER=root

ENV JAVA_HOME=/opt/java/openjdk


6 changes: 6 additions & 0 deletions dockers/core-site.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
<configuration>
<property>
<name>fs.defaultFS</name>
<value>hdfs://namenode:9000</value>
</property>
</configuration>
40 changes: 40 additions & 0 deletions dockers/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# This grabs hadoop-VERSION-snapshot.tar from the hadoop-dist/target directory and create a hadoop docker image
version: '3.3'
name: hadoop-four-nodes
services:
namenode:
image: hdfs-runtime:latest
restart: always
environment:
HDFS_DATANODE_USER: root
ports:
- "9870:9870"
volumes:
- ./core-site.xml:/opt/hadoop-3.5.0-SNAPSHOT/etc/hadoop/core-site.xml
- ./hdfs-site.xml:/opt/hadoop-3.5.0-SNAPSHOT/etc/hadoop/hdfs-site.xml
entrypoint: bash namenode-entrypoint.sh
networks:
- intra

datanode:
image: hdfs-runtime:latest
restart: always
environment:
HDFS_DATANODE_USER: root
volumes:
- ./core-site.xml:/opt/hadoop-3.5.0-SNAPSHOT/etc/hadoop/core-site.xml
- ./hdfs-site.xml:/opt/hadoop-3.5.0-SNAPSHOT/etc/hadoop/hdfs-site.xml
entrypoint: hdfs datanode
networks:
- intra
deploy:
mode: replicated
replicas: 3

networks:
intra:

volumes:
test_volume_1:
test_volume_2:
test_volume_3:
38 changes: 38 additions & 0 deletions dockers/hadoop-id-rsa
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
-----BEGIN OPENSSH PRIVATE KEY-----
b3BlbnNzaC1rZXktdjEAAAAABG5vbmUAAAAEbm9uZQAAAAAAAAABAAABlwAAAAdzc2gtcn
NhAAAAAwEAAQAAAYEA21jLtr+TCNuyrjcpPURaQCM6pcpNJKRkmS3YcZRpdibS55A3KtUr
crSc2NBjXqoMm+N7CUT2T25qLH91eSQnUjTBi2muPXXBf7NfhRTjSXszfi1OxdDNYyy31v
+TkF8DHQBBahdhCCkqbbnUIddTt4p85yuEIxH3BKnMdfw0KbBdvMB4q3pRxbvWfKuWGmar
Sj7dVWDlIR8LePPIYLtpkKlHA5LNOtygXCt7Z63TijHUG7c8ALgJ8RIKWP8dky3fu10ye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bi00MDkwAQIDBAUG
-----END OPENSSH PRIVATE KEY-----
1 change: 1 addition & 0 deletions dockers/hadoop-id-rsa.pub
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDbWMu2v5MI27KuNyk9RFpAIzqlyk0kpGSZLdhxlGl2JtLnkDcq1StytJzY0GNeqgyb43sJRPZPbmosf3V5JCdSNMGLaa49dcF/s1+FFONJezN+LU7F0M1jLLfW/5OQXwMdAEFqF2EIKSptudQh11O3inznK4QjEfcEqcx1/DQpsF28wHirelHFu9Z8q5YaZqtKPt1VYOUhHwt488hgu2mQqUcDks063KBcK3tnrdOKMdQbtzwAuAnxEgpY/x2TLd+7XTJ6jqsrV3xkCJCk9e2Cfh4I8istfKnvdtW5csLcS7Ha7JVFlgMYH3yz/Glwe/NLvReFPN5fOdauzLUucMGK2HmXNMmjBBdLmSOS/HkAED/Bs/rUOm4VB1yo94fVuPRlOyvWIL0N9S+GJJXMLxiwkZsvElPD+kkKXu8PA4a3OPBgwBtNdzedm1BE+SeciNbexFI1PvX2QQuD9FpVY1YBcJL/Q1EHgPA/EhYkmF+NWm9CAo7MWjNRuNDai4Lppnk= aaronmao@Jiajun-4090
16 changes: 16 additions & 0 deletions dockers/hdfs-site.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<configuration>
<property>
<name>dfs.namenode.name.dir</name>
<value>/data/nameNode</value>
</property>

<property>
<name>dfs.datanode.data.dir</name>
<value>/data/dataNode</value>
</property>

<property>
<name>dfs.replication</name>
<value>3</value>
</property>
</configuration>
2 changes: 2 additions & 0 deletions dockers/namenode-entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
hdfs namenode -format -force
hdfs namenode

0 comments on commit e0ae69b

Please sign in to comment.