1 Local Mode

Local mode is the simplest mode, where all modules run in a JVM process and use a local file system instead of HDFS.

The local mode is mainly used for running and debugging during local development. The downloaded Hadoop does not need to be set to the local mode by default.

2 Preparations

Make sure JAVA_HOME is set to /etc/hadoop/hadoop-env.sh before you run it.

tar -zxvf openjdk-11+28_linux-x64_bin.tar.gz
sudo mv openjdk-11+28_linux-x64_bin /usr/local/java
sudo vim HADOOP/etc/hadoop/hadoop-env.sh # HADOOP indicates the HADOOP installation directory
# enter
export JAVA_HOME=/usr/local/java
Copy the code

3 the use of

There is not much description of this pattern on the official website, except for a simple example of using a default configuration file as input and matching a regular expression as output:

# HADOOP indicates the HADOOP installation directorymkdir input cp HADOOP/etc/hadoop/*.xml input HADOOP/bin/hadoop jar HADOOP/share/HADOOP/graphs/HADOOP - graphs - examples - 3.3.0. Jar grep input output'dfs[a-z.]+'
cat output/*
Copy the code

You can see from the id below that it works in local mode:

4 the output

The output folder output has two files:

  • _SUCCESS: Is an empty file, indicating that the file is successfully run
  • part-r-00000: Output result file, word count statistics

The results of part-R-00000 are shown in the figure above.

In fact, local mode does not require special handling because it is local mode by default.

5 reference

  • Hadoop3.3.0 official documentation