知识点
相关文章
更多最近更新
更多Hadoop 本地文件复制到hdfs目录
2019-03-28 13:28|来源: 网络
Hadoop 本地文件复制到hdfs目录
- public static void main(String[] args) throws Exception {
- String localSrc = "/home/ganliang/test_fileCopyWithProgress.txt";//本地文件
- String dst = "hdfs://localhost:9000/user/ganliang/hadoop_in/test_fileCopyWithProgress.txt";//复制到hdfs目录下
- InputStream in = new BufferedInputStream(new FileInputStream(localSrc));
- Configuration conf = new Configuration();
- FileSystem fs = FileSystem.get(URI.create(dst), conf);
- OutputStream out = fs.create(new Path(dst), new Progressable() {//进度条信息
- public void progress() {
- System.out.print(".");
- }
- });
- IOUtils.copyBytes(in, out, 4096, true);//复制
- }
相关问答
更多-
关于hadoop的问题,进来看看呀[2023-07-31]
java是执行文件,不是目录 java path默认是java_home/bin/目录 这个目录底下应该 java和javac等文件 -
hadoop hdfs目录[2022-03-28]
移动目录的命令很简单啊,跟Linux shell的命令差不多: hdfs dfs -mv 被移动的目录A 目标目录B 直接移动就行,不知道能否解决你的问题。 -
hadoop hdfs的问题[2021-10-30]
最下面那张图里环境变量设置的那一行多了一个$符号 export JAVA_HOME=/usr/java/jdk1.6.0_35 -
在Amazon Aws EC2上复制到HDFS时出现Hadoop警告和错误(Hadoop warning and error while copying to HDFS on Amazon Aws EC2)[2021-12-27]
在Amazon EC2中创建多节点集群的最佳分步指南之一就是这里 它解释了每一步。 你已经完成了第一部分似乎,通过第二部分,它将帮助你.. 希望它能帮到你...... One of the best step by step guide to create multinode cluster in Amazon EC2 is Here It explains each and every step. You are already done with first part seems, Go through ... -
无法将文件从本地文件系统复制到cloudera上的hadoop / hdfs(Cannot copy files from local file system to hadoop/hdfs on cloudera)[2022-02-12]
问题在于你的本地路径/home/mohammed不可访问,因为用户需要运行整个命令。 由于hdfs的本地linux用户无法进入/home/mohammed ,因此命令会抛出一个No such file or directory error,并因无法找到或读取提供的文件而退出。 在大多数打包的HDFS安装中, hdfs用户通常是分布式文件系统的超级用户,管理命令通常以该用户的身份运行。 但是,在使用hdfs用户为普通用户提供权限和所有权后,可以并且应该以常规用户的身份完成数据处理工作。 对于您的情况,如果此帐 ... -
如何将子目录中的文件复制到HDFS中的单个目录中(How can I copy files in subdirectories to a single directory in HDFS)[2023-11-23]
通配符应该可以解决问题: hdfs dfs -cp /myroot/*/*/*.parq /mynewdir 请注意,如果您不需要原始位置的文件,那么hdfs dfs -mv会快得多。 Wildcards should do the trick: hdfs dfs -cp /myroot/*/*/*.parq /mynewdir Note that if you don't need the files at the original locations then a hdfs dfs -mv will ... -
使用awk删除第一行put其put HDFS: awk 'NR != 1 {print}' file.txt | hdfs dfs -put - hdfs://nn1/user/cloudera Remove the first line using awk and put it to HDFS: awk 'NR != 1 {print}' file.txt | hdfs dfs -put - hdfs://nn1/user/cloudera
-
该列表大概是100-200行,每个文件只有几兆字节。 如果这是一种一次性的情况,那么这还不够大,不用担心。 一个哑的ol'hell loop会很好: cat pairs-file | while read pair; do hdfs dfs -cp $pair; done The list is probably 100-200 lines long each file is a few megabytes. If this a one-off kind of situation, then this i ...
-
如果您编写如上所述的命令,该文件将被复制到用户的HDFS主目录,即/ home / username 。 另请参见: HDFS主目录 。 如果要将文件写入其他位置,则可以像在Linux文件系统中一样使用绝对路径名(以“/”开头)。 If you write the command like above, the file gets copied to your user's HDFS home directory, which is /home/username. See also here: HDFS H ...
-
根据您的输入,您的Hadoop安装似乎工作正常。 有什么问题, hadoop fs -copyFromLocal希望将目录HDFS目录作为目标目录,而不是Hadoop存储其块的本地目录。 所以在你的情况下,命令应该看起来像(例如): sara@ubuntu:/usr/lib/hadoop/hadoop-2.3.0/bin$ hdfs dfs -copyFromLocal /home/sara/Downloads/CA-GrQc.txt /sampleDir/ 其中sampleDir是您使用hadoop ...