Rate This Document
Findability
Accuracy
Completeness
Readability

Installing Swift

Swift provides a scalable and highly available distributed object storage service, which is suitable for storing unstructured data in large scale. Install Swift on the controller and storage nodes.

Installing Swift on the Controller Node

  1. Create a service credential.
    source ~/.admin-openrc
    openstack user create --domain default --password-prompt swift
    openstack role add --project service --user swift admin
    openstack service create --name swift --description "OpenStack Object Storage" object-store

    The password cannot contain the characters including #@$ and can contain the special characters including &=-_.+!*()

  2. Create Swift API endpoints.
    openstack endpoint create --region RegionOne object-store public http://controller:8080/v1/AUTH_%\(project_id\)s 
    openstack endpoint create --region RegionOne object-store internal http://controller:8080/v1/AUTH_%\(project_id\)s 
    openstack endpoint create --region RegionOne object-store admin http://controller:8080/v1
  3. Install the software package.
    yum install openstack-swift-proxy python3-swiftclient python3-keystoneclient python3-keystonemiddleware memcached
  4. Modify the proxy-server configuration file.

    The Swift RPM package contains a proxy-server.conf file which is basically ready to use. You only need to change the value of password in the file.

    1. Open the file.
      vi /etc/swift/proxy-server.conf
    2. Press i to enter the insert mode and modify the following variable:
      [filter:authtoken]
      password = SWIFT_PASSWORD

      Replace SWIFT_PASSWORD with the Swift user password.

    3. Press Esc to exit the insert mode. Type :wq! and press Enter to save the file and exit.

Installing Swift on the Storage Node

  1. Install and configure the program package supported by the storage.
    yum install xfsprogs rsync

    If the disaster recovery function is not required, you only need to create one device in steps 2 to 6, and skip the following rsync configuration in 7 and 8.

  2. Select two idle storage devices and format them to XFS. vdb and vdc are used as examples. Change them as required.
    mkfs.xfs -f /dev/vdb
    mkfs.xfs -f /dev/vdc
  3. Create a mount point directory structure.
    mkdir -p /srv/node/vdb
    mkdir -p /srv/node/vdc
  4. Find the UUID of the new partition.
    blkid
  5. Add the following content to the /etc/fstab file:
    UUID="<UUID-from-output-above>" /srv/node/vdb xfs noatime 0 2 
    UUID="<UUID-from-output-above>" /srv/node/vdc xfs noatime 0 2
  6. Mount the devices.
    mount /srv/node/vdb
    mount /srv/node/vdc
  7. Optional: Create or modify the /etc/rsyncd.conf file.
    1. Open the file.
      vi /etc/rsyncd.conf
    2. Press i to enter the insert mode. Modify or add the following content to the file:
      [DEFAULT] 
      uid = swift 
      gid = swift 
      log file = /var/log/rsyncd.log 
      pid file = /var/run/rsyncd.pid 
      address = MANAGEMENT_INTERFACE_IP_ADDRESS 
       
      [account] 
      max connections = 2 
      path = /srv/node/ 
      read only = False 
      lock file = /var/lock/account.lock 
       
      [container] 
      max connections = 2 
      path = /srv/node/ 
      read only = False 
      lock file = /var/lock/container.lock 
       
      [object] 
      max connections = 2 
      path = /srv/node/ 
      read only = False 
      lock file = /var/lock/object.lock

      Replace MANAGEMENT_INTERFACE_IP_ADDRESS with the management network IP address of the current node.

    3. Press Esc to exit the insert mode. Type :wq! and press Enter to save the file and exit.
  8. Start the rsyncd service and configure it to start upon system startup.
    systemctl enable rsyncd.service 
    systemctl start rsyncd.service
  9. Install the software package.
    yum install openstack-swift-account openstack-swift-container openstack-swift-object
  10. Modify account-server.conf, container-server.conf, and object-server.conf in the /etc/swift directory and change bind_ip to the management network IP address of the storage node.
  11. Ensure the proper ownership of the mount point directory structure.
    chown -R swift:swift /srv/node
  12. Create a recon directory and ensure that it has the correct ownership.
    mkdir -p /var/cache/swift 
    chown -R root:swift /var/cache/swift 
    chmod -R 775 /var/cache/swift

