본문 바로가기

hdfs

[hdfs] webhdfs httpfs api (file put/get)

hdfs command

$ hadoop fs -put /localfile /hdfsdir/hdfsfilename

$ hadoop fs -get /hdfsfilename /localdir/localfile 

 

webhdfs api command

curl -i "http://host:14000/webhdfs/v1?op=gethomedirectory&user.name=hive"

curl -i "http://host:14000/webhdfs/v1/user/hive/test.txt?op=open&user.name=hive"

-> return file contents

curl -i -X GET "http://host:14000/webhdfs/v1/user/hive?op=LISTSTATUS&user.name=hive"

-> return /user/hive dir contents

curl -i -X PUT "http://host:14000/webhdfs/v1/user/hive/test1?op=MKDIRS&user.name=hive"

-> make dir 'test1'

 

webhdfs file create

curl -i -X PUT "http://host:14000/webhdfs/v1/user/hive/testdir?op=CREATE&user.name=hive"

curl -i -X PUT -L "http://host:14000/webhdfs/v1/user/hive/testdir?op=CREATE&user.name=hive" -T localfile.txt \

-H "Content-Type:application/octet-stream"

 

webhdfs file append

curl -i -X POST "http://host:14000/webhdfs/v1/user/hive/existfilename?op=APPEND&user.name=hive"

curl -i -X POST "http://host:14000/webhdfs/v1/user/hive/existfilename?op=APPEND&user.name=hive" -T localfile.txt 

-H "Content-Type:application/octet-stream"

'hdfs' 카테고리의 다른 글

[python] get hdfs path info  (0) 2021.12.27