1.4 KiB
1.4 KiB
List of Commands
-
Create a Directory for Your Project:
mkdir ~/hadoop_char_count cd ~/hadoop_char_count -
Compile the Java Files:
javac -classpath $(hadoop classpath) -d . CharacterCountMapper.java CharacterCountReducer.java CharacterCountDriver.java -
Create the JAR File:
jar cvf CharacterCount.jar *.class -
Create Input Directory in HDFS (if needed):
hdfs dfs -mkdir -p /user/hduser/input -
Upload Input File to HDFS:
hdfs dfs -put /path/to/your/local/input.txt /user/hduser/input/ -
Run the MapReduce Job:
hadoop jar CharacterCount.jar CharacterCountDriver /user/hduser/input /user/hduser/output -
Remove Existing Output Directory (if needed):
hdfs dfs -rm -r /user/hduser/output -
List Contents of the Output Directory:
hdfs dfs -ls /user/hduser/output -
View the Output File:
hdfs dfs -cat /user/hduser/output/part-r-00000 -
View Output with
moreorless:hdfs dfs -cat /user/hduser/output/part-r-00000 | moreor
hdfs dfs -cat /user/hduser/output/part-r-00000 | less -
Copy Output to Local File System (Optional):
hdfs dfs -get /user/hduser/output/part-r-00000 /path/to/local/directory/