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.

81 lines
3.6 KiB

  1. Failover master server
  2. =======================
  3. Introduction
  4. ###################################
  5. Some user will ask for no single point of failure. Although google runs its file system with a single master for years, no SPOF seems becoming a criteria for architects to pick solutions.
  6. Luckily, it's not too difficult to enable Seaweed File System with failover master servers.
  7. Cheat Sheet: Startup multiple servers
  8. ########################################
  9. This section is a quick way to start 3 master servers and 3 volume servers. All done!
  10. .. code-block:: bash
  11. weed server -master.port=9333 -dir=./1 -volume.port=8080 \
  12. -master.peers=localhost:9333,localhost:9334,localhost:9335
  13. weed server -master.port=9334 -dir=./2 -volume.port=8081 \
  14. -master.peers=localhost:9333,localhost:9334,localhost:9335
  15. weed server -master.port=9335 -dir=./3 -volume.port=8082 \
  16. -master.peers=localhost:9333,localhost:9334,localhost:9335
  17. Or, you can use this "-peers" settings to add master servers one by one.
  18. .. code-block:: bash
  19. weed server -master.port=9333 -dir=./1 -volume.port=8080
  20. weed server -master.port=9334 -dir=./2 -volume.port=8081 -master.peers=localhost:9333
  21. weed server -master.port=9335 -dir=./3 -volume.port=8082 -master.peers=localhost:9334
  22. How it works
  23. ##########################
  24. The master servers are coordinated by Raft protocol, to elect a leader. The leader took over all the work to manage volumes, assign file ids. All other master servers just simply forward requests to the leader.
  25. If the leader dies, another leader will be elected. And all the volume servers will send their heartbeat together with their volumes information to the new leader. The new leader will take the full responsibility.
  26. During the transition, there could be moments where the new leader has partial information about all volume servers. This just means those yet-to-heartbeat volume servers will not be writable temporarily.
  27. Startup multiple master servers
  28. ###############################################
  29. Now let's start the master and volume servers separately, the usual way.
  30. Usually you would start several (3 or 5) master servers, then start the volume servers:
  31. .. code-block:: bash
  32. weed master -port=9333 -mdir=./1
  33. weed master -port=9334 -mdir=./2 -peers=localhost:9333
  34. weed master -port=9335 -mdir=./3 -peers=localhost:9334
  35. # now start the volume servers, specifying any one of the master server
  36. weed volume -dir=./1 -port=8080
  37. weed volume -dir=./2 -port=8081 -mserver=localhost:9334
  38. weed volume -dir=./3 -port=8082 -mserver=localhost:9335
  39. These 6 commands will actually functioning the same as the previous 3 commands from the cheatsheet.
  40. Even though we only specified one peer in "-peers" option to bootstrap, the master server will get to know all the other master servers in the cluster, and store these information in the local directory.
  41. When you need to restart
  42. If you need to restart the master servers, just run the master servers WITHOUT the "-peers" option.
  43. .. code-block:: bash
  44. weed master -port=9333 -mdir=./1
  45. weed master -port=9334 -mdir=./2
  46. weed master -port=9335 -mdir=./3
  47. To understand why, remember that the cluster information is "sticky", meaning it is stored on disk. If you restart the server, the cluster information stay the same, so the "-peers" option is not needed again.
  48. Common Problem
  49. ############################
  50. This "sticky" cluster information can cause some misunderstandings. For example, here is one:
  51. https://code.google.com/p/weed-fs/issues/detail?id=70
  52. The previously used value "localhost" would come up even not specified. This could cause your some time to figure out.