Files
2025-10-12 23:38:15 +05:30

1.4 KiB

List of Commands

  1. Create a Directory for Your Project:

    mkdir ~/hadoop_char_count
    cd ~/hadoop_char_count
    
  2. Compile the Java Files:

    javac -classpath $(hadoop classpath) -d . CharacterCountMapper.java CharacterCountReducer.java CharacterCountDriver.java
    
  3. Create the JAR File:

    jar cvf CharacterCount.jar *.class
    
  4. Create Input Directory in HDFS (if needed):

    hdfs dfs -mkdir -p /user/hduser/input
    
  5. Upload Input File to HDFS:

    hdfs dfs -put /path/to/your/local/input.txt /user/hduser/input/
    
  6. Run the MapReduce Job:

    hadoop jar CharacterCount.jar CharacterCountDriver /user/hduser/input /user/hduser/output
    
  7. Remove Existing Output Directory (if needed):

    hdfs dfs -rm -r /user/hduser/output
    
  8. List Contents of the Output Directory:

    hdfs dfs -ls /user/hduser/output
    
  9. View the Output File:

    hdfs dfs -cat /user/hduser/output/part-r-00000
    
  10. View Output with more or less:

    hdfs dfs -cat /user/hduser/output/part-r-00000 | more
    

    or

    hdfs dfs -cat /user/hduser/output/part-r-00000 | less
    
  11. Copy Output to Local File System (Optional):

    hdfs dfs -get /user/hduser/output/part-r-00000 /path/to/local/directory/