Introduction
Imagine you are in the ancient empire of Naruda, where Emperor Jason has ordered the relocation of ancient scrolls containing valuable knowledge from one library to another. Your task is to simulate this scenario in the context of Hadoop Distributed File System (HDFS) using the Hadoop FS Shell mv
command. Your goal is to successfully move the scrolls from one directory to another without losing any data.
Move Ancient Scroll
In this step, you will move an ancient scroll named ancient_scroll.txt
from the /documents
directory to the /archives
directory using the Hadoop FS Shell mv
command.
- First, use the
su - hadoop
command to switch to the hadoop user, and then explore theancient_scroll.txt
file in the/documents
directory.
hdfs dfs -ls / hdfs dfs -ls /documents hdfs dfs -cat /documents/ancient_scroll.txt
- Next, move the
ancient_scroll.txt
file to the/archives
directory.
hdfs dfs -mv /documents/ancient_scroll.txt /archives
Here’s an explanation of the command and its components:
hdfs dfs
: This is the prefix of the command that invokes the Hadoop file system client, and is used to perform operations that interact with HDFS.mv
: This parameter specifies that the operation to be performed is move, which is similar to themv
command in Unix/Linux, and can be used to rename a file or move a file from one location to another./documents/ancient_scroll.txt
: This part specifies the HDFS path and name of the source file. It tells Hadoop which file you want to move. In this example, the source file isancient_scroll.txt
located in the/documents
directory of HDFS./archives/
: This part specifies the HDFS path to the destination directory. It tells Hadoop which directory you want to move the source files to. In this example, the target directory is the/archives
directory of HDFS.
Update Scroll Location
In this step, you will update the location of the ancient scroll in the metadata without physically moving the file.
- Check the current location of the
ancient_scroll.txt
file.
hdfs dfs -ls /archives/ancient_scroll.txt
- Update the location information of the file to reflect a new path.
hdfs dfs -mv /archives/ancient_scroll.txt /library/archives/ancient_scroll.txt
Summary
In this lab, the focus was on practicing the Hadoop FS Shell mv
command within the HDFS environment. By simulating the movement of ancient scrolls in a fictional empire setting, users can grasp the concept of transferring files in Hadoop effectively. The step-by-step guidance ensures that learners can understand the process clearly and apply the knowledge gained in similar scenarios.
Want to learn more?
- 🚀 Practice Hadoop FS Shell mv
- 🌳 Learn the latest Hadoop Skill Trees
- 📖 Read More Hadoop Tutorials
Join our Discord or tweet us @WeAreLabEx ! 😄