2

Is there any way to append to a file on HDFS from command line like copying file:

hadoop fs -copyFromLocal <localsrc> URI

2 Answers 2

5

This feature is implemented in Hadoop 2.3.0 as appendToFile with a syntax like:

hdfs dfs -appendToFile localfile /user/hadoop/hadoopfile

(it was first suggested in 2009 when the HDFS Append feature was being contemplated: https://issues.apache.org/jira/browse/HADOOP-6239 )

Sign up to request clarification or add additional context in comments.

Comments

1

cli doesn't support append, but httpfs and fuse both has support for appending files.

w301% ls -lA
total 0
-rw-r--r-- 1 hdfs supergroup 0 Nov 14 01:02 test.me
w301% cat test.me
w301% sync
w301% cat test.me
hello
w301% echo "more rows" >> test.me
w301% sync
w301% cat test.me 
hello
more rows

EDIT: but keep in mind, that only one client can append to file.

3 Comments

Do you know any reference to clear instructions to set up httpfs or fuse and try out append, I tried httpfs, but I failed.
in case of fuse, you simply open file with append flag (as usual in you favorite language or use >> in shell) and write to file. recent fuse should correctly handle this flag

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.