安装s3cmd
代码语言:javascript复制virtualenv ven_s3
source ven_s3/bin/activate
pip install pip --upgrade
pip install s3cmd
查看user key
代码语言:javascript复制radosgw-admin user info --uid=testuser
{
"user_id": "testuser",
"display_name": "First User",
"email": "",
"suspended": 0,
"max_buckets": 1000,
"auid": 0,
"subusers": [
{
"id": "testuser:swift",
"permissions": "full-control"
}
],
"keys": [
{
"user": "testuser",
"access_key": "UNQA07763EJDVFE1U82F",
"secret_key": "yERsPubsAxUjlIxsO9HOQ03EbEE2HrP88dikyObM"
}
],
"swift_keys": [
{
"user": "testuser:swift",
"secret_key": "joNclsgsrr2VJjezfTwlfZiuEz1b9OcUiTnRXBxp"
}
],
"caps": [
{
"type": "buckets",
"perm": "read"
},
{
"type": "metadata",
"perm": "*"
},
{
"type": "usage",
"perm": "*"
},
{
"type": "users",
"perm": "*"
}
],
"op_mask": "read, write, delete",
"default_placement": "",
"placement_tags": [],
"bucket_quota": {
"enabled": false,
"max_size_kb": -1,
"max_objects": -1
},
"user_quota": {
"enabled": false,
"max_size_kb": -1,
"max_objects": -1
},
"temp_url_keys": []
}
配置s3cmd
代码语言:javascript复制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: XA256MGT6DOJWG0WHUBM
Secret Key: CP7uaDpOK7rxHJmTjGrVfO5hd5oRUukzGSkBfL5E
Default Region [US]:
Encryption password is used to protect your files from reading
by unauthorized persons while in transfer to S3
Encryption password:
Path to GPG program [/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 [Yes]: 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: XA256MGT6DOJWG0WHUBM
Secret Key: CP7uaDpOK7rxHJmTjGrVfO5hd5oRUukzGSkBfL5E
Default Region: US
Encryption password:
Path to GPG program: /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...
ERROR: Test failed: [Errno -2] Name or service not known
Retry configuration? [Y/n] n
Save settings? [y/N] y
Configuration saved to '/home/b/.s3cfg'
由于是自建的radosgw,还需要配置如下三项:
- cloudfont_host
- host_base
- host_bucket
其对应的配置如下:
代码语言:javascript复制cat .s3cfg
...
cloudfront_host = 192.168.1.200:8080
...
host_base = 192.168.1.200:8080
host_bucket = 192.168.1.200:8080/%(bucket)
代码语言:javascript复制s3cmd操作
s3cmd ls # 查看bucket
s3cmd mb s3://test # 创建bucket
s3cmd put .s3cfg s3://test # 上传文件
s3cmd la # 查看object
s3cmd get s3://test/.s3cfg # 下载文件
s3cmd rm s3://test/.s3cfg # 删除文件
s3cmd rb s3://test # 删除bucket
参考链接
http://www.lai18.com/content/6968965.html