Installing, Configuring, and Verifying Swift
Swift, the OpenStack object storage project, stores and retrieves random and unstructured data objects. It provides high fault tolerance due to features such as multi-copy storage and elastic scaling. Unlike the traditional data storage directory tree, objects and files are stored in multiple drives.
Configuring Name Resolution
Perform the following operations on controller nodes and storage nodes.
- In etc/swift/swift.con, set the hostname of the first storage node to object1.
1hostnamectl set-hostname object1
In this example, only one object storage node is used. If there are multiple object storage nodes, set this parameter to object2, object3, and so on.
- Run the vim /etc/hosts command to open the /etc/hosts file and ensure that the file contains the following:
1 2 3
172.168.201.11 controller 172.168.201.12 compute 172.168.201.13 object1
- Restart the system to make the change take effect.
Configuring the Environment (Controller Node)
Perform the following operations on controller nodes.
- Log in to the OpenStack CLI as the admin user.
1source /etc/keystone/admin-openrc
- Create the Identity service credentials.
- Create the swift user.
1openstack user create --domain default --password-prompt swift

- Add the admin role to the swift user.
1openstack role add --project service --user swift admin
- Create the swift service entity.
1openstack service create --name swift --description "OpenStack Object Storage" object-store

- Create the swift user.
- Create API endpoints for the object storage service.
1 2 3
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

Installing and configuring Components (Controller Node)
Perform the following operations on controller nodes.
- Install the packages.
1yum -y install openstack-swift-proxy python-swiftclient python-keystoneclient python-keystonemiddleware memcached
- Obtain the proxy service configuration file from the object storage source repository.
1curl -o /etc/swift/proxy-server.conf https://opendev.org/openstack/swift/raw/branch/stable/rocky/etc/proxy-server.conf-sample --insecure

- Edit the etc/swift/proxy-server.conf file and make the following changes:
1vim /etc/swift/proxy-server.conf- Configure the port binding, user, and configuration directory.
1 2 3 4
[DEFAULT] bind_port = 8080 user = swift swift_dir = /etc/swift
- In the [pipeline:main] section, delete tempurl and tempauth and add authtoken and keystoneauth.
1 2
[pipeline:main] pipeline = catch_errors gatekeeper healthcheck proxy-logging cache container_sync bulk ratelimit authtoken keystoneauth container-quotas account-quotas slo dlo versioned_writes proxy-logging proxy-server
- In the [app:proxy-server] section, enable automatic account creation.
1 2 3
[app:proxy-server] use = egg:swift#proxy account_autocreate = True
- In the [filter:keystoneauth] section, configure the operator role.
1 2 3
[filter:keystoneauth] use = egg:swift#keystoneauth operator_roles = admin,user
- In the [filter:authtoken] section, configure Identity service access (comment out or delete any other options in the [filter:authtoken] section).
1 2 3 4 5 6 7 8 9 10 11 12
[filter:authtoken] paste.filter_factory = keystonemiddleware.auth_token:filter_factory www_authenticate_uri = http://controller:5000 auth_url = http://controller:5000/v3/ memcached_servers = controller:11211 auth_type = password project_domain_id = default user_domain_id = default project_name = service username = swift password = <PASSWORD> delay_auth_decision = True
In this document, all passwords are represented as <PASSWORD>. Use the actual password during the operation. The <PASSWORD> here is the password created for the swift user in Configuring the Environment (Controller Node).
- In the [filter:cache] section, configure the Memcached location.
1 2 3
[filter:cache] use = egg:swift#memcache memcache_servers = controller:11211
- Configure the port binding, user, and configuration directory.
Configuring the Environment (Storage Node)
Perform the following operations on storage nodes.
- Install the supporting utility package.
1yum -y install xfsprogs rsync

- Format the /dev/sdb and /dev/sdc devices as XFS.
1 2
mkfs.xfs /dev/sdb mkfs.xfs /dev/sdc

