Podcast
Questions and Answers
What is the command used to move the input text file to HDFS?
What is the command used to move the input text file to HDFS?
What should be checked before running the WordCount example?
What should be checked before running the WordCount example?
Which command will correctly list the content of a directory in HDFS?
Which command will correctly list the content of a directory in HDFS?
What will the output of the command 'hdfs dfs -cat /user/cloudera/input/wordcount.txt' display?
What will the output of the command 'hdfs dfs -cat /user/cloudera/input/wordcount.txt' display?
Signup and view all the answers
Which component is used to illustrate how MapReduce works?
Which component is used to illustrate how MapReduce works?
Signup and view all the answers
What does the 'found' command output when checking the contents of the input directory?
What does the 'found' command output when checking the contents of the input directory?
Signup and view all the answers
Where are the example programs located on the Cloudera Quickstart VM?
Where are the example programs located on the Cloudera Quickstart VM?
Signup and view all the answers
What happens if the command 'ls /user' is executed in the local filesystem?
What happens if the command 'ls /user' is executed in the local filesystem?
Signup and view all the answers
What is the primary purpose of the WordCount example in MapReduce?
What is the primary purpose of the WordCount example in MapReduce?
Signup and view all the answers
What command is used to create a new directory in HDFS?
What command is used to create a new directory in HDFS?
Signup and view all the answers
Which command would correctly check the running status of the YARN service before executing the WordCount example?
Which command would correctly check the running status of the YARN service before executing the WordCount example?
Signup and view all the answers
What would be the result of attempting to access the directory '/user' in the local filesystem?
What would be the result of attempting to access the directory '/user' in the local filesystem?
Signup and view all the answers
What is the command format to display the contents of a file in HDFS while paging through it?
What is the command format to display the contents of a file in HDFS while paging through it?
Signup and view all the answers
What should be included in the command to run the WordCount example from the Hadoop jar file?
What should be included in the command to run the WordCount example from the Hadoop jar file?
Signup and view all the answers
In the context of integrating HDFS and local filesystem, what unique characteristic does the 'ls' command have?
In the context of integrating HDFS and local filesystem, what unique characteristic does the 'ls' command have?
Signup and view all the answers
Study Notes
Working with HDFS
- To run the
WordCount
example, it is first necessary to create an input file in the local file system and then move it to HDFS. - The command
echo “This is a hadoop tutorial test" > wordcount.txt
creates a test filewordcount.txt
in the local file system. - To move the file to HDFS, we can use the
hdfs dfs
command with the-put
subcommand. The command will move the file to the specified location in HDFS. - Example command:
hdfs dfs -put /home/cloudera/temp/wordcount.txt /user/cloudera/input
- Use the 'ls' command to list the content in HDFS.
- Example command:
hdfs dfs -ls /user/cloudera/input
-
hdfs dfs -cat /user/cloudera/input/wordcount.txt
is a command to view the content of a file in HDFS. - The
hdfs dfs -cat wc-out/* | more
command can be used to view the content of a large file by piping the output of the-cat
subcommand through the local shell’smore
command.
Running WordCount Example
- The
WordCount
example is a common illustration of how MapReduce works. - It returns a list of words present in the input file along with their frequency.
- The example programs can be found in the jar file
hadoop-mapreduce-examples.jar
on the Cloudera Quickstart VM. - Running the jar file without any arguments will show a list of available examples.
- To run the
WordCount
example with the input file from HDFS: - Ensure that the YARN (MR2) service is running (check in Cloudera Manager).
- Execute the
WordCount
example with the jar file and specify the input and output paths for the job. - The output will show each word found and its count, line by line.
Working in HDFS
- To create input text files for Hadoop, first create a file on your local file system using the
echo
command and redirecting the output to a file. - Then, move the text file to HDFS using the
hdfs dfs -put
command. - The
hdfs dfs -ls
command lists files and directories in HDFS. - The
hdfs dfs -cat
command displays the content of a file on HDFS. - To view only the first or last parts of a large file in HDFS, use the
more
ortail
commands, piped withhdfs dfs -cat
.
Running the WordCount Example
- The WordCount example counts the frequency of words in a text file.
- This is a popular example to illustrate the MapReduce framework.
- On the Cloudera Quickstart VM, the WordCount example is located in the
hadoop-mapreduce-examples.jar
file. - To run the WordCount example, use the following command:
hadoop jar hadoop-mapreduce-examples.jar wordcount /user/cloudera/input /user/cloudera/output
- Make sure the YARN (MR2) service is running before executing the command.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Related Documents
Description
This quiz covers the essential commands for working with HDFS, specifically for running the WordCount example. You will learn how to create an input file, transfer it to HDFS, and explore the contents using various HDFS commands.