Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/amazon-web-services/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Amazon web services DynamoDB导出为gzip JSON_Amazon Web Services_Amazon S3_Hive_Amazon Dynamodb_Amazon Data Pipeline - Fatal编程技术网

Amazon web services DynamoDB导出为gzip JSON

Amazon web services DynamoDB导出为gzip JSON,amazon-web-services,amazon-s3,hive,amazon-dynamodb,amazon-data-pipeline,Amazon Web Services,Amazon S3,Hive,Amazon Dynamodb,Amazon Data Pipeline,我使用AWS数据管道导出了一个DynamoDB表,其中DataNodes>S3BackupLocation>压缩设置为GZIP。我希望压缩输出带有.gz扩展名,但我得到的是没有扩展名的未压缩输出 显示压缩字段“仅支持与Amazon红移一起使用,以及与CopyActivity一起使用S3DataNode时使用。” 如何将DynamoDB表的gzip备份到S3中?我必须下载所有的文件,压缩它们,然后上传它们吗?有没有办法让管道与CopyActivity一起工作?有更好的方法吗 我一直在尝试使用配置单

我使用AWS数据管道导出了一个DynamoDB表,其中DataNodes>S3BackupLocation>压缩设置为
GZIP
。我希望压缩输出带有
.gz
扩展名,但我得到的是没有扩展名的未压缩输出

显示压缩字段“仅支持与Amazon红移一起使用,以及与CopyActivity一起使用S3DataNode时使用。”

如何将DynamoDB表的gzip备份到S3中?我必须下载所有的文件,压缩它们,然后上传它们吗?有没有办法让管道与CopyActivity一起工作?有更好的方法吗

我一直在尝试使用配置单元进行导出,但是我还没有找到一种在输出上正确设置格式的方法。它需要与下面的格式匹配,以便EMR作业可以将其与其他来源的数据一起读取

{"col1":{"n":"596487.0550532"},"col2":{"s":"xxxx-xxxx-xxxx"},"col3":{"s":"xxxx-xxxx-xxxx"}}
{"col1":{"n":"234573.7390354"},"col2":{"s":"xxxx-xxxx-xxxx"},"col3":{"s":"xxxx-xxxxx-xx"}}
{"col2":{"s":"xxxx-xxxx-xxxx"},"col1":{"n":"6765424.7390354"},"col3":{"s":"xxxx-xxxxx-xx"}}

我也一直在寻找如何做到这一点。这是一个如此基本的请求,以至于我很惊讶它不是基本数据管道工作流的一部分

经过几天的调查和实验,我发现了两种机制:

1) 使用ShellCommandActivity启动两个aws cli命令(s3 cp、gzip),从s3、gzip本地下载,然后重新上载到s3。以下是相关部分:

{
    "name": "CliActivity",
    "id": "CliActivity",
    "runsOn": {
        "ref": "Ec2Instance"
    },
    "type": "ShellCommandActivity",
    "command": "(sudo yum -y update aws-cli) && (#{myCopyS3ToLocal}) && (#{myGzip}) && (#{myCopyLocalToS3})"
},

"values": {
    "myCopyS3ToLocal": "aws s3 cp s3://your-bucket/your-folders/ --recursive",
    "myGzip": "for file in /tmp/random-date/*; do gzip \"$file\"; done",
    "myCopyLocalToS3": "aws s3 cp /tmp/random-date s3://your-bucket/your-folders-gz/ --recursive"
}
2) 创建一个单独的EMR集群,然后创建一个使用该EMR集群运行S3DistCp(S3DistCp)的数据管道

在两者之间,我喜欢第二个,因为s3distcp可以自动删除源s3文件。但是,它需要一个单独的EMR集群来运行(成本更高)。或者,您可以在#1中添加其他步骤来执行删除操作

此外,如果要参数化,可能需要直接内联这些值,以便可以利用#{format(@scheduledstartime,'YYYY-MM-dd_hh.MM')}之类的功能

{
    "name": "CliActivity",
    "id": "CliActivity",
    "runsOn": {
        "ref": "Ec2Instance"
    },
    "type": "ShellCommandActivity",
    "command": "(sudo yum -y update aws-cli) && (#{myAWSCLICmd})"
},

"values": {
    "myAWSCLICmd": "aws emr add-steps --cluster-id j-XXXXYYYYZZZZ --region us-east-1 --steps Name=\"S3DistCp command runner\",Jar=\"command-runner.jar\",Args=[\"s3-dist-cp\",\"--s3Endpoint=s3.amazonaws.com\",\"--src=s3://your-bucket/your-folders/\",\"--dest=s3://your-bucket/your-folders-gz/\",\"--outputCodec=gz\"]"
}