Skip to content

Instantly share code, notes, and snippets.

@bloodeagle40234
Created November 2, 2021 05:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bloodeagle40234/9c44f3a7bab47a2327364ccf6577f010 to your computer and use it in GitHub Desktop.
Save bloodeagle40234/9c44f3a7bab47a2327364ccf6577f010 to your computer and use it in GitHub Desktop.
#!/bin/bash
echo "create new ring"
swift-ring-builder account.builder create 10 3 0
swift-ring-builder account.builder add --region 1 --zone 1 --ip 10.0.0.51 --port 6002 --device sdb --weight 100
swift-ring-builder account.builder add --region 1 --zone 1 --ip 10.0.0.51 --port 6002 --device sdc --weight 100
swift-ring-builder account.builder add --region 1 --zone 2 --ip 10.0.0.52 --port 6002 --device sdb --weight 100
swift-ring-builder account.builder add --region 1 --zone 2 --ip 10.0.0.52 --port 6002 --device sdc --weight 100
swift-ring-builder account.builder rebalance
echo "you can see current balance"
swift-ring-builder account.builder
echo "add new device"
swift-ring-builder account.builder add --region 1 --zone 2 --ip 10.0.0.52 --port 6002 --device sdd --weight 100
echo "the rebalance has not happened yet, in-balance and show obsolete message here"
swift-ring-builder account.builder
echo "get rebalanced ring"
swift-ring-builder account.builder rebalance
echo "it should not be no more obsolete ring found"
swift-ring-builder account.builder
vagrant@saio:~/tmp/ring_test$ bash example_ring_create.sh
create new ring
Device d0r1z1-10.0.0.51:6002R10.0.0.51:6002/sdb_"" with 100.0 weight got id 0
Device d1r1z1-10.0.0.51:6002R10.0.0.51:6002/sdc_"" with 100.0 weight got id 1
Device d2r1z2-10.0.0.52:6002R10.0.0.52:6002/sdb_"" with 100.0 weight got id 2
Device d3r1z2-10.0.0.52:6002R10.0.0.52:6002/sdc_"" with 100.0 weight got id 3
Reassigned 3072 (300.00%) partitions. Balance is now 0.00. Dispersion is now 0.00
you can see current balance
account.builder, build version 5, id 9e9de5caa43843a39af85748970d0a84
1024 partitions, 3.000000 replicas, 1 regions, 2 zones, 4 devices, 0.00 balance, 0.00 dispersion
The minimum number of hours before a partition can be reassigned is 0 (0:00:00 remaining)
The overload factor is 0.00% (0.000000)
Ring file account.ring.gz is up-to-date
Devices: id region zone ip address:port replication ip:port name weight partitions balance flags meta
0 1 1 10.0.0.51:6002 10.0.0.51:6002 sdb 100.00 768 0.00
1 1 1 10.0.0.51:6002 10.0.0.51:6002 sdc 100.00 768 0.00
2 1 2 10.0.0.52:6002 10.0.0.52:6002 sdb 100.00 768 0.00
3 1 2 10.0.0.52:6002 10.0.0.52:6002 sdc 100.00 768 0.00
add new device
Device d4r1z2-10.0.0.52:6002R10.0.0.52:6002/sdd_"" with 100.0 weight got id 4
the rebalance has not happened yet, in-balance and show obsolete message here
account.builder, build version 6, id 9e9de5caa43843a39af85748970d0a84
1024 partitions, 3.000000 replicas, 1 regions, 2 zones, 5 devices, 100.00 balance, 0.00 dispersion
The minimum number of hours before a partition can be reassigned is 0 (0:00:00 remaining)
The overload factor is 0.00% (0.000000)
Ring file account.ring.gz is obsolete
Devices: id region zone ip address:port replication ip:port name weight partitions balance flags meta
0 1 1 10.0.0.51:6002 10.0.0.51:6002 sdb 100.00 768 25.00
1 1 1 10.0.0.51:6002 10.0.0.51:6002 sdc 100.00 768 25.00
2 1 2 10.0.0.52:6002 10.0.0.52:6002 sdb 100.00 768 25.00
3 1 2 10.0.0.52:6002 10.0.0.52:6002 sdc 100.00 768 25.00
4 1 2 10.0.0.52:6002 10.0.0.52:6002 sdd 100.00 0 -100.00
get rebalanced ring
Reassigned 614 (59.96%) partitions. Balance is now 0.10. Dispersion is now 0.00
it should not be no more obsolete ring found
account.builder, build version 7, id 9e9de5caa43843a39af85748970d0a84
1024 partitions, 3.000000 replicas, 1 regions, 2 zones, 5 devices, 0.10 balance, 0.00 dispersion
The minimum number of hours before a partition can be reassigned is 0 (0:00:00 remaining)
The overload factor is 0.00% (0.000000)
Ring file account.ring.gz is up-to-date
Devices: id region zone ip address:port replication ip:port name weight partitions balance flags meta
0 1 1 10.0.0.51:6002 10.0.0.51:6002 sdb 100.00 615 0.10
1 1 1 10.0.0.51:6002 10.0.0.51:6002 sdc 100.00 614 -0.07
2 1 2 10.0.0.52:6002 10.0.0.52:6002 sdb 100.00 615 0.10
3 1 2 10.0.0.52:6002 10.0.0.52:6002 sdc 100.00 614 -0.07
4 1 2 10.0.0.52:6002 10.0.0.52:6002 sdd 100.00 614 -0.07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment