三、对象存储
在使用对象存储之前,使用我们cephfs快照。(如果安装了块存储,这里的对象存储网关启动不了,原因不明。)
1、在 ceph-1 上通过 ceph-deploy 将 ceph-radosgw 软件包安装到 ceph-1 中
[root@ceph-1 ceph]# ceph-deploy install --rgw ceph-1
2、创建RGW服务
[root@ceph-1 ceph]# ceph-deploy rgw create ceph-1 [root@ceph-1 ceph]# ps -ef | grep radosgw ceph 2347 1 2 15:50 ? 00:00:00 /usr/bin/radosgw -f --cluster ceph --name client.rgw.ceph-1 --setuser ceph --setgroup ceph root 2962 1771 0 15:51 pts/0 00:00:00 grep --color=auto radosgw [root@ceph-1 ceph]# systemctl status ceph-radosgw\* ● ceph-radosgw@rgw.ceph-1.service - Ceph rados gateway Loaded: loaded (/usr/lib/systemd/system/ceph-radosgw@.service; enabled; vendor preset: disabled) Active: active (running) since Fri 2022-06-03 15:50:45 CST; 31s ago Main PID: 2347 (radosgw) CGroup: /system.slice/system-ceph\x2dradosgw.slice/ceph-radosgw@rgw.ceph-1.service └─2347 /usr/bin/radosgw -f --cluster ceph --name client.rgw.ceph-1 --setuser ceph --setgroup ceph Jun 03 15:50:45 ceph-1 systemd[1]: Started Ceph rados gateway. Jun 03 15:50:45 ceph-1 systemd[1]: Starting Ceph rados gateway...
3、访问RGW
RGW默认端口 7480
[root@ceph-1 ceph]# yum install -y net-tools [root@ceph-1 ceph]# netstat -tnplu Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name ... tcp 0 0 0.0.0.0:7480 0.0.0.0:* LISTEN 2347/radosgw
浏览器访问http://192.168.200.43:7480/
使用 S3 访问 RGW
1、创建 s3 的兼容用户
[root@ceph-1 ceph]# radosgw-admin user create --uid ceph-s3-user --display-name "Ceph S3 User Demo" ... "keys": [ { "user": "ceph-s3-user", "access_key": "V3J9L4M1WKV5O5ECAKPU", "secret_key":"f5LqLVYOVNu38cuQwi0jXC2ZTboCSJDmdvB8oeYw" ... }
access_key 与 secret_key 这里可以记录一下,也可以使用命令再次查看。
[root@ceph-1 ceph]# radosgw-admin user info --uid ceph-s3-user
使用命令行方式操作 rgw
1、配置命令行工具
[root@ceph-1 ceph]# yum -y install s3cmd [root@ceph-1 ceph]# 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: 82EWM49KPWGFVR0CWSD4 #输入用户Access Secret Key: 129CSMM9Dk3CC1lZwM7kn75lXMhrWBAMPEuyJL5k ##输入用户Secret Default Region [US]: #默认回车 Use "s3.amazonaws.com" for S3 Endpoint and not modify it to the target Amazon S3. S3 Endpoint [s3.amazonaws.com]: 192.168.200.43:7480 #输入Rgw服务地址 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 [%(bucket)s.s3.amazonaws.com]: 192.168.200.43:7480/%(bucket)s #输入 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 [Yes]: no #输入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: 82EWM49KPWGFVR0CWSD4 Secret Key: 129CSMM9Dk3CC1lZwM7kn75lXMhrWBAMPEuyJL5k Default Region: US S3 Endpoint: 192.168.200.43:7480 ##输入Rgw服务地址 DNS-style bucket+hostname:port template for accessing a bucket: 192.168.200.43:7480/%(bucket)s 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] y #输入y Please 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] y #输入y Configuration saved to '/root/.s3cfg'
2、这是需要修改版本,启用v2版本即可
[root@ceph-1 ~]# s3cmd mb s3://s3cmd-demo ERROR: S3 error: 403 (SignatureDoesNotMatch)
[root@ceph-1 ceph]# sed -i '/signature_v2/s/False/True/g' /root/.s3cfg
3、创建
[root@ceph-1 ceph]# s3cmd mb s3://s3cmd-demo Bucket 's3://s3cmd-demo/' created
4、上传
[root@ceph-1 ceph]# s3cmd put /etc/fstab s3://s3cmd-demo/fatab-demo upload: '/etc/fstab' -> 's3://s3cmd-demo/fatab-demo' [1 of 1] 541 of 541 100% in 1s 327.08 B/s done
5、下载
[root@ceph-1 ceph]# s3cmd get s3://s3cmd-demo/fatab-demo download: 's3://s3cmd-demo/fatab-demo' -> './fatab-demo' [1 of 1] 541 of 541 100% in 0s 39.79 KB/s done
6、删除
[root@ceph-1 ceph]# s3cmd del s3://s3cmd-demo/fatab-demo delete: 's3://s3cmd-demo/fatab-demo'