Configuring a Ring Account on the Controller Node

  1. Create an account ring.
    1. Switch to the /etc/swift directory.
      cd /etc/swift
    2. Create a basic account.builder file.
      swift-ring-builder account.builder create 10 1 1
    3. Add each storage node to the ring.
      swift-ring-builder account.builder add --region 1 --zone 1 --ip STORAGE_NODE_MANAGEMENT_INTERFACE_IP_ADDRESS --port 6202  --device DEVICE_NAME --weight DEVICE_WEIGHT
      • Replace STORAGE_NODE_MANAGEMENT_INTERFACE_IP_ADDRESS with the management network IP address of the storage node.
      • Replace DEVICE_NAME with the storage device name, for example, sda.
      • DEVICE_WEIGHT is the device search weight, that is, the number of virtual nodes corresponding to the node where the device resides in the hash ring. Generally, the value is 100.
    4. Verify the ring contents.
      swift-ring-builder account.builder
    5. Rebalance the ring.
      swift-ring-builder account.builder rebalance
  2. Create a container ring.
    1. Switch to the /etc/swift directory.
      cd /etc/swift
    2. Create a basic container.builder file.
      swift-ring-builder container.builder create 10 1 1
    3. Add each storage node to the ring.
      swift-ring-builder container.builder add --region 1 --zone 1 --ip STORAGE_NODE_MANAGEMENT_INTERFACE_IP_ADDRESS --port 6201 --device DEVICE_NAME --weight DEVICE_WEIGHT
      • Replace STORAGE_NODE_MANAGEMENT_INTERFACE_IP_ADDRESS with the management network IP address of the storage node.
      • Replace DEVICE_NAME with the storage device name, for example, sda.
      • DEVICE_WEIGHT is the device search weight, that is, the number of virtual nodes corresponding to the node where the device resides in the hash ring. Generally, the value is 100.
    4. Verify the ring contents.
      swift-ring-builder container.builder
    5. Rebalance the ring.
      swift-ring-builder container.builder rebalance
  3. Create an object ring.
    1. Switch to the /etc/swift directory.
      cd /etc/swift
    2. Create a basic object.builder file.
      swift-ring-builder object.builder create 10 1 1
    3. Add each storage node to the ring.
      swift-ring-builder object.builder add --region 1 --zone 1 --ip STORAGE_NODE_MANAGEMENT_INTERFACE_IP_ADDRESS --port 6200 --device DEVICE_NAME --weight DEVICE_WEIGHT
      • Replace STORAGE_NODE_MANAGEMENT_INTERFACE_IP_ADDRESS with the management network IP address of the storage node.
      • Replace DEVICE_NAME with the storage device name, for example, sda.
      • DEVICE_WEIGHT is the device search weight, that is, the number of virtual nodes corresponding to the node where the device resides in the hash ring. Generally, the value is 100.
    1. Verify the ring contents.
      swift-ring-builder object.builder
    2. Rebalance the ring.
      swift-ring-builder object.builder rebalance
  4. Install Swift.
    1. Open the /etc/swift/swift.conf file.
      vi /etc/swift/swift.conf
    2. Press i to enter the insert mode and add the following content to replace test-hash with a unique value:
      [swift-hash] 
      swift_hash_path_suffix = test-hash 
      swift_hash_path_prefix = test-hash 
       
      [storage-policy:0] 
      name = Policy-0 
      default = yes
    3. Press Esc to exit the insert mode. Type :wq! and press Enter to save the file and exit.
    4. Copy the swift.conf file to the /etc/swift directory on each storage node and any additional nodes running the proxy service.
    5. Ensure correct ownership of the configuration directory on all nodes.
      chown -R root:swift /etc/swift
    6. On the controller node and any additional nodes running the proxy service, start the object storage proxy service and its dependencies, and configure them to start upon system startup.
      systemctl enable openstack-swift-proxy.service memcached.service
      systemctl start openstack-swift-proxy.service memcached.service

Starting the Services

On the storage node, start the object storage services and configure them to start upon system startup.
systemctl enable openstack-swift-account.service openstack-swift-account-auditor.service openstack-swift-account-reaper.service openstack-swift-account-replicator.service 
systemctl start openstack-swift-account.service openstack-swift-account-auditor.service openstack-swift-account-reaper.service openstack-swift-account-replicator.service 
systemctl enable openstack-swift-container.service openstack-swift-container-auditor.service openstack-swift-container-replicator.service openstack-swift-container-updater.service 
systemctl start openstack-swift-container.service openstack-swift-container-auditor.service openstack-swift-container-replicator.service openstack-swift-container-updater.service 
systemctl enable openstack-swift-object.service openstack-swift-object-auditor.service openstack-swift-object-replicator.service openstack-swift-object-updater.service 
systemctl start openstack-swift-object.service openstack-swift-object-auditor.service openstack-swift-object-replicator.service openstack-swift-object-updater.service