繁体   English   中英

如何将文件从本地笔记本电脑放到远程HDFS?

[英]How put file from local laptop to remote HDFS?

我有Hadoop 2.8.1

配置的hdfs-site.xml

<configuration>
# Add the following inside the configuration tag
<property>
        <name>dfs.data.dir</name>
        <value>/app/dfs/name/data</value>
        <final>true</final>
</property>
<property>
        <name>dfs.name.dir</name>
        <value>/app/dfs/name</value>
        <final>true</final>
</property>
<property>
        <name>dfs.replication</name>
        <value>1</value>
</property>
<property>
    <name>dfs.webhdfs.enabled</name>
    <value>true</value>
</property>
</configuration>

确实通过python找到了这段代码

from pywebhdfs.webhdfs import PyWebHdfsClient
from pprint import pprint

hdfs = PyWebHdfsClient(host='hadoop01',port='50070', user_name='hadoop')  # your Namenode IP & username here

my_data = "01010101010101010101010101010101000111 Example DataSet"
my_file = '/examples/myfile.txt'
hdfs.create_file(my_file, my_data.encode('utf-8'))

此变体有效。 但是我想把已经准备好的文件放到远程HDFS中。

试图写

with open("C:\\Downloads\\Demographic_Statistics_By_Zip_Code.csv") as file_data:
     print(file_data)

BUT文件未放入HDFS。 只返回

<_io.TextIOWrapper name='C:\\Downloads\\Demographic_Statistics_By_Zip_Code.csv' mode='r' encoding='cp1251'>

如何解决这种情况?

如何使用hdfs cli? 请从以下链接参考copyFromLocal或put命令:

https://hadoop.apache.org/docs/r2.8.0/hadoop-project-dist/hadoop-common/FileSystemShell.html

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM