Which among the following command is used to copy a directory from one node to another in HDFS?

rcp
distcp
dcp
drcp

The correct answer is: C. dcp

  • rcp is a command-line utility for copying files and directories between hosts on a local network. It is not specific to HDFS.
  • distcp is a command-line utility for copying large amounts of data between clusters in Hadoop. It is not specific to copying directories.
  • dcp is a command-line utility for copying data between HDFS clusters. It can be used to copy directories, files, or a combination of both.
  • drcp is not a valid command.

dcp is a more recent command than distcp and offers a number of advantages, including:

  • It is more efficient, as it uses multiple threads to copy data.
  • It is more reliable, as it can resume a copy that has been interrupted.
  • It is more secure, as it supports encryption.

To use dcp, you must first install it on the source and destination clusters. You can then use the following command to copy a directory from one cluster to another:

dcp -r source_directory destination_directory

For example, to copy the directory /data/foo from the cluster h1 to the cluster h2, you would use the following command:

dcp -r /data/foo h1:/data/foo

dcp can also be used to copy files. To do this, you would use the following command:

dcp source_file destination_file

For example, to copy the file /data/bar from the cluster h1 to the cluster h2, you would use the following command:

dcp /data/bar h1:/data/bar

dcp is a powerful tool that can be used to copy data between HDFS clusters. It is more efficient, reliable, and secure than distcp.

Exit mobile version