查bucket相关信息
# 查看bucket名称 radosgw-admin bucket list # 查看metadata中有哪些用户 radosgw-admin metadata list user # 指定bucket的相关信息 radosgw-admin bucket stats --bucket="first-bucket.s3.amazonaws.com" # 查看指定用户的相关信息 radosgw-admin user info --uid=test # 查看bucket中的文件名 radosgw-admin bucket list --bucket=first-bucket.s3.amazonaws.com # 删除bucket中的某个文件(--object:bucket中的file) radosgw-admin object rm --bucket=testab --object=passwd # 查看bucket中object的相关信息 radosgw-admin object stat --bucket=first-bucket.s3.amazonaws.com --object=hosts
删除bucket
# 删除buckets,及其内容 radosgw-admin bucket rm --bucket=first-bucket.s3.amazonaws.com --purge-objects # 删除某个用户及其buckets radosgw-admin user rm --uid=<username> --purge-data
创建用户
# 创建S3用户 radosgw-admin user create --uid=test --display-name="Test User" # 创建swift用户 radosgw-admin subuser create --uid=test --subuser=test:swift --access=full # swift用户生成secret_key radosgw-admin key create --subuser=test:swift --key-type=swift --gen-secret
S3客服端配置
s3cmd --configure

1 [root@OPS0-h ~]# s3cmd --configure 2 3 Enter new values or accept defaults in brackets with Enter. 4 Refer to user manual for detailed description of all options. 5 6 Access key and Secret key are your identifiers for Amazon S3. Leave them empty for using the env variables. 7 Access Key: P4EU3KV0RX50I051NNID 8 Secret Key: NyAQOxQulsPhi7tjHGtbLVQp2t1c7DEJKDdkMGY1 9 Default Region [US]: 10 11 Use "s3.amazonaws.com" for S3 Endpoint and not modify it to the target Amazon S3. 12 S3 Endpoint [s3.amazonaws.com]: ceph.s3.int.zuzuche.com 13 14 Use "%(bucket)s.s3.amazonaws.com" to the target Amazon S3. "%(bucket)s" and "%(location)s" vars can be used 15 if the target S3 system supports dns based buckets. 16 DNS-style bucket+hostname:port template for accessing a bucket [%(bucket)s.s3.amazonaws.com]: %(bucket)s.ceph.s3.int.zuzuche.com 17 18 Encryption password is used to protect your files from reading 19 by unauthorized persons while in transfer to S3 20 Encryption password: 21 Path to GPG program [/usr/bin/gpg]: 22 23 When using secure HTTPS protocol all communication with Amazon S3 24 servers is protected from 3rd party eavesdropping. This method is 25 slower than plain HTTP, and can only be proxied with Python 2.7 or newer 26 Use HTTPS protocol [No]: 27 28 On some networks all internet access must go through a HTTP proxy. 29 Try setting it here if you can't connect to S3 directly 30 HTTP Proxy server name: 31 32 New settings: 33 Access Key: P4EU3KV0RX50I051NNID 34 Secret Key: NyAQOxQulsPhi7tjHGtbLVQp2t1c7DEJKDdkMGY1 35 Default Region: US 36 S3 Endpoint: ceph.s3.int.zuzuche.com 37 DNS-style bucket+hostname:port template for accessing a bucket: %(bucket)s.ceph.s3.int.zuzuche.com 38 Encryption password: 39 Path to GPG program: /usr/bin/gpg 40 Use HTTPS protocol: False 41 HTTP Proxy server name: 42 HTTP Proxy server port: 0 43 44 Test access with supplied credentials? [Y/n] n 45 46 Save settings? [y/N] y 47 Configuration saved to '/root/.s3cfg'
注意输入以上生成的access_key和secret_key,更改host_base 与host_bucket 配置,生成/root/.s3cfg配置文件,本机上的dns里面配置s3相应的域名。
S3客服端操作
# 创建bucket [root@OPS0-h ~]# s3cmd mb s3://three-bucket Bucket 's3://three-bucket/' created #上传文件测试 [root@OPS0-h ~]# s3cmd put --acl-public 3.sh s3://three-bucket/3.sh upload: '3.sh' -> 's3://three-bucket/3.sh' [1 of 1] 53 of 53 100% in 0s 1551.07 B/s done Public URL of the object is: http://three-bucket.ceph.s3.int.zuzuche.com/3.sh #设置S3 bucket的Public权限 (只能加现有的,后期加进来的访问还是会403) s3cmd setacl s3://first-bucket --acl-public --recursive curl -I http://first-bucket.s3.amazonaws.com/group #上传并将权限设置为所有人可读 s3cmd put --acl-public file.txt s3://first-bucket/file.txt # 下载文件 s3cmd get s3://first-bucket/hosts ./ # 批量下载 s3cmd get s3://first-bucket/* ./
注意:swift接口可查看s3上传的文件,s3无权限查看swift的容器