Foreword:
In Lesson 1, we have successfully installed Hadoop , let's test the function of Hadoop statistical analysis data.
1. Create two files, file1.txt and file2.txt respectively, under /home/sa/file
Contents of file1.txt:
What's your name My name is Li Ming
Contents of file2.txt:
How are you My dear friend
2. After we start Hadoop, create the directory /input2 in the HDFS database
cd ~/hadoop bin/hadoop fs -mkdir /input2
3. Save the file1.txt and file2.txt files to the HDFS database
bin/hadoop fs -put ~/file/file*.txt /input2/
4. Check whether file1.txt and file2.txt already exist in the HDFS database
bin/hadoop fs -ls /input2
5. Run the package command "hadoop jar × × × .jar" and execute the WordCount program to analyze the statistical data
bin/hadoop jar share/hadoop/mapreduce/hadoop-mapreduce-examples-2.6.0.jar wordcount /input2/ /output2/wordcount1
6. After the analysis and statistics are completed, let's view all the results in the output directory:
bin/hadoop fs -cat /output2/wordcount1/*