LoginSignup
8
2

More than 5 years have passed since last update.

IBM Cloud Object Storage のデータを Swift API コンテナ から S3 API バケットに移行する

Last updated at Posted at 2018-04-04

構成

以下のような構成で、「rclone」というプログラムを使ってデータをコピーしてみます。
今回は「rclone」を使うための Linux サーバーを IBM Cloud 上に用意しました。

IBM Cloud Object Storage では、Swift と S3 に関わらず、Private Endpoint を提供しています。
Private 経由では、ネットワーク通信量に対する課金は発生しない ので、安心してください。

Kobito.KuynTq.png

Swift API と S3 API の違いは下記リンクを参照してください。

https://console.bluemix.net/catalog/infrastructure/object-storage-group

認証情報の取得

接続に使う認証情報をポータルから取得しておきましょう。

Swift API

以下の3つの情報を使います。

  • Private Endpoint
  • Username
  • API Key (Password)

Kobito.L4gLlH.png

S3 API

以下の3つの情報を使います。

  • Private Endpoint
  • Access Key ID
  • Secret Access Key

Kobito.34lupx.png
Kobito.ISm1Dr.png

Kobito.Seo6rX.png

rclone を Linux サーバーにインストール

「unzip」等がないと、「None of the supported tools for extracting zip archives (unzip 7z) were found. Please install one of them and try again.」と怒られるので、入れておきます。
「rclone」のインストール自体は、2行目のコマンドだけなので非常に簡単です。

yum install unzip -y
curl https://rclone.org/install.sh | sudo bash

https://rclone.org/install/

rclone の設定

rclone config のコマンドで設定ファイルを生成できるので、そこから適当なファイルをつくります。

設定ファイルは ~/.config/rclone.conf に保存されるので、以下の設定として書き直します。

  • 使いたいリージョンによって、適宜 Endpoint を変更します
  • S3 API の設定では、Endpointの設定に加えて「region = other-v4-signature」とします
  • S3 API の設定では、「location_constraint」のパラメータで以下の場所を指定します(https://rclone.org/s3/)
    • us-standard / us-vault / us-cold / us-flex
    • us-east-standard / us-east-vault / us-east-cold / us-east-flex
    • us-south-standard / us-south-vault / us-south-cold / us-south-flex
    • eu-standard / eu-vault / eu-cold / eu-flex
    • ap-standard / ap-vault / ap-cold / ap-flex
~/.config/rclone.conf
[SWIFT]
type = swift
env_auth = false
user = IBMxxxxxx:xxxxxx
key = xxxxxx
auth = https://tok02.objectstorage.service.networklayer.com/auth/v1.0/
user_id = 
domain = 
tenant = 
tenant_id = 
tenant_domain = 
region = 
storage_url = 
auth_token = 
endpoint_type = private

[COS-TOK-AP]
type = s3
env_auth = false
access_key_id = xxxxxx
secret_access_key = xxxxxx
region = other-v4-signature
endpoint = s3.tok-ap-geo.objectstorage.service.networklayer.com
location_constraint = ap-flex
acl = private
server_side_encryption = 
storage_class = 

設定確認

以下のコマンドで、コンテナやバケットのリストが出てくれば、問題なく設定されてることが確認できます。

rclone lsd SWIFT:
rclone lsd COS-TOK-AP:
[root@khayama-test rclone]# rclone lsd COS-TOK-AP:
          -1 2017-08-09 06:50:19        -1 apictest
          -1 2018-03-22 12:58:23        -1 khayama-test2
          -1 2018-03-28 13:09:53        -1 khayama-test3

ドライラン

以下のコマンドで、どのファイルがコピーされる対象となっているか、確認できます。
コピー先となる S3 API 側のバケットを新規に作る場合は、バケット名が全ユーザーの中で一意である必要ありますので、注意します。

rclone --dry-run copy SWIFT:khayama COS-TOK-AP:khayama-test4
[root@khayama-test rclone]# rclone --dry-run copy SWIFT:khayama COS-TOK-AP:khayama-test4
2018/04/03 03:49:58 NOTICE: vyatta-vrouter-5.2R5S3_B_amd64.iso: Not copying as --dry-run

オブジェクトストレージ間のコピー

以下のコマンドで実施できます。

rclone -v copy SWIFT:khayama COS-TOK-AP:khayama-test4

100 Mbps の Linux サーバーで実行した場合、これくらいの速度感でした。

[root@khayama-test rclone]# rclone -v copy SWIFT:khayama COS-TOK-AP:khayama-test4
2018/04/03 04:09:49 INFO  : S3 bucket khayama-test4: Modify window is 1ns
2018/04/03 04:09:50 INFO  : S3 bucket khayama-test4: Waiting for checks to finish
2018/04/03 04:09:50 INFO  : S3 bucket khayama-test4: Waiting for transfers to finish
2018/04/03 04:10:26 INFO  : vyatta-vrouter-5.2R5S3_B_amd64.iso: Copied (new)
2018/04/03 04:10:26 INFO  : 
Transferred:   335 MBytes (9.108 MBytes/s)
Errors:                 0
Checks:                 0
Transferred:            1
Elapsed time:       36.7s

このコマンドでは、ファイルはコピーされるだけで、削除はされません。

Kobito.M3OwGE.png

ターゲット側の S3 API の設定で「location_constraint」のパラメータを「ap-standard / ap-vault / ap-cold / ap-flex」の中で変えてみると、反映されていることがわかります。

Kobito.iCI0a7.png

さいごに

「rclone」は「rsync」のようなコマンドが使え、たとえばオブジェクトストレージ間のデータ同期、ローカルPC-オブジェクトストレージ間のデータ同期にも有効です。
ぜひ使ってみてください。

8
2
2

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
2