You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

114 lines
3.2 KiB

  1. Use cases
  2. ===================
  3. Saving image with different sizes
  4. #############################
  5. Each image usually store one file key in database. However, one image can have several versions, e.g., thumbnail, small, medium, large, original. And each version of the same image will have a file key. It's not ideal to store all the keys.
  6. One way to resolve this is here.
  7. Reserve a set of file keys, for example, 5
  8. .. code-block:: bash
  9. curl http://<host>:<port>/dir/assign?count=5
  10. {"fid":"3,01637037d6","url":"127.0.0.1:8080","publicUrl":"localhost:8080","count":5}
  11. Save the 5 versions of the image to the volume server. The urls for each image can be:
  12. .. code-block:: bash
  13. http://<url>:<port>/3,01637037d6
  14. http://<url>:<port>/3,01637037d6_1
  15. http://<url>:<port>/3,01637037d6_2
  16. http://<url>:<port>/3,01637037d6_3
  17. http://<url>:<port>/3,01637037d6_4
  18. Overwriting mime types
  19. #############################
  20. The correct way to send mime type:
  21. .. code-block:: bash
  22. curl -F "file=@myImage.png;type=image/png" http://127.0.0.1:8081/5,2730a7f18b44
  23. The wrong way to send it:
  24. .. code-block:: bash
  25. curl -H "Content-Type:image/png" -F file=@myImage.png http://127.0.0.1:8080/5,2730a7f18b44
  26. Securing Seaweed-FS
  27. #############################
  28. The simple way is to front all master and volume servers with firewall.
  29. However, if blocking servicing port is not feasible or trivial, a white list option can be used. Only traffic from the white list IP addresses have write permission.
  30. .. code-block:: bash
  31. weed master -whiteList="::1,127.0.0.1"
  32. weed volume -whiteList="::1,127.0.0.1"
  33. # "::1" is for IP v6 localhost.
  34. Data Migration Example
  35. #############################
  36. .. code-block:: bash
  37. weed master -mdir="/tmp/mdata" -defaultReplication="001" -ip="localhost" -port=9334
  38. weed volume -dir=/tmp/vol1/ -mserver="localhost:9334" -ip="localhost" -port=8081
  39. weed volume -dir=/tmp/vol2/ -mserver="localhost:9334" -ip="localhost" -port=8082
  40. weed volume -dir=/tmp/vol3/ -mserver="localhost:9334" -ip="localhost" -port=8083
  41. .. code-block:: bash
  42. ls vol1 vol2 vol3
  43. vol1:
  44. 1.dat 1.idx 2.dat 2.idx 3.dat 3.idx 5.dat 5.idx
  45. vol2:
  46. 2.dat 2.idx 3.dat 3.idx 4.dat 4.idx 6.dat 6.idx
  47. vol3:
  48. 1.dat 1.idx 4.dat 4.idx 5.dat 5.idx 6.dat 6.idx
  49. stop all of them
  50. move vol3/* to vol1 and vol2
  51. it is ok to move x.dat and x.idx from one volumeserver to another volumeserver,
  52. because they are exactly the same.
  53. it can be checked by md5.
  54. .. code-block:: bash
  55. md5 vol1/1.dat vol2/1.dat
  56. MD5 (vol1/1.dat) = c1a49a0ee550b44fef9f8ae9e55215c7
  57. MD5 (vol2/1.dat) = c1a49a0ee550b44fef9f8ae9e55215c7
  58. md5 vol1/1.idx vol2/1.idx
  59. MD5 (vol1/1.idx) = b9edc95795dfb3b0f9063c9cc9ba8095
  60. MD5 (vol2/1.idx) = b9edc95795dfb3b0f9063c9cc9ba8095
  61. .. code-block:: bash
  62. ls vol1 vol2 vol3
  63. vol1:
  64. 1.dat 1.idx 2.dat 2.idx 3.dat 3.idx 4.dat 4.idx 5.dat 5.idx 6.dat 6.idx
  65. vol2:
  66. 1.dat 1.idx 2.dat 2.idx 3.dat 3.idx 4.dat 4.idx 5.dat 5.idx 6.dat 6.idx
  67. vol3:
  68. start
  69. .. code-block:: bash
  70. weed master -mdir="/tmp/mdata" -defaultReplication="001" -ip="localhost" -port=9334
  71. weed volume -dir=/tmp/vol1/ -mserver="localhost:9334" -ip="localhost" -port=8081
  72. weed volume -dir=/tmp/vol2/ -mserver="localhost:9334" -ip="localhost" -port=8082
  73. so we finished moving data of localhost:8083 to localhost:8081/localhost:8082