Programmatically implement the following specified functions, and use the shell commands provided by Hadoop to accomplish the same tasks:
- Create a file txt in the "/home/hadoop/" directory of the local Linux file system, and enter some words at will.
- View file location locally (ls)
- Display file contents locally
- Use the command to upload "txt" in the local file system to the input directory of the current user directory in HDFS.
- View files in hdfs (-ls)
- Display the content of the file in hdfs
- delete the local txt file and view the directory
- Download the txt to the original local location from hdfs.
- delete txt from hdfs and view directory
mkdir hadoop
cd hadoop
touch test.txt
gedit test.txt
ls -al
gedit test.txt
cd /usr/local/hadoop
#Open hdfs
./bin/hdfs dfs -mkdir /input
./bin/hdfs dfs -put ~/hadoop/test.txt /input
./bin/hdfs dfs -ls /input
./bin/hdfs dfs -cat /input/test.txt
cd ~/hadoop
rm -r test.txt
ls -al
#Enable hdfs
./bin/hdfs dfs -mkdir /input
./bin/hdfs dfs -get /input/test.txt ~/hadoop
./bin/hdfs dfs -rm -r /input/test.txt
./bin/hdfs dfs -ls
screenshot: