From bab1989506c7f709e2f97f1c384cd2b0c818fba0 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Mon, 6 May 2019 13:31:08 -0700 Subject: [PATCH] Created Volume Management (markdown) --- Volume-Management.md | 47 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 Volume-Management.md diff --git a/Volume-Management.md b/Volume-Management.md new file mode 100644 index 0000000..30fe580 --- /dev/null +++ b/Volume-Management.md @@ -0,0 +1,47 @@ +When running large clusters, it is common to add more volume severs, or some volume servers are down, or some volume servers are replaced. These topology changes can cause missing volume replicas, or unbalanced number of volumes on volume servers. + +## Fix missing volumes +When running large clusters, it is common that some volume servers are down. If a volume is replicated and one replica is missing, the volume will be marked as readonly. + +One way to fix is to find one healthy copy and replicated to other servers, to meet the replication requirement. This volume id will be marked as writable. + +In `weed shell`, the command `volume.fix.replication` will do exactly that, automating the replication fixing process. You can start a crontab job to periodically run `volume.fix.replication` to ensure the system health. + +## Balance volumes +When running large clusters, it is common to add more volume severs, or some volume servers are down, or some volume servers are replaced. These topology changes can cause unbalanced number of volumes on volume servers. + +In `weed shell`, the command `volume.balance` will generate a balancing plan, and `volume.balance -f` will execute the balancing plan and move the actual volumes. + +The balancing plan will try to evenly spread the number of writable and readonly + +``` + For each type of volume server (different max volume count limit){ + for each collection { + balanceWritableVolumes() + balanceReadOnlyVolumes() + } + for all volumes { + balanceWritableVolumes() + balanceReadOnlyVolumes() + } + } + + func balanceWritableVolumes(){ + idealWritableVolumes = totalWritableVolumes / numVolumeServers + for { + sort all volume servers ordered by the number of local writable volumes + pick the volume server A with the lowest number of writable volumes x + pick the volume server B with the highest number of writable volumes y + if y > idealWritableVolumes and x +1 <= idealWritableVolumes { + if B has a writable volume id v that A does not have { + move writable volume v from A to B + } + } + } + } + func balanceReadOnlyVolumes(){ + //similar to balanceWritableVolumes + } + + +``` \ No newline at end of file