Single Node Cluster Hadoop to perform basic operations using Hadoop MapReduce and HDFS
2.6K
DISCLAMER:
This software is packaged by neshkeev. The respective trademarks mentioned in the offering are owned by the respective companies, and use of them does not imply any affiliation or endorsement.
There is a functional docker-compose.yml file in the repository. Run the application using it as shown below:
curl -sSL https://raw.githubusercontent.com/neshkeev/containers/master/hadoop/examples/simple/docker-compose.yml > docker-compose.yml
docker compose up
The Apache Hadoop software library is a framework that allows for the distributed processing of large data sets across clusters of computers using simple programming models.
The packaging is ideal for demo, testing or teaching purposes, because it contains full-blown Hadoop Distribution inside a single docker image. Client applications can perform basic operations using Hadoop MapReduce and the Hadoop Distributed File System (HDFS).
The docker image can be used to run a Hadoop Cluster on the following architectures:
In order to cofigure a Hadoop cluster there are two options that can be used in combination.
One can mount prepared config files:
core-site.xml -> /opt/hadoop/etc/hadoop/core-site.xmlhdfs-site.xml -> /opt/hadoop/etc/hadoop/hdfs-site.xml,yarn-site.xml -> /opt/hadoop/etc/hadoop/yarn-site.xml,mapred-site.xml -> /opt/hadoop/etc/hadoop/mapred-site.xml,Existing config files can be amended with environment variables.
In order to amend a config properties one needs to construct an environment variable which name matches the following pattern: PREFIX + config.name.
For example, the value for fs.defaultFS should be stored in the CORE-SITE.XML_fs.defaultFS environment variable like this:
CORE-SITE.XML_fs.defaultFS=hdfs://namenode:9000
The prefix is derived from the file the config belongs to. See the examples' docker-compose.yml files for references.
The values from environment variables takes precedence over the mounted config files.
docker-compose.yml:curl -sSL https://raw.githubusercontent.com/neshkeev/containers/master/hadoop/examples/multi-node-cluster/docker-compose.yml > docker-compose.yml
docker compose up
hadoop docker compose service:docker compose exec -it hadoop bash
yarn jar share/hadoop/mapreduce/hadoop-mapreduce-examples-*.jar pi 10 15
http://localhost:9870/explorer.htmlhttp://localhost:8088hadoop docker container:exit
docker compose down
Run the grep example that comes with the Hadoop distribution by default:
docker-compose.yml:curl -sSL https://raw.githubusercontent.com/neshkeev/containers/master/hadoop/examples/multi-node-cluster/docker-compose.yml > docker-compose.yml
docker compose up
healthy:docker compose ps
hadoop docker compose service:docker compose exec -it hadoop bash
hdfs dfs -mkdir -p /user/hadoop
hdfs dfs -mkdir -p input
hdfs dfs -put -f /opt/hadoop/etc/hadoop/*.xml input
hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-*.jar grep input output 'dfs[a-z.]+'
http://localhost:9870/explorer.htmlhttp://localhost:8088hdfs dfs -cat output/*
hdfs dfs -get output ~/output
find ~/output
hdfs dfs -rm -r output
resourcemanager docker container:exit
docker compose down
curl -sSL https://raw.githubusercontent.com/neshkeev/containers/master/hadoop/examples/jmx/docker-compose.yml > docker-compose.yml
docker compose up -d
jconsole
localhost:59870localhost:59864localhost:58088localhost:58042localhost:59888Content type
Image
Digest
sha256:669508ca9…
Size
927.1 MB
Last updated
almost 3 years ago
docker pull neshkeev/hadoop