简体   繁体   English

curl:(56) GCP SDK 失败,但 VM 中没有

[英]curl: (56) Failure in GCP SDK, but not in VM

Goal目标

I want to download a large zip file from an online database into a GCP bucket.我想从在线数据库中将一个 zip 大文件下载到 GCP 存储桶中。 I'm not very technical when it comes to GCP and working in the terminal, and I've stumbled upon some issues which I haven't been able to fix.当涉及到 GCP 和在终端工作时,我不是很懂技术,而且我偶然发现了一些我无法解决的问题。

What I've tried我试过的

I tried to do the above in a few different ways.我尝试以几种不同的方式执行上述操作。 First I tried the following command in the cloud shell on the GCP: curl -O https://website/file.zip | gsutil cp - gs://bucke/file.zip首先,我在 GCP 上的云 shell 中尝试了以下命令: curl -O https://website/file.zip | gsutil cp - gs://bucke/file.zip curl -O https://website/file.zip | gsutil cp - gs://bucke/file.zip , didn't work so I tried it in Google Cloud SDK shell on my Windows computer and I got the following output (cURL without gsutil gives the same output): curl -O https://website/file.zip | gsutil cp - gs://bucke/file.zip没有用,所以我在我的 Windows 计算机上的 Google Cloud SDK shell 中尝试了它,我得到了以下 output(没有 gsutil 的 cURL 给出了相同的输出):

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  1 43.5G    1  735M    0     0   239k      0 52:55:07  0:52:23 52:02:44     0
curl: (56) Send failure: Connection was reset
'count' is not recognized as an internal or external command,
operable program or batch file.
Copying from <STDIN>...
/ [1 files][    0.0 B/    0.0 B]
Operation completed over 1 objects.

Lastly, I tried the cURL command in a (Ubuntu) VM, and it worked fine.最后,我在 (Ubuntu) VM 中尝试了 cURL 命令,它运行良好。 The only problem with that is that I don't have sufficient permission to upload the files into a GCP bucket using gsutil (I get a 403 error, also when uploading other files).唯一的问题是我没有足够的权限使用 gsutil 将文件上传到 GCP 存储桶(我收到 403 错误,在上传其他文件时也是如此)。

Hypothesized issue假设问题

I've noticed I'm not the only one with a similar problem, so I looked into several proposed solutions ( 1 , 2 , 3 ), this solution mentions that it must be some issues with my system as it works fine in a VM.我注意到我不是唯一遇到类似问题的人,所以我研究了几个建议的解决方案( 123 ), 这个解决方案提到它一定是我的系统存在一些问题,因为它在 VM 中运行良好. When I try to download & upload a small file from cloud sdk shell on my computer (with the same command) from a different website it works fine.当我尝试从我的计算机上的云 sdk shell 从不同的网站下载和上传一个小文件(使用相同的命令)时,它工作正常。 Downloading a way smaller zip file from the same website doesn't return the error as previously, but this instead:从同一网站下载更小的 zip 文件不会像以前那样返回错误,而是返回:

 % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 12.2M  100 12.2M    0     0   313k      0  0:00:40  0:00:40 --:--:--  354k

'count' is not recognized as an internal or external command,
operable program or batch file.
Copying from <STDIN>...
/ [1 files][    0.0 B/    0.0 B]      0.0 B/s
Operation completed over 1 objects.

and when I download the zip file from the GCP bucket, it seems to be an invalid zip file.当我从 GCP 存储桶下载 zip 文件时,它似乎是一个无效的 zip 文件。

So apparently the problem lies within the connectivity of the website with my computer.很明显,问题出在网站与我的电脑的连接上。 (because other computer with same website works, and other website with same computer works), I'm guessing this might be a firewall issue, but my knowledge about this is very limited. (因为具有相同网站的其他计算机可以工作,而具有相同计算机的其他网站可以工作),我猜这可能是防火墙问题,但我对此的了解非常有限。 Can someone help me to go from here to continue the troubleshooting?有人可以帮我从这里拨打 go 继续进行故障排除吗? How do I figure out whether it is indeed a firewall issue, and how do I fix this (or find information on how to do this step by step)?我如何确定它是否确实是防火墙问题,以及如何解决此问题(或查找有关如何逐步执行此操作的信息)?

Any help is much appreciated!任何帮助深表感谢!

Remove -O from the curl command.从 curl 命令中删除-O Your file is being saved locally (check for file.zip in your local directory), instead of being piped into gsutil.您的文件正在本地保存(检查本地目录中的 file.zip),而不是通过管道传输到 gsutil。

curl https://website/file.zip | gsutil cp - gs://bucke/file.zip

-O flag for curl forces output to the file, instead of STDOUT, so next command in the pipeline (gsutil) receives nothing. curl 的-O标志将 output 强制到文件,而不是 STDOUT,因此管道中的下一个命令 (gsutil) 什么也接收不到。

When you are using streaming uploads for a large files it is recommended write the data first to a local file [1].当您对大文件使用流式上传时,建议先将数据写入本地文件 [1]。 So you could try:所以你可以尝试:

First, download to local file.首先,下载到本地文件。

curl -O URL curl-O URL

Second upload the file to your bucket [2]其次将文件上传到您的存储桶 [2]

gsutil cp file gs://bucket gsutil cp 文件 gs://bucket

Also, maybe you could try a test with a small file:另外,也许您可以尝试使用一个小文件进行测试:

curl " http://nginx.org/download/nginx-1.17.10.zip " | curl " http://nginx.org/download/nginx-1.17.10.zip " | gsutil cp - "gs://bucke/nginx-1.17.10.zip" gsutil cp - “gs://bucke/nginx-1.17.10.zip”

[1] https://cloud.google.com/storage/docs/gsutil/commands/cp#streaming-transfers [1] https://cloud.google.com/storage/docs/gsutil/commands/cp#streaming-transfers

[2] https://cloud.google.com/storage/docs/gsutil/commands/cp#copying-tofrom-subdirectories-distributing-transfers-across-machines [2] https://cloud.google.com/storage/docs/gsutil/commands/cp#copying-tofrom-subdirectories-distributing-transfers-across-machines

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

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