Making the Object Storage rings

The final step is to create the object ring, account ring, and container ring that each of our virtual nodes exists in. The OpenStack Object Storage rings keeps track of where our data exists in our cluster. There are three rings that OpenStack Object Storage understands: the account, container, and object rings. To facilitate quick rebuilding of the rings in our cluster, we will create a script that performs the necessary steps.

Getting ready

Ensure that you are logged in to the swift-proxy node and have the packages installed and configured for running Swift and have the five storage nodes installed and configured, as described earlier in this chapter. If you created the swift-proxy node with vagrant, you can execute the following command:

vagrant ssh swift-proxy

How to do it...

To create the three rings used by the OpenStack Object Storage service, carry out the following steps:

  1. The most convenient way to create the rings for our OpenStack Object Storage environment is to create a script. Create /usr/local/bin/remakerings with the following contents:

    Tip

    This file can be downloaded from http://bit.ly/OpenStackCookbookSwift.

    #!/bin/bash
    
    cd /etc/swift
    rm -f *.builder *.ring.gz backups/*.builder backups/*.ring.gz
    
    # Object Ring
    swift-ring-builder object.builder create 18 3 1
    swift-ring-builder object.builder add r1z1-172.16.0.221:6000/sdb1 1
    swift-ring-builder object.builder add r1z1-172.16.0.222:6000/sdb1 1
    swift-ring-builder object.builder add r1z1-172.16.0.223:6000/sdb1 1
    swift-ring-builder object.builder add r1z1-172.16.0.224:6000/sdb1 1
    swift-ring-builder object.builder add r1z1-172.16.0.225:6000/sdb1 1
    swift-ring-builder object.builder rebalance
    
    # Container Ring
    swift-ring-builder container.builder create 18 3 1
    swift-ring-builder container.builder add r1z1-172.16.0.221:6001/sdb1 1
    swift-ring-builder container.builder add r1z1-172.16.0.222:6001/sdb1 1
    swift-ring-builder container.builder add r1z1-172.16.0.223:6001/sdb1 1
    swift-ring-builder container.builder add r1z1-172.16.0.224:6001/sdb1 1
    swift-ring-builder container.builder add r1z1-172.16.0.225:6001/sdb1 1
    swift-ring-builder container.builder rebalance
    
    # Account Ring
    swift-ring-builder account.builder create 18 3 1
    swift-ring-builder account.builder add r1z1-172.16.0.221:6002/sdb1 1
    swift-ring-builder account.builder add r1z1-172.16.0.222:6002/sdb1 1
    swift-ring-builder account.builder add r1z1-172.16.0.223:6002/sdb1 1
    swift-ring-builder account.builder add r1z1-172.16.0.224:6002/sdb1 1
    swift-ring-builder account.builder add r1z1-172.16.0.225:6002/sdb1 1
    swift-ring-builder account.builder rebalance
  2. Now, we can run the script as follows:
    sudo chmod +x /usr/local/bin/remakerings
    sudo /usr/local/bin/remakerings
    

    You will see an output similar to this:

    How to do it...
  3. Once this has been completed (and this step can take a while), it creates three gzipped files in the /etc/swift directory called /etc/swift/account.ring.gz, /etc/swift/container.ring.gz, and /etc/swift/object.ring.gz. These files now need to be placed into the /etc/swift directory of all of our storage nodes.

Copy the *.gz files from the proxy server's /etc/swift directory to each of the storage node's /etc/swift directories.

How it works…

In Swift, a ring functions like a cereal box decoder ring. It keeps track of where various bits of data reside in a given Swift cluster. In our example, we have provided details for creating the rings, as well as executed a rebuild of said rings.

Creation of the rings is done using the swift-ring-builder command and involves the following steps, repeated for each ring type (object, container, and account):

  1. To create the ring, we use the following syntax:
    swift-ring-builder builder_file create 
        part_power replicas min_part_hours
    

    This syntax specifies the builder file to create three parameters—part_power, replicas, and min_part_hours. This means 2^part_power (18 is used in this instance) is the number of partitions to create, replicas are the number of replicas (3 is used in this case) of the data within the ring, and min_part_hours (1 is specified in this case) is the time in hours before a specific partition can be moved in succession.

  2. To assign a device to a ring, we use the following syntax:
    swift-ring-builder builder_file add 
        zzone-ip:port/device_name weight
    

    Adding a node to the ring specifies the same builder_file created in the first step. We then specify a zone (for example, 1, prefixed with z) that the device will be in; ip (172.16.0.222) is the IP address of the server that the device is in, port (for example, 6000) is the port number that the server is running on, and device_name is the name of the device on the server (for example, sdb1). The weight is a float weight that determines how many partitions are put on the device, relative to the rest of the devices in the cluster.

  3. A balanced Swift ring is one where the number of data exchanges between nodes is minimized, while still providing the configured number of replicas. A number of cases for rebalancing a Swift ring are provided in Chapter 6, Using OpenStack Object Storage, and Chapter 7, Administering OpenStack Object Storage. To rebalance the ring, we use the following syntax within the /etc/swift directory:
    swift-ring-builder builder_file rebalance
    

    The preceding command will distribute the partitions across the drives in the ring.

    The previous process is run for each of the rings—object, container, and account.

After the swift-ring-builder steps have finished, remember to copy the resultant account.ring.gz, container.ring.gz, and object.ring.gz files to each of the nodes in our environment, including other proxy servers we might have.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset