ceph+s3使用方法


查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'
View Code

注意輸入以上生成的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的容器

 

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM