代码之家  ›  专栏  ›  技术社区  ›  dreddy

使用hadoop dist cp命令的Dataproc上的s3 dist cp groupby等价物

  •  0
  • dreddy  · 技术社区  · 6 年前

    在急诊室,我用的是 s3-dist-cp --groupBy 以随机命名文件 fileName 在我想在S3中将其重命名为的文件夹中:

    s3-dist-cp --groupBy='.*(folder_in_hdfs).*' --src=hdfs:///user/testUser/tmp-location/folder_in_hdfs --dest=s3://testLocation/folder_in_s3
    

    例子:

    hadoop fs -ls hdfs:///user/testUser/tmp-location/folder_in_hdfs
    Found 2 items
    -rw-r--r--   1 hadoop hadoop          0 2019-04-05 14:54 hdfs:///user/testUser/tmp-location/folder_in_hdfs/file.csv/_SUCCESS
    -rw-r--r--   1 hadoop hadoop     493077 2019-04-05 14:54 hdfs:///user/testUser/tmp-location/folder_in_hdfs/file.csv/part-00000-12db8851-31be-4b08-8a93-1887e534941d-c000.csv
    

    aws s3 ls s3://testLocation/folder_in_s3/
    s3://testLocation/folder_in_s3/file.csv
    

    但是,我希望在Dataproc上使用 hadoop distcp 命令并将文件写入GCS位置 gs://testLocation/folder_in_gs/file.csv

    0 回复  |  直到 6 年前
        1
  •  1
  •   Igor Dvorzhak    6 年前

    Dataproc在DistCp中没有这样的功能。

    也就是说,使用使用 gsutil compose ,运行DistCp之后:

    DESTINATION=gs://bucket/path/to/destination/file
    FILES=($(gsutil ls gs://testLocation/**folder_in_gs**))
    gsutil compose "${FILES[@]::32}" "${DESTINATION}"
    echo "${FILES[@]:32}"| xargs -n 1 | xargs -i gsutil compose "${DESTINATION}" {} "${DESTINATION}"
    gsutil -m rm gs://testLocation/**folder_in_gs**