When it’s ready.

出来るまで出来ない

Google Storageの使い方 導入編

GoogleIOで発表になったGoogleStorageを使ってみる。

GoogleStorage

http://code.google.com/intl/ja/apis/storage/docs/overview.html
に詳しく書いてあるがざっくり説明すると

Internetにつながってたらどこからでも使うことが出来て
GsUtilコマンドかWebInterFaceから使うことが出来ます。
巨大で大量のバイナリデータを保存することが出来てデータはアメリカ国内の複数の
データセンターに分散して保存されます。保存した瞬間に必ずデータが更新されることを
保証されます。ファイル毎にACLを設定出来てSSLでのセキュアなアクセスが可能です。

制限

現在はPreviewなのでいくつかの制限があります。1アカウントあたり100GB、1000Bucketまで無償で使用できます。

料金

現在発表されている料金体系

  • 容量
    • $0.17/GB/month
  • 帯域
    • Upload data to Google
      • + $0.10/GB
    • Download data from Google
      • + $0.15/GB for Americas and EMEA
      • + $0.30/GB for APAC
  • Requests
    • PUT, POST, LIST
      • $0.01 per 1,000 requests
    • GET, HEAD
      • $0.01 per 10,000 requests

参考にS3の料金

  • First 50 TB 99.999999999%
    • $0.150 per GB / Month
  • First 50 TB 99.99%
    • $0.100 per GB / Month
  • All Data Transfer In
    • Free until June 30th, 2010**
  • PUT, COPY, POST, or LIST
    • $0.01 per 1,000 Requests

S3って、もうすぐ50TBまでだったらアップロードフリーになるのは凄いかも。全体的にS3の方が安い

使ってみる

下準備1 キーとシークレットの取得

GoogleStorageのマネージページにアクセスする > https://sandbox.google.com/storage/m/manage

new acces keyボタンをクリックするとアクセスキーとシークレットが生成される。

下準備2 ユーティリティーをインスコする

https://code.google.com/intl/ja/apis/storage/docs/gsutil.html#install
ドキュメントに従いツールをDLして、インスコする。私は、Pathを追加せずにgsutilとbotoフォルダを/usr/local/bin直下にコピーした。

バケットを作って、ファイルをアップロードする
%gsutil mb gs://a2cdata
% gsutil cp 1977603095_fb7971e69e.jpg 1978160173_a3a5183800.jpg 1979227588_cdf15f6a7d.jpg 1995253276_cd6a2a1bb8.jpg gs://a2cdata
Copying file://1977603095_fb7971e69e.jpg...
Copying file://1978160173_a3a5183800.jpg...
Copying file://1979227588_cdf15f6a7d.jpg...
Copying file://1995253276_cd6a2a1bb8.jpg...
% gsutil ls gs://a2cdata
gs://a2cdata/1977603095_fb7971e69e.jpg
gs://a2cdata/1978160173_a3a5183800.jpg
gs://a2cdata/1979227588_cdf15f6a7d.jpg
gs://a2cdata/1995253276_cd6a2a1bb8.jpg

簡単すぎる。
Webインターフェースから見るとこうなってる

ログイン情報について

初めてgsutilを実行するとアクアセスキーとシークレットキーをプロンプトで聞かれる。また、gs://の他にs3://を使うとGoogleStorageとS3をシームレスに利用することが出来る。これらの情報は、~/.botoファイルに格納されている。また、プロキシーの設定も追記出来るのでFW内からも利用出来るぽい

# This file contains credentials and other configuration information needed
# by the boto library, used by gsutil. You can edit this file (e.g., to add
# credentials) but be careful not to mis-edit any of the variable names (like
# "gs_access_key_id") or remove important markers (like the "[Credentials]" and
# "[Boto]" section delimeters).
#
# This file was created by gsutil version "2010-05-16 19:36:15-07:00"
# at 2010-05-20 13:16:10.


[Credentials]

# To add Amazon credentials ("s3://" URIs), edit and uncomment the
# following two lines:
#aws_access_key_id = <your Amazon access key ID>
#aws_secret_access_key = <your Amazon secret access key>
# The ability to specify an alternate storage host is primarily for developers.
#aws_host = <alternate storage host address>

# Google credentials ("gs://" URIs):
gs_access_key_id = <your access key ID>
gs_secret_access_key = <your Amazon secret access key>
# The ability to specify an alternate storage host is primarily for developers.
#gs_host = <alternate storage host address>



[Boto]

# To use a proxy, edit and uncomment the proxy and proxy_port lines.  If you
# need a user/password with this proxy, edit and uncomment those lines as well.
#proxy = <proxy host>
#proxy_port = <proxy port>
#proxy_user = <your proxy user name>
#proxy_pass = <your proxy password>

# Set 'is_secure' to False to cause boto to connect using HTTP instead of the
# default HTTPS.  This is useful if you want to capture/analyze traffic
# (e.g., with tcpdump).
#is_secure = False

# 'debug' controls the level of debug messages printed: 0 for none, 1
# for basic boto debug, 2 for all boto debug plus HTTP requests/responses.
# Note: 'gsutil -d' sets debug to 2 for that one command run.
#debug = <0, 1, or 2>

# 'num_retries' controls the number of retry attempts made when errors occur.
# The default is 5.
#num_retries = <integer value>