harumaki.net

インフラ屋の覚書や、ラーメン食べある記とか。

AWS infra 運用

[AWS]s3-tools(s3cmd)のインストールと検証

投稿日:2013年6月14日

Last Updated on 2021年7月4日 by かんりにん

[pukiwiki]
EC2上のDB→S3バケットへのダンプファイルの転送にて、s3fs以外のものでも試してみよう、ということで
今日はs3-toolsのテストを。
インスタンスはAmazon Linux AMI、ラージインスタンスで。

-本家サイト?
お世話になっております!
http://s3tools.org/s3cmd

*1)ダウンロード

# wget http://sourceforge.net/projects/s3tools/files/s3cmd/1.5.0-alpha1/s3cmd-1.5.0-alpha1.tar.gz/download

*2)展開、インストール

パッケージでも提供されている様子だが、今回はダウンロードしたアーカイブのうち
以下のファイルを/usr/local/bin以下に移動。

# mv S3 /usr/local/bin
# mv s3cmd /usr/local/bin

*3)初期設定

s3cmdにオプション”–configure”をつけて実行。

# s3cmd –configure
 
Enter new values or accept defaults in brackets with Enter.
Refer to user manual for detailed description of all options.
 
Access key and Secret key are your identifiers for Amazon S3
Access Key: ****************** ←アクセスキーを入力
Secret Key: ****************** ←シークレットキーを入力
 
Encryption password is used to protect your files from reading
by unauthorized persons while in transfer to S3
Encryption password: ************ ←暗号化パスワードの入力
Path to GPG program [/usr/bin/gpg]: ←GPGの実行ファイルのパスを指定、デフォルトは/usr/bin/gpg
 
When using secure HTTPS protocol all communication with Amazon S3
servers is protected from 3rd party eavesdropping. This method is
slower than plain HTTP and can’t be used if you’re behind a proxy
Use HTTPS protocol [No]: ←HTTPS使用の有無を指定、デフォルトはNo
 
On some networks all internet access must go through a HTTP proxy.
Try setting it here if you can’t conect to S3 directly
HTTP Proxy server name: ←Proxyサーバーの指定、デフォルトは無し
 
New settings:
Access Key: ******************
Secret Key: ******************
Encryption password: ************
Path to GPG program: /usr/bin/gpg
Use HTTPS protocol: False
HTTP Proxy server name:
HTTP Proxy server port: 0
 
Test access with supplied credentials? [Y/n] Y
Please wait, attempting to list all buckets…
Success. Your access key and secret key worked fine 🙂
 
Now verifying that encryption works…
Success. Encryption and decryption worked fine 🙂
 
Save settings? [y/N] y
Configuration saved to ‘/root/.s3cfg’
#

*4)追加インストール

実行にはpython-magicが必要だったのでyumでインストール

# yum install python-magic

*5)動作テスト

デフォルトではファイルを15MB単位でスプリットして転送する様子(マルチパートアップロード?)。

**5-1)ファイルサイズ120MB

# time s3cmd -c /root/.s3cfg put /home/ec2-user/db-sprittest/backup_dbah s3://backup-db1-tokyo/backup_dbah
/home/ec2-user/db-sprittest/backup_dbah -> s3://backup-db1-tokyo/backup_dbah [part 1 of 8, 15MB]
15728640 of 15728640 100% in 0s 16.98 MB/s done
/home/ec2-user/db-sprittest/backup_dbah -> s3://backup-db1-tokyo/backup_dbah [part 2 of 8, 15MB]
15728640 of 15728640 100% in 0s 15.09 MB/s done
 
 
— snip —
 
 
/home/ec2-user/db-sprittest/backup_dbah -> s3://backup-db1-tokyo/backup_dbah [part 8 of 8, 2MB]
2689560 of 2689560 100% in 0s 5.41 MB/s done
 
real 0m10.279s
user 0m1.624s
sys 0m0.620s
 
