SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.
Go blob-storagecloud-drivedistributed-file-systemdistributed-storageerasure-codingfusehadoop-hdfshdfskuberneteslancelancedbobject-storageposixs3s3-storageseaweedfstiered-file-systemvector-search
ensure master server count is odd
Chris Lueca4b928d2b1
diff --git a/weed/command/master.go b/weed/command/master.goindex c1b9cf5aef..ac5902b60d 100644--- a/weed/command/master.go+++ b/weed/command/master.go@@ -35,7 +35,7 @@ var (masterIp = cmdMaster.Flag.String("ip", "localhost", "master <ip>|<server> address")masterBindIp = cmdMaster.Flag.String("ip.bind", "0.0.0.0", "ip address to bind to")metaFolder = cmdMaster.Flag.String("mdir", os.TempDir(), "data directory to store meta data")- masterPeers = cmdMaster.Flag.String("peers", "", "other master nodes in comma separated ip:port list, example: 127.0.0.1:9093,127.0.0.1:9094")+ masterPeers = cmdMaster.Flag.String("peers", "", "all master nodes in comma separated ip:port list, example: 127.0.0.1:9093,127.0.0.1:9094")volumeSizeLimitMB = cmdMaster.Flag.Uint("volumeSizeLimitMB", 30*1000, "Master stops directing writes to oversized volumes.")volumePreallocate = cmdMaster.Flag.Bool("volumePreallocate", false, "Preallocate disk space for volumes.")mpulse = cmdMaster.Flag.Int("pulseSeconds", 5, "number of seconds between heartbeats")@@ -86,11 +86,7 @@ func runMaster(cmd *Command, args []string) bool {go func() {time.Sleep(100 * time.Millisecond)- myMasterAddress := *masterIp + ":" + strconv.Itoa(*mport)- var peers []string- if *masterPeers != "" {- peers = strings.Split(*masterPeers, ",")- }+ myMasterAddress, peers := checkPeers(*masterIp, *mport, *masterPeers)raftServer := weed_server.NewRaftServer(r, peers, myMasterAddress, *metaFolder, ms.Topo, *mpulse)ms.SetRaftServer(raftServer)}()@@ -117,3 +113,27 @@ func runMaster(cmd *Command, args []string) bool {return true}++func checkPeers(masterIp string, masterPort int, peers string) (masterAddress string, cleanedPeers []string) {+ masterAddress = masterIp + ":" + strconv.Itoa(masterPort)+ if peers != "" {+ cleanedPeers = strings.Split(peers, ",")+ }++ hasSelf := false+ for _, peer := range cleanedPeers {+ if peer == masterAddress {+ hasSelf = true+ break+ }+ }++ peerCount := len(cleanedPeers)+ if !hasSelf {+ peerCount += 1+ }+ if peerCount %2 == 0 {+ glog.Fatalf("Only odd number of masters are supported!")+ }+ return+}diff --git a/weed/command/server.go b/weed/command/server.goindex 983b3075fc..b0c6a1ed5d 100644--- a/weed/command/server.go+++ b/weed/command/server.go@@ -58,7 +58,7 @@ var (serverDataCenter = cmdServer.Flag.String("dataCenter", "", "current volume server's data center name")serverRack = cmdServer.Flag.String("rack", "", "current volume server's rack name")serverWhiteListOption = cmdServer.Flag.String("whiteList", "", "comma separated Ip addresses having write permission. No limit if empty.")- serverPeers = cmdServer.Flag.String("master.peers", "", "other master nodes in comma separated ip:masterPort list")+ serverPeers = cmdServer.Flag.String("master.peers", "", "all master nodes in comma separated ip:masterPort list")serverSecureKey = cmdServer.Flag.String("secure.secret", "", "secret to encrypt Json Web Token(JWT)")serverGarbageThreshold = cmdServer.Flag.String("garbageThreshold", "0.3", "threshold to vacuum and reclaim spaces")masterPort = cmdServer.Flag.Int("master.port", 9333, "master server http listen port")@@ -191,11 +191,7 @@ func runServer(cmd *Command, args []string) bool {go func() {raftWaitForMaster.Wait()time.Sleep(100 * time.Millisecond)- myAddress := *serverIp + ":" + strconv.Itoa(*masterPort)- var peers []string- if *serverPeers != "" {- peers = strings.Split(*serverPeers, ",")- }+ myAddress, peers := checkPeers(*serverIp, *masterPort, *serverPeers)raftServer := weed_server.NewRaftServer(r, peers, myAddress, *masterMetaFolder, ms.Topo, *volumePulse)ms.SetRaftServer(raftServer)volumeWait.Done()