Calvin (Deutschbein)
Week 03
Cloud
mkdir running-hadoop
cd running-hadoop
git clone https://github.com/wxw-matt/docker-hadoop.git
cd docker-hadoop
docker run hello-world
mv docker-compose.yml docker-compose-v1.yml
mv docker-compose-v3.yml docker-compose.yml
docker-compose up -d
I used "docker ps" to list the nodes, then picked the one with name in it. For me:
CONTAINER ID IMAGE NAMES
aadf77229476 bde2020/hadoop-namenode:2.0.0-hadoop3.2.1-java8 namenode
e7ebe649b320 bde2020/hadoop-resourcemanager:2.0.0-hadoop3.2.1-java8 resourcemanager
4ece65b07145 bde2020/hadoop-datanode:2.0.0-hadoop3.2.1-java8 datanode
65ce5597dde4 bde2020/hadoop-historyserver:2.0.0-hadoop3.2.1-java8 historyserver
9d289fd85a48 bde2020/hadoop-nodemanager:2.0.0-hadoop3.2.1-java8 nodemanager
So I used:
docker exec -it namenode /bin/bash
I also tested `hello world` here:
echo hello world
mkdir app
mkdir app/data
mkdir app/res
mkdir app/jars
echo hi > /app/data/hi.txt
cd /app/data
curl https://raw.githubusercontent.com/cd-public/books/main/pg1342.txt -o austen.txt
curl https://raw.githubusercontent.com/cd-public/books/main/pg84.txt -o shelley.txt
curl https://raw.githubusercontent.com/cd-public/books/main/pg768.txt -o bronte.txt
ls -al
I got:
total 1884
drwxr-xr-x 2 root root 4096 May 28 19:42 .
drwxr-xr-x 5 root root 4096 May 28 19:38 ..
-rw-r--r-- 1 root root 772420 May 28 19:41 austen.txt
-rw-r--r-- 1 root root 693877 May 28 19:42 bronte.txt
-rw-r--r-- 1 root root 448937 May 28 19:42 shelley.txt
docker cp .\jobs\jars\WordCount.jar namenode:/app/jars/WordCount.jar
cd /app/jars
curl https://github.com/wxw-matt/docker-hadoop/blob/master/jobs/jars/WordCount.jar -o WordCounter.jar
cd /
hdfs dfs -mkdir /test-1-input
hdfs dfs -copyFromLocal -f /app/data/*.txt /test-1-input/
hadoop jar /app/jars/WordCount.jar WordCount /test-1-input /test-1-output
jar jars/WordCount.jar WordCount
/test-1-input
test_in <- c(austen,shelley,bronte) # imagine these are already defined
test_out = lapply(test_in, wordcount) # imagine wordcount is already defined
hdfs dfs -copyToLocal /test-1-output /app/res/
head /app/res/test-1-output/part-r-00000
#1342] 1
#768] 1
#84] 1
$5,000) 3
& 1
($1 3
(801) 3
(By 1
(Godwin) 1
(He 1