简体   繁体   English

如何使用OpenStack的Swift将大型SQLite文件上传到对象存储(通过Python)

[英]How do I upload a large SQLite file to Object Storage using OpenStack's Swift (via Python)

I have an Object Storage instance on IBM's Bluemix, and I'm attempting to upload a ~32GB SQLite file. 我在IBM的Bluemix上有一个对象存储实例,并且试图上载〜32GB的SQLite文件。 Here is my Python code which uses the OpenStack Swift API (with the credentials removed): 这是我的Python代码,该代码使用OpenStack Swift API(已删除凭据):

import swiftclient
conn = swiftclient.Connection(key="pw",authurl="url",auth_version='3',os_options={"project_id": "project_id","user_id": "user_id","region_name": "region"})
container_name = 'containerName'
file_name = 'file.sqlite'
with open(file_name, 'rb') as sqlite_file:
    conn.put_object(container_name,file_name,sqlite_file)

I tested this code with a small .html file and it uploaded without a problem. 我用一个小的.html文件测试了此代码,并成功上传了代码。 When I changed the file to the SQLite file, it ran for > 5 hours and eventually gave a "requests.exceptions.ConnectionError: [Errno 32] Broken pipe" error. 当我将文件更改为SQLite文件时,它运行了5个小时以上,并最终出现“ requests.exceptions.ConnectionError:[Errno 32]管道损坏”错误。 What am I doing wrong? 我究竟做错了什么?

You'll need to read-up on Swift DLO/SLO support and manifests. 您需要阅读有关Swift DLO / SLO的支持和清单。 Here's a blog post that might help with context on what manifests are and the differences between Static Large Object and Dynamic Large Object support. 这是一篇博客文章 ,可帮助您了解清单的内容以及静态大对象和动态大对象支持之间的区别。

Basically, I'd recommend the following approach: 基本上,我建议采用以下方法:

  1. Download/install the Python-SwiftClient binary 下载/安装Python-SwiftClient二进制文件
  2. Use its upload command in conjunction with your object storage credentials from the Bluemix service. 结合使用其上载命令和Bluemix服务中的对象存储凭证。 In the manifest article above, it discusses this approach here . 在上面的清单文章,探讨这种方法在这里 Take note of the upload command, the use of the --use-slo flag and the ability to define the size of the concatenated segments generated. 注意上命令,--use -slo标志的使用以及定义所生成的串联段的大小的功能。 Roughly, the invocation will look like this: 大致来说,调用将如下所示:

$ swift --os-auth-url=https://identity.open.softlayer.com/v3 --os-user- id=some_hex_value --os-password="weird_characters" --os-project-id=another_hex_value --os-region-name=dallas -V 3 upload my_object_storage_container_name -S int_seg_size_in_bytes my_local_large_file_with_some_extension --use-slo

my_local_large_file_with_some_extension segment 3
my_local_large_file_with_some_extension segment 1
my_local_large_file_with_some_extension segment 2
my_local_large_file_with_some_extension segment 0
my_local_large_file_with_some_extension/1443450560.000000/160872806/52428800/00000002
my_local_large_file_with_some_extension/1443450560.000000/160872806/52428800/00000003
my_local_large_file_with_some_extension/1443450560.000000/160872806/52428800/00000001
my_local_large_file_with_some_extension/1443450560.000000/160872806/52428800/00000000
my_local_large_file_with_some_extension

Good luck. 祝好运。

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

相关问题 如何使用python在Swift存储系统中上传文件? - How to upload a file in Swift Storage system using python? 如何使用Python Flask将文件上传到Firebase存储? - How do you upload a file to Firebase Storage using Python Flask? 如何在不阻止Web服务器的情况下上传大文件? 使用python和Amazon Beanstalk / EC2 - How do I upload a large file without blocking my webserver? Using python and Amazon Beanstalk/EC2 使用 Python 将 csv 大文件上传到云存储 - Upload large csv file to cloud storage using Python 如何使用Python在myBucket中上传CSV文件并在S3 AWS中读取文件 - How do I upload a CSV file in myBucket and Read File in S3 AWS using Python 如何使用 python 将文件上传到 S3 签名 url? - How do I upload a file into S3 signed url with python? 如何在heroku上使用python中的boto3将文件上传到s3? - How do I upload a file to s3 using boto3 in python on heroku? Swift(OpenStack存储)安装 - Swift (OpenStack Storage) Installation 如何使用Python将Azure Blob存储中的大型JSON文件拆分为每个记录的单个文件? - How can I split large JSON file in Azure Blob Storage into individual files for each record using Python? Google Cloud Storage - 如何通过 Python 检索文件的所有者? - Google Cloud Storage - How to retrieve a file's owner via Python?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM