swift-ring-builder(1)
πΈ NAME πΈ
swift-ring-builder β the OpenStack Swift ring builder, aka the lil tool that decides where your data actually lives π (yes bestie, this is the swift-ring-builder(1) page, pull up a chair)
π¦ SYNOPSIS π¦
swift-ring-builder <builder_file> <commands> <arguments> <...>
β¨ DESCRIPTION β¨
Okay so swift-ring-builder is the utility you use to create, search and manipulate the swift storage ring. It assigns partitions to devices and writes an optimized Python structure out to a gzipped, pickled file on disk so you can ship it out to the servers. The server processes are lowkey chill about it β they just check the modification time of the file every so often and reload their in-memory copies of the ring structure as needed. And because of how the ring-builder manages changes to the ring, using a slightly older ring usually just means one of the three replicas for a subset of the partitions will be incorrect, which can be easily worked around. Not a crisis. We cope. π
The ring-builder also keeps its own builder file with the ring information and the extra data it needs to build future rings. And bestie, listen to me: it is VERY important to keep multiple backup copies of these builder files. One option is to copy the builder files out to every server while you're copying the ring files themselves. Another is to upload the builder files into the cluster itself. Complete loss of a builder file means creating a new ring from scratch, nearly all partitions will end up assigned to different devices, and therefore nearly all data stored will have to be replicated to new locations. So yeah, recovery from a builder file loss is possible, but data will definitely be unreachable for an extended time. π
Also! If you invoke it asswift-ring-builder-safe, the directory containing the builder file you provided will be locked (via a.lockfile in the files parent directory). This gives you a basic safe guard against multiple instances of the swift-ring-builder (or other utilities that observe this lock) from attempting to write to or read the builder/ring files while operations are in progress. That's genuinely useful in environments where ring management has been automated but the operator still needs to interact with the rings manually. Iconic, honestly. π
π SEARCH π
<search-value> β here's the form it can take:
d<device_id>r<region>z<zone>-<ip>:<port>/<device_name>_<meta>
Every part is optional, but you must include at least one. Examples, bestie:
d74β matches the device id 74z1β matches devices in zone 1z1-1.2.3.4β matches devices in zone 1 with the ip 1.2.3.41.2.3.4β matches devices in any zone with the ip 1.2.3.4r1z1:5678β matches devices in zone 1 present in region 1 using port 5678z1:5678β matches devices in zone 1 using port 5678:5678β matches devices that use port 5678/sdb1β matches devices with the device name sdb1_shinyβ matches devices with shiny in the meta data_'snet: 5.6.7.8'β matches devices with snet: 5.6.7.8 in the meta data[::1]β matches devices in any zone with the ip ::1z1-[::1]:5678β matches devices in zone 1 with ip ::1 and port 5678
Most specific example ever, the full flex:
d74z1-1.2.3.4:5678/sdb1_"snet: 5.6.7.8"
Nerd explanation (this is the iykyk part):
All items require their single character prefix except the ip, in which case the - is optional unless the device id or zone is also included.
π OPTIONS π
-y,--yesβ assume a yes response to all questions. no more clicking through prompts like it's a pop-up ad, she just says yes for you π«Ά
π COMMANDS π
<builder_file>β shows information about the ring and the devices within. just hand her the file, she spills the tea.search <search-value>β shows information about matching devices. πadd z<zone>-<ip>:<port>/<device_name>_<meta> <weight>add r<region>z<zone>-<ip>:<port>/<device_name>_<meta> <weight>add -r <region> -z <zone> -i <ip> -p <port> -d <device_name> -m <meta> -w <weight>
Adds a device to the ring with the given information. No partitions will be assigned to the new device until after running rebalance. This is so you can make multiple device changes and rebalance them all just once. efficiency queen β¨
create <part_power> <replicas> <min_part_hours>β creates<builder_file>with2^<part_power>partitions and<replicas>.<min_part_hours>is number of hours to restrict moving a partition more than once.list_parts <search-value> [<search-value>] ..β returns a 2 column list of all the partitions that are assigned to any of the devices matching the search values given. The first column is the assigned partition number and the second column is the number of device matches for that partition. The list is ordered from most number of matches to least. Heads up: if there are a lot of devices to match against, this command could take a while to run. πrebalanceβ attempts to rebalance the ring by reassigning partitions that haven't been recently reassigned.remove <search-value>β removes the device(s) from the ring. This should normally just be used for a device that has failed. For a device you wish to decommission, it's best to set its weight to0, wait for it to drain all its data, then use this remove command. This will not take effect until after runningrebalance. This is so you can make multiple device changes and rebalance them all just once.set_info <search-value> <ip>:<port>/<device_name>_<meta>β resets the device's information. This information isn't used to assign partitions, so you can usewrite_ringafterward to rewrite the current ring with the newer device information. Any of the parts are optional in the final<ip>:<port>/<device_name>_<meta>parameter; just give what you want to change. For instanceset_info d74 _"snet: 5.6.7.8"would just update the meta data for device id 74.set_min_part_hours <hours>β changes the<min_part_hours>to the given<hours>. This should be set to however long a full replication/update cycle takes. We're working on a way to determine this more easily than scanning logs. πset_weight <search-value> <weight>β resets the device's weight. No partitions will be reassigned to or from the device until after runningrebalance. This is so you can make multiple device changes and rebalance them all just once.validateβ just runs the validation routines on the ring.write_ringβ just rewrites the distributable ring file. This is done automatically after a successful rebalance, so really this is only useful after one or moreset_infocalls when no rebalance is needed but you want to send out the new device information.
Quick list, screenshot it bestie: add create list_parts rebalance remove search set_info set_min_part_hours set_weight validate write_ring
Exit codes: 0 = ring changed, 1 = ring did not change, 2 = error
π DOCUMENTATION π
More in depth documentation about the swift ring and also OpenStack Swift as a whole can be found at:
https://docs.openstack.org/swift/latest/overview_ring.htmlhttps://docs.openstack.org/swift/latest/admin_guide.html#managing-the-ringshttps://docs.openstack.org/swift/latest/
and that's the whole page, bestie π written Linux-flavored, dated 8/26/2011, and it's the swift-ring-builder(1) era β go forth and keep backups of your builder files, I am BEGGING you πβ¨
π¦ where this page comes from
- debian bookworm: swift 2.30.1-0+deb12u1 Β· Apache-2
- debian bookworm: swift 2.30.1-0+deb12u3 Β· Apache-2
- debian trixie: swift 2.35.1-0+deb13u3 Β· Apache-2
- debian trixie: swift 2.35.1-0+deb13u4 Β· Apache-2
- nixos 26.05: python3.13-swift 2.37.1
- nixos 26.05: python3.14-swift 2.37.1
- nixpkgs unstable: python3.13-swift 2.38.3
- nixpkgs unstable: python3.14-swift 2.38.3
- ubuntu jammy: swift 2.29.1-0ubuntu1 Β· Apache-2
- ubuntu jammy: swift 2.29.2-0ubuntu1.1 Β· Apache-2
- ubuntu noble: swift 2.33.0-0ubuntu1 Β· Apache-2
- ubuntu noble: swift 2.33.0-0ubuntu1.1 Β· Apache-2
- ubuntu questing: swift 2.36.0-0ubuntu1
- ubuntu questing: swift 2.36.0-0ubuntu1.1
- ubuntu resolute: swift 2.37.1-0ubuntu2 Β· Apache-2
- ubuntu resolute: swift 2.37.1-0ubuntu2.1 Β· Apache-2
- ubuntu stonking: swift 2.38.2-0ubuntu1 Β· Apache-2
- Copyright (c) 2010-2011 OpenStack Foundation
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms