metdos
metdos

Reputation: 13939

HDFS Command Line Append

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

hadoop fs -copyFromLocal <localsrc> URI

Upvotes: 2

Views: 8330

Answers (2)

metdos
metdos

Reputation: 13939

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 )

Upvotes: 5

octo
octo

Reputation: 665

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.

Upvotes: 1

Related Questions