无法使用awscli 1.5.4复制大文件(5 Gb)
我在使用aws-cli的时候遇到了问题。我做了一个yum更新,结果更新了awscli(还有其他东西),现在在处理大文件(比如5.1GB)时出现了SignatureDoesNotMatch的错误。对于同样的命令(对同一个存储桶)来说,小文件是可以正常工作的。
这个大文件在用Python的boto库时是可以正常工作的。
看起来它复制了所有部分,但似乎漏掉了两个部分(也就是说,它已经复制到743个部分,但总共有745个部分),然后就出现了错误信息。
这看起来像是awscli的一个bug?不过我在网上搜索的时候没有找到相关的信息。
这一切都是在一个ec2实例上执行的。
$ /usr/bin/aws --version
aws-cli/1.5.4 Python/2.6.9 Linux/3.14.20-20.44.amzn1.x86_64
$ ls -hl
-rw-rw-r-- 1 user user 4 Nov 4 21:14 small
-rw-rw-r-- 1 user user 5.1G Nov 4 20:02 big
$ /usr/bin/aws s3 cp small s3://mybucket/uploaded.ext
upload: ./small to s3://mybucket/uploaded.ext
$ /usr/bin/aws s3 cp big s3://mybucket/uploaded.ext
upload failed: ./big to s3://mybucket/uploaded.ext
A client error (SignatureDoesNotMatch) occurred when calling the UploadPart operation: The request signature we calculated does not match the signature you provided. Check your key and signing method.
补充:我以为找到了问题,但还是有这个问题。我更希望继续使用awscli,因为我们在代码中到处都在用它,而且它比boto快得多(至少在正常情况下是这样)。
补充2:情况实际上从坏变得更糟了,我可以在控制台重复同样的复制命令,有时候能成功,有时候又不行。
2 个回答
如果说这是aws-cli里的一个bug,我一点也不觉得奇怪。建议你可以试试用s3cmd来复制文件到S3或者从S3复制文件,这样做其他和S3相关的操作也会更方便。
aws-cli这个工具确实可以处理5GB及以上的文件上传。
我启动了一个EC2实例,并成功完成了上传:
$ /usr/bin/aws --version
aws-cli/1.3.6 Python/2.6.9 Linux/3.10.35-43.137.amzn1.x86_64
$ dd if=/dev/zero of=small bs=1K count=1
1+0 records in
1+0 records out
1024 bytes (1.0 kB) copied, 0.000388469 s, 2.6 MB/s
$ dd if=/dev/zero of=big bs=5M count=1000
1000+0 records in
1000+0 records out
5242880000 bytes (5.2 GB) copied, 73.733 s, 71.1 MB/s
$ aws s3 mb s3://target77
make_bucket: s3://target77/
$ aws s3 cp small s3://target77/small
upload: ./small to s3://target77/small
$ aws s3 cp big s3://target77/big
upload: ./big to s3://target77/big
$ aws s3 ls s3://target77/
2014-11-17 09:44:42 5242880000 big
2014-11-17 09:44:29 1024 small
到目前为止,一切顺利!
然后我更新到了一个新版本的CLI,结果又试了一次:
$ sudo yum update
...
$ /usr/bin/aws --version
aws-cli/1.5.5 Python/2.6.9 Linux/3.10.35-43.137.amzn1.x86_64
$ aws s3 cp small s3://target77/small
upload: ./small to s3://target77/small
$ aws s3 cp big s3://target77/big
upload failed: ./big to s3://target77/bigs) remaining
A client error (SignatureDoesNotMatch) occurred when calling the UploadPart operation: The request signature we calculated does not match the signature you provided. Check your key and signing method.
我在同一个区域和不同区域的EC2实例和S3存储桶上重复了这个实验,结果在这两种情况下都出现了错误,但有时也能成功。
所以,看起来这个问题可能是出在更新后的aws-cli上。而且,当我尝试重新执行复制命令时,错误是在随机数量的“部分”后出现的。
SignatureDoesNotMatch
这个错误和安全凭证有关,而不是和Amazon S3服务本身有关。听起来和人们在GitHub上报告的问题类似:反复出现的SignatureDoesNotMatch客户端错误 #995
所以,我建议在问题解决之前,使用早期版本的aws-cli。