当前位置: 首页 > 工具软件 > Swift-T > 使用案例 >

swift-ring-builder命令大全

冯阳成
2023-12-01
一 swift-ring-builder 命令
swift-ring-builder中包含多种命令:
add
create
list_parts
rebalance
remove
search
set_info
set_min_part_hours
set_weight
set_replicas
validate
write_ring
二 swift-ring-builder命令详细解释
swift-ring-builder <builder_file>
    Shows information about the ring and the devices within.
    显示ring以及ring中设备的信息,swift-1.8.0中对device新增了一个region属性

swift-ring-builder <builder_file> add
    z<zone>-<ip>:<port>/<device_name>_<meta> <weight>
    [z<zone>-<ip>:<port>/<device_name>_<meta> <weight>] ...
    Adds devices 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.
    使用给出的信息添加新的设备到ring上。add操作不会分配partitions到新的设备上,只有运行了'rebalance'命令后才会进行分区的分配。
   因此,这种机制可以允许你一次添加多个设备,并只执行一次rebalance实现对这些设备的分区分配。

swift-ring-builder <builder_file> create <part_power> <replicas> <min_part_hours>
    Creates <builder_file> with 2^<part_power> partitions and <replicas>.
    <min_part_hours> is number of hours to restrict moving a partition more
    than once.                                                                                                                  使用2的<part_power>次方个分区和<replicas>副本数创建<builder_file>.<min_part_hour>是一个分区被连续移动两次之间的最小时间间隔
swift-ring-builder <builder_file> 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. If there are a lot of devices to match against, this command
    could take a while to run.
  返回一个两列的列表,包含与搜索值相匹配的所有设备的所有分区。
  第一列是关联的分区编号
  第二列是与分区匹配的设备编号
  列表按匹配的编号大小从大到小排序,如果有很多设备与搜索符合,则这个命令需要多运行一会儿

swift-ring-builder <builder_file> rebalance
    Attempts to rebalance the ring by reassigning partitions that haven't been
    recently reassigned.
   rebalance命令尝试重新平衡环,通过重新分配分区最近没有被重新分配的分区。

swift-ring-builder <builder_file> remove <search-value> [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 to 0, wait for it to drain all its data, then use this
    remove command. This will not take effect until after running 'rebalance'.
    This is so you can make multiple device changes and rebalance them all just
    once.
   remove命令将设备从ring中移除。一般情况下,这个命令应该仅用在那些失败的设备上。
   如果你想将一个设备退役掉,那么最好的方式是将它的weight设置为0,待它将其上所有的数据都移走之后,再使用这个命令移除设备。
   remove操作不会重新分配partitions,只有运行了'rebalance'命令后才会进行分区的分配。因此,这种机制可以允许你一次添加删除个设备,并只执行一    次rebalance实现对这些设备的分区分配。

swift-ring-builder <builder_file> search <search-value>
    Shows information about matching devices.
   显示匹配的设备的信息

swift-ring-builder <builder_file> set_info
    <search-value> <ip>:<port>/<device_name>_<meta>
    [<search-value> <ip>:<port>/<device_name>_<meta>] ...
    For each search-value, resets the matched device's information.
    This information isn't used to assign partitions, so you can use
    'write_ring' afterward 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 instance set_info d74 _"snet: 5.6.7.8" would
    just update the meta data for device id 74.
   set_info命令会重新设置每一个与<search-value>相匹配的设备信息。这个信息不会用来重新分配分区,因此你可以使用'write_ring'来直接重写当前的     ring。
   <ip>:<port>/<device_name>_<meta>参数的任意一个部分都是可选的,你只需要给出你需要更改的部分。
   比如,set_info d74 _"snet: 5.6.7.8"就仅仅会把id为74的设备的元数据更新为"snet: 5.6.7.8"

swift-ring-builder <builder_file> 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_min_part_hours命令将<min_part_hours>设置为参数给定的<hours>.
   这个时间应该被设置的至少满足一个完整的replication/update周期。我们正在努力找到一个方法可以比看日志更简单的决定这个时间

swift-ring-builder <builder_file> set_weight <search-value> <weight>
    [<search-value> <weight] ...
    Resets the devices' weights. No partitions will be reassigned to or from
    the device until after running 'rebalance'. This is so you can make
    multiple device changes and rebalance them all just once.
   重新设置设备的weight。set_weight操作后,设备上的partition不会重新分配,只有运行了'rebalance'命令后才会进行分区的分配。
   因此,这种机制可以允许你一次添加多个设备,并只执行一次rebalance实现对这些设备的分区分配。
swift-ring-builder <builder_file> set_replicas <replicas>
  Changes the replica count to the given <replicas>. <replicas> may
  be a floating-point value, in which case some partitions will have
  floor(<replicas>) replicas and some will have ceiling(<replicas>)
  in the correct proportions.A rebalance is needed to make the change take effect.
  set_replicas命令用于使用参数中的<replicas>来设置副本数。
  <replicas>可以是一个浮点数,因此在一些场景中一些分区的副本数可能是floor(<replicas>),也可能是(<replicas>),这取决于正确的比例。
  需要执行一个rebalance命令来使副本设置生效。该命令是swift-1.8.0新增的。

swift-ring-builder <builder_file> validate
    Just runs the validation routines on the ring.
    仅运行builder的validate方法,使ring生效

swift-ring-builder <builder_file> 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 more
    'set_info' calls when no rebalance is needed but you want to send out the
    new device information.
   write_ring命令仅是用来重写分部环境下的ring文件。这个命令会在成功执行一个rebalance操作后呗自动执行。
   因此,它仅在你执行了一次或多次'set_info'命令,不想rebalance却想保留新信息时使用。
三 参考
 类似资料: