参考这篇博客

  1. https://blog.csdn.net/for_tech/article/details/80271495

step 1

  1. 执行以下两条指令
  2. 在你的管理节点的工作目录下,给 Ceph 对象网关节点安装Ceph对象所需的软件包
  3. ceph-deploy install --rgw c4 c5 c6
  4. 新建网关实例
  5. ceph-deploy --overwrite rgw create c4 c5 c6
  6. 执行上面的命令不成功
  7. 分别在每个gw节点上执行:yum install ceph-radosgw,然后再执行:ceph-deploy --overwrite rgw create controller-03 controller-04 controller-05成功。
  8. 可以看到网关已经运行。
  9. ps aux | grep rados

2、在浏览器输入host:7480,可以看到正确运行

3、配置各节点网关

  1. c4执行:ceph auth get client.rgw.c4 > /etc/ceph/ceph.client.radosgw.keyring
  2. c5执行:ceph auth get client.rgw.c5 > /etc/ceph/ceph.client.radosgw.keyring
  3. c6执行:ceph auth get client.rgw.c6 > /etc/ceph/ceph.client.radosgw.keyring

5、创建cephgw存储池

6.创建radosgw用户进行访问

  1. radosgw-admin user create --uid="admin" --display-name="admin"
  2. [root@c4 ceph]# radosgw-admin user create --uid="admin" --display-name="admin"
  3. {
  4. "user_id": "admin",
  5. "display_name": "admin",
  6. "email": "",
  7. "suspended": 0,
  8. "max_buckets": 1000,
  9. "auid": 0,
  10. "subusers": [],
  11. "keys": [
  12. {
  13. "user": "admin",
  14. "access_key": "NB8SR8JU85V16ROBD4B3",
  15. "secret_key": "gkIxvICALUahng0MTlSXhNafdN2FVpwM0qDBTtRB"
  16. }
  17. ],
  18. "swift_keys": [],
  19. "caps": [],
  20. "op_mask": "read, write, delete",
  21. "default_placement": "",
  22. "placement_tags": [],
  23. "bucket_quota": {
  24. "enabled": false,
  25. "check_on_raw": false,
  26. "max_size": -1,
  27. "max_size_kb": 0,
  28. "max_objects": -1
  29. },
  30. "user_quota": {
  31. "enabled": false,
  32. "check_on_raw": false,
  33. "max_size": -1,
  34. "max_size_kb": 0,
  35. "max_objects": -1
  36. },
  37. "temp_url_keys": [],
  38. "type": "rgw",
  39. "mfa_ids": []
  40. }
  41. ======
  42. radosgw-admin user create --secret="123456" --uid="zhangsan" --display-name="zhangsan"

客户端对接

S3cmd客户端

步骤1:安装s3cmd

[root@node1 ~]# yum -y install s3cmd

步骤2:配置s3cmd

[root@node1 ~]# s3cmd —configure

  1. [root@c4 ceph]# s3cmd --configure
  2. Enter new values or accept defaults in brackets with Enter.
  3. Refer to user manual for detailed description of all options.
  4. Access key and Secret key are your identifiers for Amazon S3. Leave them empty for using the env variables.
  5. Access Key: NB8SR8JU85V16ROBD4B3
  6. Secret Key: gkIxvICALUahng0MTlSXhNafdN2FVpwM0qDBTtRB
  7. Default Region [US]:
  8. Use "s3.amazonaws.com" for S3 Endpoint and not modify it to the target Amazon S3.
  9. S3 Endpoint [s3.amazonaws.com]: c4:7480
  10. Use "%(bucket)s.s3.amazonaws.com" to the target Amazon S3. "%(bucket)s" and "%(location)s" vars can be used
  11. if the target S3 system supports dns based buckets.
  12. DNS-style bucket+hostname:port template for accessing a bucket [%(bucket)s.s3.amazonaws.com]: buket
  13. Encryption password is used to protect your files from reading
  14. by unauthorized persons while in transfer to S3
  15. Encryption password:
  16. Path to GPG program [/usr/bin/gpg]:
  17. When using secure HTTPS protocol all communication with Amazon S3
  18. servers is protected from 3rd party eavesdropping. This method is
  19. slower than plain HTTP, and can only be proxied with Python 2.7 or newer
  20. Use HTTPS protocol [Yes]: No
  21. On some networks all internet access must go through a HTTP proxy.
  22. Try setting it here if you can't connect to S3 directly
  23. HTTP Proxy server name:
  24. New settings:
  25. Access Key: NB8SR8JU85V16ROBD4B3
  26. Secret Key: gkIxvICALUahng0MTlSXhNafdN2FVpwM0qDBTtRB
  27. Default Region: US
  28. S3 Endpoint: c4:7480
  29. DNS-style bucket+hostname:port template for accessing a bucket: buket
  30. Encryption password:
  31. Path to GPG program: /usr/bin/gpg
  32. Use HTTPS protocol: False
  33. HTTP Proxy server name:
  34. HTTP Proxy server port: 0
  35. Test access with supplied credentials? [Y/n] n
  36. Save settings? [y/N] y
  37. Configuration saved to '/root/.s3cfg'
  38. [root@c4 ceph]#

步骤3:增删改查:

  1. [root@c4 ceph]# s3cmd mb s3://first_bucket
  2. Bucket 's3://first_bucket/' created
  3. [root@c4 ceph]# s3cmd -v ls
  4. 2019-04-25 08:40 s3://first_bucket
  5. [root@c4 ceph]# echo "aaaa" > file.txt
  6. [root@c4 ceph]# ls
  7. Make bucket
  8. s3cmd mb s3://BUCKET
  9. Remove bucket
  10. s3cmd rb s3://BUCKET
  11. List objects or buckets
  12. s3cmd ls [s3://BUCKET[/PREFIX]]
  13. List all object in all buckets
  14. s3cmd la
  15. Put file into bucket
  16. s3cmd put FILE [FILE...] s3://BUCKET[/PREFIX]
  17. Get file from bucket
  18. s3cmd get s3://BUCKET/OBJECT LOCAL_FILE