1、安装s3cmd
2、创建s3用户
  1. {
  2. "user_id": "admin",
  3. "display_name": "admin",
  4. "email": "",
  5. "suspended": 0,
  6. "max_buckets": 1000,
  7. "auid": 0,
  8. "subusers": [],
  9. "keys": [
  10. {
  11. "user": "admin",
  12. "access_key": "123456",
  13. "secret_key": "123456"
  14. }
  15. ],
  16. "swift_keys": [],
  17. "caps": [],
  18. "op_mask": "read, write, delete",
  19. "default_placement": "",
  20. "placement_tags": [],
  21. "bucket_quota": {
  22. "enabled": false,
  23. "check_on_raw": false,
  24. "max_size": -1,
  25. "max_size_kb": 0,
  26. "max_objects": -1
  27. },
  28. "user_quota": {
  29. "enabled": false,
  30. "max_size": -1,
  31. "max_size_kb": 0,
  32. "max_objects": -1
  33. },
  34. "temp_url_keys": [],
  35. "type": "rgw"
  36. }
3、配置s3cmd
  1. root目录下创建.s3cfg文件,并写入以下内容
  2. [root@node1 ~]# vim .s3cfg
  3. [default]
  4. access_key = 123456
  5. bucket_location = US
  6. cloudfront_host = 192.168.1.10:8080
  7. cloudfront_resource = /2010-07-15/distribution
  8. default_mime_type = binary/octet-stream
  9. delete_removed = False
  10. dry_run = False
  11. encoding = UTF-8
  12. encrypt = False
  13. follow_symlinks = False
  14. force = False
  15. get_continue = False
  16. gpg_command = /usr/bin/gpg
  17. gpg_decrypt = %(gpg_command)s -d --verbose --no-use-agent --batch --yes --passphrase-fd %(passphrase_fd)s -o %(output_file)s %(input_file)s
  18. gpg_encrypt = %(gpg_command)s -c --verbose --no-use-agent --batch --yes --passphrase-fd %(passphrase_fd)s -o %(output_file)s %(input_file)s
  19. gpg_passphrase =
  20. guess_mime_type = True
  21. host_base = 192.168.1.10:8080
  22. host_bucket = 192.168.1.10:8080/%(bucket)
  23. list_md5 = False
  24. log_target_prefix =
  25. preserve_attrs = True
  26. progress_meter = True
  27. proxy_host =
  28. proxy_port = 0
  29. recursive = False
  30. recv_chunk = 4096
  31. reduced_redundancy = False
  32. secret_key = 123456
  33. send_chunk = 96
  34. simpledb_host = sdb.amazonaws.com
  35. skip_existing = False
  36. socket_timeout = 300
  37. urlencoding_mode = normal
  38. use_https = False
  39. verbosity = WARNING
  40. signature_v2 = True
s3cmd 操作
1、创建bucket
  1. s3cmd mb s3://test
  2. Bucket 's3://test/' created
2、上传object
  1. # s3cmd put osd.sh s3://test
  2. upload: 'osd.sh' -> 's3://test/osd.sh' [1 of 1]
  3. 1472 of 1472 100% in 2s 628.87 B/s done
3、查看bucket
4、查看指定bucket内的object
  1. # s3cmd ls s3://test
  2. 2018-07-03 08:58 1472 s3://test/osd.sh
5、下载文件到本地
  1. # s3cmd get s3://test/osd.sh test.sh
  2. download: 's3://test/osd.sh' -> 'test.sh' [1 of 1]
  3. 1472 of 1472 100% in 0s 153.24 kB/s done
6、删除object
7、删除bucket
  1. # s3cmd rb s3://test/