简体   繁体   English

在 AWS 上运行 Python 脚本并将 5GB 的文件传输到 EC2

[英]Run Python Script on AWS and transfer 5GB of files to EC2

I am an absolute beginner in AWS: I have created a key and an instance, the python script I want to run in the EC2 environment needs to loop through around 80,000 filings, tokenize the sentences in them, and use these sentences for some unsupervised learning.我是 AWS 的绝对初学者:我已经创建了一个密钥和一个实例,我想在 EC2 环境中运行的 python 脚本需要遍历大约 80,000 个文件,标记其中的句子,并将这些句子用于一些无监督学习.

This might be a duplicate;这可能是重复的; but I can't find a way to copy these filings to the EC2 environment and run the python script in EC2, I am also not very sure as to how I can use boto3.但是我找不到将这些文件复制到 EC2 环境并在 EC2 中运行 python 脚本的方法,我也不太确定如何使用 boto3。 I am using Mac OS.我正在使用 Mac 操作系统。 I am just looking for any way to speed things up.我只是在寻找任何方法来加快速度。 Thank you so so much!非常感谢! I am forever grateful!!!我永远心存感激!!!

Here's one way that might help:这是一种可能有帮助的方法:

  • create a simple IAM role that allows S3 access to the bucket holding your files创建一个简单的 IAM 角色,允许 S3 访问保存您的文件的存储桶
  • apply that IAM role to the running EC2 instance (or launch a new instance with the IAM role)将该 IAM 角色应用于正在运行的 EC2 实例(或使用 IAM 角色启动一个新实例)
  • install the awscli on the EC2 instance在 EC2 实例上安装 awscli
  • SSH to the instance and sync the S3 files to the EC2 instance using aws s3 sync通过 SSH 连接到实例并使用aws s3 sync将 S3 文件同步到 EC2 实例
  • run your app运行你的应用

I'm assuming you've launched EC2 with enough diskspace to hold the files.我假设您已经启动了具有足够磁盘空间来保存文件的 EC2。

Here's what I tried recently:这是我最近尝试的:

  1. Create the bucket and keep the bucket accessible for public.创建存储桶并使存储桶可供公众访问。
  2. Create the role and add HTTP option.创建角色并添加 HTTP 选项。
  3. Upload all the files and make sure the files are public accessible.上传所有文件并确保文件可公开访问。
  4. Get the HTTP link of the S3 file.获取 S3 文件的 HTTP 链接。
  5. Connect the instance through putty.通过putty连接实例。
  6. wget copies the file into EC2 instance. wget将文件复制到 EC2 实例中。

If your files are in zip format, one time copy enough to move all the files into instance.如果您的文件是 zip 格式,请复制一次足以将所有文件移动到实例中。

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

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