Support Questions
Find answers, ask questions, and share your expertise

How to speed up "hdfs dfs -mv" for more than 30 000 files ?

Hello,

I've got 30 thousand of files to move to another hdfs directory.

Do you know a better way than "hdfs dfs -mv /mydirectory/* /targetdirectory" to go faster ?

Average size of a file : 10 Kb.

And I can't merge the files in a bigger one before.

Thanks for your feedback

1 ACCEPTED SOLUTION

@Thierry Vernhet,

If there are less files in /targetdirectory than the /mydirectory , you can do the below

hdfs dfs -mv /targetdirectory /x
hdfs dfs -mv /mydirectory /targetdirectory
hdfs dfs -mv /x/* /targetdirectory

Thanks,

Aditya

View solution in original post

7 REPLIES 7

1. dfs -mv is the fastest as compare to -cp or distcp .
If possible move mydirectory instead of mydirectory/* into /targetdirectory

Thanks

Not possible because the result is /targetdirectory/mydirectory and I expect all the files moved in path /targetdirectory/*

@Thierry Vernhet,

If there are less files in /targetdirectory than the /mydirectory , you can do the below

hdfs dfs -mv /targetdirectory /x
hdfs dfs -mv /mydirectory /targetdirectory
hdfs dfs -mv /x/* /targetdirectory

Thanks,

Aditya

Thanks but it doesn't work for the same reason.

When you "mv /mydirectory /targetdirectory" the result is always /targetdirectory/mydirectory.

@Thierry Vernhet,

After running the first command targetdirectory will be renamed to x.

So mv /mydirectory /targetdirectory is not /targetdirectory/mydirectory , instead it will just rename mydirectory to targetdirectory since the destination directory doesn't exist.

So, if targetdirectory has less files this is an option.Instead of moving 30k files, you can move less files

Thanks,

Aditya

@Aditya Sirna,

Of course... I'm going to try this.

Thanks

@Thierry Vernhet

If you have more than 10 GB, I'd recommend use distcp instead of using Copy OR Move.

Take a Tour of the Community
Don't have an account?
Your experience may be limited. Sign in to explore more.