sdb and sdc cannot be system drives. Use other drives as system drives.
- Create the mount point directory structure.
1 2
mkdir -p /srv/node/sdb mkdir -p /srv/node/sdc
- Add the following to the /etc/fstab file:
1 2
/dev/sdb /srv/node/sdb xfs noatime,nodiratime,nobarrier,logbufs=8 0 2 /dev/sdc /srv/node/sdc xfs noatime,nodiratime,nobarrier,logbufs=8 0 2
- Mount the devices.
1 2
mount /dev/sdb /srv/node/sdb mount /dev/sdc /srv/node/sdc
- Create or edit the /etc/rsyncd.conf file to include the following content:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
uid = swift gid = swift log file = /var/log/rsyncd.log pid file = /var/run/rsyncd.pid address = 172.168.201.13 [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
address indicates the management network IP address of the storage node.
- Enable the rsyncd service and configure it to start as the system boots.
1 2
systemctl enable rsyncd.service systemctl start rsyncd.service
Installing and configuring Components (Storage Node)
Perform the following operations on storage nodes.
- Install OpenStack Rocky if it has not been installed. Otherwise, the next step cannot be performed.
- Clear the Yum cache.
1yum clean all
- Install the OpenStack Rocky software package.
1yum -y install centos-release-openstack-rocky
- Clear the Yum cache.
- Install the Swift software package.
1 2
yum -y install openstack-swift-account openstack-swift-container \ openstack-swift-object
- Obtain the accounting, container, and object service configuration files from the Object Storage source repository.
1 2 3
curl -o /etc/swift/account-server.conf https://opendev.org/openstack/swift/raw/branch/stable/rocky/etc/account-server.conf-sample curl -o /etc/swift/container-server.conf https://opendev.org/openstack/swift/raw/branch/stable/rocky/etc/container-server.conf-sample curl -o /etc/swift/object-server.conf https://opendev.org/openstack/swift/raw/branch/stable/rocky/etc/object-server.conf-sample

- Edit the etc/swift/account-server.conf file and make the following changes:
1vim /etc/swift/account-server.conf- In the [DEFAULT] section, configure the bind IP address, bind port, user, configuration directory, and mount point directory.
1 2 3 4 5 6 7
[DEFAULT] bind_ip = 172.168.201.13 bind_port = 6202 user = swift swift_dir = /etc/swift devices = /srv/node mount_check = True
bind_ip indicates the management network IP address of the storage node.
- In the [pipeline:main] section, enable the corresponding modules.
1 2
[pipeline:main] pipeline = healthcheck recon account-server
- In the [filter:recon] section, configure the recon (meters) cache directory.
1 2 3
[filter:recon] use = egg:swift#recon recon_cache_path = /var/cache/swift
- In the [DEFAULT] section, configure the bind IP address, bind port, user, configuration directory, and mount point directory.
- Edit the /etc/swift/container-server.conf file and make the following changes:
1vim /etc/swift/container-server.conf- In the [DEFAULT] section, configure the bind IP address, bind port, user, configuration directory, and mount point directory.
1 2 3 4 5 6 7
[DEFAULT] bind_ip = 172.168.201.13 bind_port = 6201 user = swift swift_dir = /etc/swift devices = /srv/node mount_check = True
bind_ip indicates the management network IP address of the storage node.
- In the [pipeline:main] section, enable the corresponding modules.
1 2
[pipeline:main] pipeline = healthcheck recon container-server
- In the [filter:recon] section, configure the recon cache directory.
1 2 3
[filter:recon] use = egg:swift#recon recon_cache_path = /var/cache/swift
- In the [DEFAULT] section, configure the bind IP address, bind port, user, configuration directory, and mount point directory.
- Edit the /etc/swift/object-server.conf file and make the following changes:
1vim /etc/swift/object-server.conf- In the [DEFAULT] section, configure the bind IP address, bind port, user, configuration directory, and mount point directory.
1 2 3 4 5 6 7
[DEFAULT] bind_ip = 172.168.201.13 bind_port = 6200 user = swift swift_dir = /etc/swift devices = /srv/node mount_check = True
bind_ip indicates the management network IP address of the storage node.
- In the [pipeline:main] section, enable the corresponding modules.
1 2
[pipeline:main] pipeline = healthcheck recon object-server
- In the [filter:recon] section, configure the recon (meters) cache and lock directories.
1 2 3 4
[filter:recon] use = egg:swift#recon recon_cache_path = /var/cache/swift recon_lock_path = /var/lock
- Ensure proper ownership of the mount point directory structure.
1 2
chown -R swift:swift /srv/node sudo restorecon -R /srv
- Create the recon directory and assign proper ownership.
1 2 3
mkdir -p /var/cache/swift chown -R root:swift /var/cache/swift chmod -R 775 /var/cache/swift
- In the [DEFAULT] section, configure the bind IP address, bind port, user, configuration directory, and mount point directory.
Creating an Account Ring
Perform the following operations on controller nodes.
- Switch to the /etc/swift directory.
1cd /etc/swift
- Create the base account.builder file.
1swift-ring-builder account.builder create 10 2 1
- Add each storage node to the ring.
1 2
swift-ring-builder account.builder add --region 1 --zone 1 --ip 172.168.201.13 --port 6202 --device sdb --weight 100 swift-ring-builder account.builder add --region 1 --zone 1 --ip 172.168.201.13 --port 6202 --device sdc --weight 100
The value following --ip is the management IP address of the storage node.
- Verify the account ring content.
1swift-ring-builder account.builder - Rebalance the ring.
1swift-ring-builder account.builder rebalance

Creating a Container Ring
Perform the following operations on controller nodes.
- Switch to the /etc/swift directory.
1cd /etc/swift
- Create the base container.builder file.
1swift-ring-builder container.builder create 10 2 1
- Add each storage node to the ring.
1 2
swift-ring-builder container.builder add --region 1 --zone 1 --ip 172.168.201.13 --port 6201 --device sdb --weight 100 swift-ring-builder container.builder add --region 1 --zone 1 --ip 172.168.201.13 --port 6201 --device sdc --weight 100
The value following --ip is the management IP address of the storage node.
- Verify the container ring content.
1swift-ring-builder container.builder - Rebalance the ring.
1swift-ring-builder container.builder rebalance

Creating an Object Ring
Perform the following operations on controller nodes.
- Switch to the /etc/swift directory.
1cd /etc/swift
- Create the base object.builder file.
1swift-ring-builder object.builder create 10 2 1
- Add each storage node to the ring.
1 2
swift-ring-builder object.builder add --region 1 --zone 1 --ip 172.168.201.13 --port 6200 --device sdb --weight 100 swift-ring-builder object.builder add --region 1 --zone 1 --ip 172.168.201.13 --port 6200 --device sdc --weight 100
The value following --ip is the management IP address of the storage node.
- Verify the object ring content.
1swift-ring-builder object.builder - Rebalance the ring.
1swift-ring-builder object.builder rebalance

Distributing Ring Configuration Files
Perform the following operations on controller nodes.
Copy the generated account.ring.gz, container.ring.gz, and object.ring.gz files to the /etc/swift directory on each storage node and any other node running the proxy service.
1 2 |
cd /etc/swift/ scp -r ./*.gz root@object1:/etc/swift/ |

Modifying Configuration
Perform the following operations on controller nodes.
- Obtain /etc/swift/swift.conf file from the Object Storage source repository.
1curl -o /etc/swift/swift.conf \https://opendev.org/openstack/swift/raw/branch/stable/rocky/etc/swift.conf-sample
- Edit the /etc/swift/swift.conf file and make the following changes:
1vim /etc/swift/swift.conf- In the [swift-hash] section, configure the hash path prefix and suffix for your environment.
1 2 3
[swift-hash] swift_hash_path_suffix = <PASSWORD> swift_hash_path_prefix = <PASSWORD>
Set the two parameters to unique strings of any characters.
- In the [storage-policy:0] section, set the default storage policy.
1 2 3
[storage-policy:0] name = Policy-0 default = yes
- In the [swift-hash] section, configure the hash path prefix and suffix for your environment.
- Copy the swift.conf file to the /etc/swift directory on each storage node. If there are multiple controller nodes, copy the file to the /etc/swift directory on other controller nodes.
Starting the Services
Perform the following operations on controller nodes and storage nodes.
- Ensure correct ownership of the configuration directory on all nodes.
1chown -R root:swift /etc/swift
- On the controller node and any other node running the proxy service, start the object storage agent service (including its dependencies) and configure it to start as the system boots.
1 2
systemctl enable openstack-swift-proxy.service memcached.service systemctl start openstack-swift-proxy.service memcached.service
- On the storage node, enable the object storage service and configure it to start as the system boots.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
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 status 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 status 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 systemctl status openstack-swift-object.service openstack-swift-object-auditor.service \ openstack-swift-object-replicator.service openstack-swift-object-updater.service
Verifying Swift
Perform the following operations on controller nodes.
- Log in to the OpenStack CLI as the admin user.
1source /etc/keystone/admin-openrc
- Check service status.
1swift stat
- Create the container1 container.
1openstack container create container1
- Upload the test file to container1.
1openstack object create container1 FILE
- List the files in container1.
1openstack object list container1

- Download the test file from container1.
1openstack object save container1 FILE

Common Swift Commands
Command |
Description |
|---|---|
swift stat |
Displays the Swift service status. |
openstack container create container1 |
Creates a storage container. |
openstack object create container1 FILE |
Uploads a file to a container. |
openstack container delete container1 |
Deletes a storage container. |
openstack object list container1 |
Lists the files in a container. |
openstack object save container1 FILE |
Downloads files from a container. |