When running a Hadoop program, the output directory specified by the program (such as output) cannot be present to prevent overwriting the result, otherwise an error is prompted, so the output directory needs to be deleted before running. When you actually develop your application, consider adding the following code to your program to automatically delete the output directory each time you run it, avoiding tedious command-line operations:
Configuration conf = new Configuration();
Job job = new Job(conf);
/* 删除输出目录 */
Path outputPath = new Path(args[1]);
outputPath.getFileSystem(conf).delete(outputPath, true);
To turn off Hadoop, run the
./sbin/stop-dfs.sh
Attention
The next time you start Hadoop, you don't need to do NameNode initialization, just run ./sbin/start-dfs.sh
!
From for notes (Wiz)
Hadoop configuration (4)--Automatically delete output directories on each run