LoginSignup
4
4

More than 5 years have passed since last update.

s3cmdのインストールとLeoFSへのアクセス

Posted at

前回からLeoFSの使うためのツール群を触っている。今回はs3cmdを使ってLeoFSにアクセスしてみる。前回から見てる感じだとLeoFSはS3のエコシステムが使えるっぽい?
Amazon S3 Client Tutorials — LeoFS 1.0 documentation

s3cmdのインストール

s3cmd - Browse /s3cmd at SourceForge.net
ここから最新版の1.5.0-rc1を入れてみる。というか、安定版だと2011-06-10リリースの1.0.1になるんだけど、この場合ってどれ入れるのが正解なんだろう。

$ cd /usr/local/src
$ wget http://sourceforge.net/projects/s3tools/files/s3cmd/1.5.0-rc1/s3cmd-1.5.0-rc1.tar.gz/download
$ tar xzvf s3cmd-1.5.0-rc1.tar.gz 
$ sudo su
$ cd s3cmd-1.5.0-rc1
$ python setup.py install

展開したs3cmd-1.5.0-rc1の中に入っていたINSTALLファイルにしたがってインストール。

# s3cmd --configure

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
ImportError trying to import dateutil.parser.
Please install the python dateutil module:
$ sudo apt-get install python-dateutil
  or
$ sudo yum install python-dateutil
  or
$ pip install python-dateutil
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Traceback (most recent call last):
  File "/usr/bin/s3cmd", line 2530, in <module>
    except (ParameterError, InvalidFileError), e:
NameError: name 'ParameterError' is not defined

なんかエラーが出てる。pythonのライブラリが足りない?とりあえず下記を実行。

$ yum install python-dateutil

その後にleofsユーザーからもう一度やってみる。

$ 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. Leave them empty for using the env variables.
Access Key: b0b13a47973f28e70ee8
Secret Key: 7315fb1215c71273bdc721b57b7f2850437ce6ce

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]: 

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]: 

On some networks all internet access must go through a HTTP proxy.
Try setting it here if you can't connect to S3 directly
HTTP Proxy server name: localhost
HTTP Proxy server port [3128]: 8080

New settings:
  Access Key: b0b13a47973f28e70ee8
  Secret Key: 7315fb1215c71273bdc721b57b7f2850437ce6ce
  Encryption password: 
  Path to GPG program: /usr/bin/gpg
  Use HTTPS protocol: False
  HTTP Proxy server name: localhost
  HTTP Proxy server port: 8080

Test access with supplied credentials? [Y/n] 
Please wait, attempting to list all buckets...
Success. Your access key and secret key worked fine :-)

Now verifying that encryption works...
Not configured. Never mind.

Save settings? [y/N] y
Configuration saved to '/home/leofs/.s3cfg'

聞かれたところを上記のように入れて、configを作成する。確認。

$ s3cmd ls
2014-07-02 05:18  s3://tarr-bucket

bucketの一覧ができた!

いろいろ触る。

bucketの追加

$ s3cmd mb s3://apple
Bucket 's3://apple/' created
$ s3cmd ls
2014-07-02 08:37 s3://apple
2014-07-02 05:18 s3://tarr-bucket

bucketの削除

$ s3cmd rb s3://apple
Bucket 's3://apple/' removed
$ s3cmd ls
2014-07-02 05:18 s3://tarr-buck

bucketの中身を見る

$ s3cmd la
2014-07-02 06:56 0 s3://tarr-bucket/apple
2014-07-02 07:31 32320 s3://tarr-bucket/leofs-logo-blk-2.png
2014-07-02 06:31 0 s3://tarr-bucket/test.txt

bucketから特定のオブジェクトをローカルに落とす

$ ls
$ s3cmd get s3://tarr-bucket/test.txt local.txt
s3://tarr-bucket/test.txt -> local.txt [1 of 1]
0 of 0 0% in 0s 0.00 B/s done
$ ls
local.txt

上記で落としてきたファイルを上書きして、leofs上のファイルを更新する。

$ echo "tarrrrrrrrrrrrrrrrr" > local.txt
$ cat local.txt 
tarrrrrrrrrrrrrrrrr
$ ls
local.txt
$ s3cmd put local.txt s3://tarr-bucket/test.txt
WARNING: Module python-magic is not available. Guessing MIME types based on file extensions.
local.txt -> s3://tarr-bucket/test.txt  [1 of 1]
 20 of 20   100% in    0s   201.35 B/s  done
$ s3cmd ls s3://tarr-bucket/
2014-07-02 06:56         0   s3://tarr-bucket/apple
2014-07-02 07:31     32320   s3://tarr-bucket/leofs-logo-blk-2.png
2014-07-02 08:44        20   s3://tarr-bucket/test.txt
$ s3cmd get s3://tarr-bucket/test.txt sample.txt
s3://tarr-bucket/test.txt -> sample.txt  [1 of 1]
 20 of 20   100% in    0s     2.37 kB/s  done
$ cat sample.txt 
tarrrrrrrrrrrrrrrrr
4
4
0

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
4
4