”→所要時間10秒”

***ファイル確認

s3fsで/mnt以下にバケットをマウントしているので、直接確認してみる。

# ll /mnt/s3-backup-db1-tokyo/backup_dbah
———- 1 root root 112790040 Jun 14 06:56 /mnt/s3-backup-db1-tokyo/backup_dbah

なぜかパーミッションがついていないので、後から設定する必要がある。

# ll /mnt/s3-backup-db1-tokyo/backup_dbah
———- 1 root root 112790040 Jun 14 06:56 /mnt/s3-backup-db1-tokyo/backup_dbah

**2)ファイルサイズ750MB

# time s3cmd -c /root/.s3cfg put /home/ec2-user/db-sprittest/backup_dbaa s3://backup-db1-tokyo/backup_dbaa
/home/ec2-user/db-sprittest/backup_dbaa -> s3://backup-db1-tokyo/backup_dbaa [part 1 of 48, 15MB]
15728640 of 15728640 100% in 4s 3.06 MB/s done
/home/ec2-user/db-sprittest/backup_dbaa -> s3://backup-db1-tokyo/backup_dbaa [part 2 of 48, 15MB]
15728640 of 15728640 100% in 3s 4.35 MB/s done
 
 
— snip —
  
 
/home/ec2-user/db-sprittest/backup_dbaa -> s3://backup-db1-tokyo/backup_dbaa [part 47 of 48, 15MB]
15728640 of 15728640 100% in 4s 3.41 MB/s done
/home/ec2-user/db-sprittest/backup_dbaa -> s3://backup-db1-tokyo/backup_dbaa [part 48 of 48, 10MB]
10753920 of 10753920 100% in 1s 5.99 MB/s done
 
real 1m48.703s
user 0m9.861s
sys 0m4.200s
 

”→所要時間1分49秒”

*6)その他

**スプリットするファイルサイズの指定

オプション”–multipart-chunk-size-mb=“で指定可能、
最小サイズは5MB、最大サイズは5GBとのこと。
– s3cmdのヘルプより抜粋
–multipart-chunk-size-mb=SIZE
Size of each chunk of a multipart upload. Files bigger
than SIZE are automatically uploaded as multithreaded-
multipart, smaller files are uploaded using the
traditional method. SIZE is in Mega-Bytes, default
chunk size is noneMB, minimum allowed chunk size is
5MB, maximum is 5GB.

そのほかにもオプションが多数あるので、今後いろいろとお試しで。
[/pukiwiki]
 
 

 

-AWS, infra, 運用
-,

執筆者:


comment

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

CAPTCHA


関連記事

no image

haproxyを試す 2.syslog設定

  ※haproxy RPM版です。 Contents haproxyのログをrsyslogへ出力する場合の設定方法。 ログの書き出しはsyslogファシリティを利用するが、送信方法はrsyslogの …

no image

CentOSにwmiクライアントを入れてみる

[pukiwiki] 何気に[[LINUX PACKAGE SEARCH>http://pkgs.org/]]でwmi(Windows Management Instrumentation)の RPM …

no image

オープンソースでのクラスタリング環境構築/DRBD

[pukiwiki] #contents *オープンソースでのクラスタリング環境構築/DRBD ネットワークに接続されたホスト間でのディスクミラーリング機能を提供。 GNU GPLに準拠。 特徴として …

no image

postfix SMTP-auth + TLSの実装

[pukiwiki] &topicpath;   **▼smtp-auth + TLSの実装 [#j312771a]  別項で記載したUNIXパスワードでのsmtp-auth実装に  暗号化 …

[AWS]ただのメモ:ELBでSSL証明書をアップするときは秘密鍵をRSAで。

  ※AWSへSSL証明書一式をアップする際の注意事項 秘密鍵ファイルをかならずRSA PRIVATE KEYへ変更すること。 普段apache httpd serverでhttpsを使うときは秘密鍵 …