s3cmd安装与使用

 安装

centos在线安装,yum install s3cmd

配置

执行s3cmd --configure命令,根据提示输入accesskey和scretkey。

注意倒数第二步,Test access with supplied credentials? [Y/n] n,可以选择n,表示不做验证,因为前面过程中输入的可能有错误,如果选择Y,会验证失败,继而导致无法生存配置文件;

跳过验证,后续手动修改配置文件即可;

[root@localhost ~]# 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 [Z475N7JCTN60FK9D9J4I]: 
Secret Key [sNQ7p598G0IpgXPhfOEXUUWPqUvgb3NqE8Ldk4MY]: 
Default Region [us-east-1]: 

Use "s3.amazonaws.com" for S3 Endpoint and not modify it to the target Amazon S3.
S3 Endpoint [192.168.221.37:7480]: 

Use "%(bucket)s.s3.amazonaws.com" to the target Amazon S3. "%(bucket)s" and "%(location)s" vars can be used
if the target S3 system supports dns based buckets.
DNS-style bucket+hostname:port template for accessing a bucket [191.168.221.37:7480/%(bucket)]: 

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 only be proxied with Python 2.7 or newer
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: 

New settings:
  Access Key: Z475N7JCTN60FK9D9J4I
  Secret Key: sNQ7p598G0IpgXPhfOEXUUWPqUvgb3NqE8Ldk4MY
  Default Region: us-east-1
  S3 Endpoint: 192.168.221.37:7480
  DNS-style bucket+hostname:port template for accessing a bucket: 191.168.221.37:7480/%(bucket)
  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] n

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

修改配置文件:

[root@localhost ~]# vim /root/.s3cfg

注意修改access_key,secret_key,  host_base,host_bucket,

对于host_bucket格式,注意要是否为virtualhost模式,需要做不同设置;

非virtualhost:

host_bucket = 191.168.221.37:7480/%(bucket)

virtualhost:

host_bucket = %(bucket).191.168.221.37:7480

使用

通过s3cmd --help查看具体使用方法;

列举bucket

s3cmd ls s3://
 

列举bucket下的objcet:

s3cmd ls s3://buc1

创建bucket:

s3cmd mb s3://test1
 

猜你喜欢

转载自blog.csdn.net/ff_gogo/article/details/83656774