测试使用S3 API接口
使用radosgw-admin工具创建用户
[root@ceph-mon01 ssl]# radosgw-admin user create --uid=s3user --display-name="s3 test user"{"user_id": "s3user","display_name": "s3 test user","email": "","suspended": 0,"max_buckets": 1000,"auid": 0,"subusers": [],"keys": [{"user": "s3user","access_key": "433ZGVH2EJTJMG5EDP1B","secret_key": "K0V73EieP8Wh6mng9xu9jA6iDbJGzfTXi2q3XQOU"}],"swift_keys": [],"caps": [],"op_mask": "read, write, delete","default_placement": "","placement_tags": [],"bucket_quota": {"enabled": false,"check_on_raw": false,"max_size": -1,"max_size_kb": 0,"max_objects": -1},"user_quota": {"enabled": false,"check_on_raw": false,"max_size": -1,"max_size_kb": 0,"max_objects": -1},"temp_url_keys": [],"type": "rgw","mfa_ids": []}[root@ceph-mon01 ssl]#radosgw-admin user list["s3user"][root@ceph-mon01 ssl]#提示:创建账号在集群节点都可以创建,建议在admin host上创建;
在客户端主机上安装s3cmd工具
[root@node11 ~]# yum install -y s3cmd提示:该工具来自epel源,安装前请配置好epel源;
配置s3cmd工具
[root@node11 ~]# s3cmd --configureEnter 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: 433ZGVH2EJTJMG5EDP1BSecret Key: K0V73EieP8Wh6mng9xu9jA6iDbJGzfTXi2q3XQOUDefault Region [US]: Use "s3.amazonaws.com" for S3 Endpoint and not modify it to the target Amazon S3.S3 Endpoint [s3.amazonaws.com]: ceph-mon01.ilinux.io:7480Use "%(bucket)s.s3.amazonaws.com" to the target Amazon S3. "%(bucket)s" and "%(location)s" vars can be usedif the target S3 system supports dns based buckets.DNS-style bucket+hostname:port template for accessing a bucket [%(bucket)s.s3.amazonaws.com]: [%(bucket)s.ceph-mon01.ilinux.io:7480Encryption password is used to protect your files from readingby unauthorized persons while in transfer to S3Encryption password:Path to GPG program [/usr/bin/gpg]: When using secure HTTPS protocol all communication with Amazon S3servers is protected from 3rd party eavesdropping. This method isslower than plain HTTP, and can only be proxied with Python 2.7 or newerUse HTTPS protocol [Yes]: NoOn some networks all internet access must go through a HTTP proxy.Try setting it here if you can't connect to S3 directlyHTTP Proxy server name:New settings:Access Key: 433ZGVH2EJTJMG5EDP1BSecret Key: K0V73EieP8Wh6mng9xu9jA6iDbJGzfTXi2q3XQOUDefault Region: USS3 Endpoint: ceph-mon01.ilinux.io:7480DNS-style bucket+hostname:port template for accessing a bucket: [%(bucket)s.ceph-mon01.ilinux.io:7480Encryption password:Path to GPG program: /usr/bin/gpgUse HTTPS protocol: FalseHTTP Proxy server name:HTTP Proxy server port: 0Test access with supplied credentials? [Y/n] YPlease 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] yConfiguration saved to '/root/.s3cfg'[root@node11 ~]#提示:access key和secret key这两项在我们创建用户时,就会返回;把对应信息复制过来就好;s3 endport是用来指定rgw站点的域名和端口;dns-style是指定泛域名解析格式;上述配置信息保存在当前用户的.s3cfg文件中,我们也可以直接修改该文件来配置s3cmd工具;
用s3user创建bucket
[root@node11 ~]# s3cmd mb s3://imagesBucket 's3://images/' created[root@node11 ~]#列出bucket
[root@node11 ~]# s3cmd ls2022-10-08 11:18s3://images[root@node11 ~]#上传文件
[root@node11 ~]# s3cmd put /usr/share/backgrounds/morning.jpg s3://images/test/test.jpgupload: '/usr/share/backgrounds/morning.jpg' -> 's3://images/test/test.jpg'[1 of 1] 980265 of 980265100% in1s491.31 KB/sdone[root@node11 ~]# s3cmd ls2022-10-08 11:18s3://images[root@node11 ~]# s3cmd ls s3://imagesDIRs3://images/test/[root@node11 ~]# s3cmd ls s3://images/test/2022-10-08 11:25980265s3://images/test/test.jpg[root@node11 ~]#
经验总结扩展阅读
- 记一次某制造业ERP系统 CPU打爆事故分析
- 没有使用IaC的DevOps系统都是耍流氓
- JuiceFS 元数据引擎选型指南
- 怎么用u盘重装系统
- 分布式存储系统之Ceph集群MDS扩展
- 苹果手机怎么删除系统软件
- win7升级到win10系统后,node13升级为node16,node版本node-sass版本与不匹配,导致出现npm ERR! ERESOLVE could not resolve
- day09-1存储引擎
- 手把手教你玩转 Gitea|在 Windows 系统上安装 Gitea
- 分布式存储系统之Ceph集群CephFS基础使用