Rechercher

Ce contenu n'est pas disponible dans la langue sélectionnée.

Chapter 3. Performing basic operations with the Block Storage service (cinder)

download PDF

Create and configure Block Storage volumes as the primary form of persistent storage for Compute instances in your overcloud. Create volumes, attach your volumes to instances, edit and resize your volumes, and modify volume ownership.

3.1. Creating Block Storage volumes

Create volumes to provide persistent storage for instances that you launch with the Compute service (nova) in the overcloud.

To create an encrypted volume, you must first have a volume type configured specifically for volume encryption. In addition, you must configure both Compute and Block Storage services to use the same static key. For information about how to set up the requirements for volume encryption, see Block Storage service (cinder) volume encryption.

Important

The default maximum number of volumes you can create for a project is 10.

Prerequisites

Procedure

  1. Log into the dashboard.
  2. Select Project > Compute > Volumes.
  3. Click Create Volume, and edit the following fields:

    FieldDescription

    Volume name

    Name of the volume.

    Description

    Optional, short description of the volume.

    Type

    Optional volume type. For more information, see Group volume configuration with volume types.

    If you create a volume and do not specify a volume type, then Block Storage uses the default volume type. For more information on defining default volume types, see Defining a project-specific default volume type.

    If you do not specify a back end, the Block Storage scheduler will try to select a suitable back end for you. For more information, see Volume allocation on multiple back ends.

    Note

    If there is no suitable back end then the volume will not be created.

    You can also change the volume type after the volume has been created. For more information, see Block Storage volume retyping.

    Size (GB)

    Volume size (in gigabytes).

    If you want to create an encrypted volume from an unencrypted image, you must ensure that the volume size is larger than the image size so that the encryption data does not truncate the volume data.

    Availability Zone

    Availability zones (logical server groups), along with host aggregates, are a common method for segregating resources within OpenStack. Availability zones are defined during installation. For more information about availability zones and host aggregates, see Creating and managing host aggregates in the Configuring the Compute service for instance creation guide.

  4. Specify a Volume Source:

    SourceDescription

    No source, empty volume

    The volume is empty and does not contain

    a file system or partition table.

    Snapshot

    Use an existing snapshot as a volume source. If you select this option, a new Use snapshot as a source list opens; you can then choose a snapshot from the list. If you want to create a new volume from a snapshot of an encrypted volume, you must ensure that the new volume is at least 1GB larger than the old volume. For more information about volume snapshots, see Creating new volumes from snapshots.

    Image

    Use an existing image as a volume source. If you select this option, a new Use snapshot as a source list opens; you can then choose an image from the list.

    Volume

    Use an existing volume as a volume source. If you select this option, a new Use snapshot as a source list opens; you can then choose a volume from the list.

  5. Click Create Volume. After the volume is created, its name appears in the Volumes table.

3.2. Editing a volume name or description

You can change the names and descriptions of your volumes in the dashboard.

Prerequisites

Procedure

  1. Log into the dashboard.
  2. Select Project > Compute > Volumes.
  3. Select the volume’s Edit Volume button.
  4. Edit the volume name or description as required.
  5. Click Edit Volume to save your changes.

3.3. Resizing (extending) a Block Storage service volume

Resize volumes to increase the storage capacity of the volumes.

Note

The ability to resize a volume in use is supported but is driver dependent. RBD is supported. You cannot extend in-use multi-attach volumes. For more information about support for this feature, contact Red Hat Support.

Procedure

  1. Source your credentials file.
  2. List the volumes to retrieve the ID of the volume you want to extend:

    $ cinder list
  3. Increase the size of the volume:

    $ cinder extend <volume_id> <size>
    • Replace <volume_id> with the ID of the volume you want to extend.
    • Replace <size> with the required size of this volume, in gigabytes.

      Note

      Ensure that the specified size is greater than the existing size of this volume.

      For example:

      $ cinder extend 573e024d-5235-49ce-8332-be1576d323f8 10

3.4. Deleting a Block Storage service volume

You can delete volumes that you no longer require.

Note

You cannot delete a volume if it has existing snapshots. For more information about deleting snapshots, see Deleting volume snapshots.

Prerequisites

Procedure

  1. Log into the dashboard.
  2. Select Project > Compute > Volumes.
  3. In the Volumes table, select the volume to delete.
  4. Click Delete Volumes.

3.5. Volume allocation on multiple back ends

When you create a volume, you can select the volume type for the required back end from the Type list. For more information, see Creating Block Storage volumes.

Note

If the Block Storage service (cinder) is configured to use multiple back ends, then a volume type must be created for each back end.

If you do not specify a back end when creating the volume, the Block Storage scheduler will try to select a suitable back end for you.

The scheduler uses filters, for the following default associated settings of the volume, to select suitable back ends:

AvailabilityZoneFilter
Filters out all back ends that do not meet the availability zone requirements of the requested volume.
CapacityFilter
Selects only back ends with enough space to accommodate the volume.
CapabilitiesFilter
Selects only back ends that can support any specified settings in the volume.
InstanceLocality
Configures clusters to use volumes local to the same node.

If there is more than one suitable back end, then the scheduler uses a weighting method to pick the best back end. By default, the CapacityWeigher method is used, so that the filtered back end with the most available free space is selected.

Note

If there is no suitable back end then the volume will not be created.

3.6. Attaching a volume to an instance

When you close an instance all the data is lost. You can attach a volume for persistent storage. You can attach a volume to only one instance at a time, unless it has a multi-attach volume type. For more information about creating multi-attach volumes, see Volumes that can be attached to multiple instances.

Prerequisites

Procedure

  1. Log into the dashboard.
  2. Select Project > Compute > Volumes.
  3. Select the Edit Attachments action. If the volume is not attached to an instance, the Attach To Instance drop-down list is visible.
  4. From the Attach To Instance list, select the instance to which you want to attach the volume.
  5. Click Attach Volume.

3.7. Detaching a volume from an instance

You must detach a volume from an instance when you want to attach this volume to another instance, unless it has a multi-attach volume type. You must also detach a volume to change the access permissions to the volume or to delete the volume.

Prerequisites

Procedure

  1. Log into the dashboard.
  2. Select Project > Compute > Volumes.
  3. Select the volume’s Manage Attachments action. If the volume is attached to an instance, the instance’s name is displayed in the Attachments table.
  4. Click Detach Volume in this and the next dialog screen.

3.8. Configuring the access rights to a volume

The default state of a volume is read-write to allow data to be written to and read from it. You can mark a volume as read-only to protect its data from being accidentally overwritten or deleted.

Note

After changing a volume to be read-only you can change it back to read-write again.

Prerequisites

Procedure

  1. Source your credentials file.
  2. List the volumes to retrieve the ID of the volume you want to configure:

    $ cinder list
  3. Set the required access rights for this volume:

    • To set the access rights of a volume to read-only:

      $ cinder readonly-mode-update <volume_id> true
      • Replace <volume_id> with the ID of the required volume.
    • To set the access rights of a volume to read-write:

      $ cinder readonly-mode-update <volume_id> false
  4. If you detached this volume from an instance to change the access rights, then re-attach the volume. For more information, see Attaching a volume to an instance.

3.9. Changing a volume owner with the Dashboard

To change a volume’s owner, you will have to perform a volume transfer. A volume transfer is initiated by the volume’s owner, and the volume’s change in ownership is complete after the transfer is accepted by the volume’s new owner.

Prerequisites

Procedure

  1. Log into the dashboard as the volume owner.
  2. Select Projects > Volumes.
  3. In the Actions column of the volume to transfer, select Create Transfer.
  4. In the Create Transfer dialog box, enter a name for the transfer and click Create Volume Transfer.

    The volume transfer is created, and in the Volume Transfer screen you can capture the transfer ID and the authorization key to send to the recipient project.

    Click the Download transfer credentials button to download a .txt file containing the transfer name, transfer ID, and authorization key.

    Note

    The authorization key is available only in the Volume Transfer screen. If you lose the authorization key, you must cancel the transfer and create another transfer to generate a new authorization key.

  5. Close the Volume Transfer screen to return to the volume list.

    The volume status changes to awaiting-transfer until the recipient project accepts the transfer

Accept a volume transfer from the dashboard

  1. Log into the dashboard as the recipient project owner.
  2. Select Projects > Volumes.
  3. Click Accept Transfer.
  4. In the Accept Volume Transfer dialog box, enter the transfer ID and the authorization key that you received from the volume owner and click Accept Volume Transfer.

    The volume now appears in the volume list for the active project.

3.10. Changing a volume owner with the CLI

To change a volume’s owner, you will have to perform a volume transfer. A volume transfer is initiated by the volume’s owner, and the volume’s change in ownership is complete after the transfer is accepted by the volume’s new owner.

Procedure

  1. Log in as the volume’s current owner.
  2. List the available volumes:

    $ cinder list
  3. Initiate the volume transfer:

    $ cinder transfer-create <volume>

    Replace <volume> with the name or ID of the volume you wish to transfer. For example:

      +------------+--------------------------------------+
      |  Property  |                Value                 |
      +------------+--------------------------------------+
      |  auth_key  |           f03bf51ce7ead189           |
      | created_at |      2014-12-08T03:46:31.884066      |
      |     id     | 3f5dc551-c675-4205-a13a-d30f88527490 |
      |    name    |                 None                 |
      | volume_id  | bcf7d015-4843-464c-880d-7376851ca728 |
      +------------+--------------------------------------+

    The cinder transfer-create command clears the ownership of the volume and creates an id and auth_key for the transfer. These values can be given to, and used by, another user to accept the transfer and become the new owner of the volume.

  4. The new user can now claim ownership of the volume. To do so, the user should first log in from the command line and run:

    $ cinder transfer-accept <transfer_id> <transfer_key>
    • Replace <transfer_id> with the id value returned by the cinder transfer-create command.
    • Replace <transfer_key> with the auth_key value returned by the cinder transfer-create command.

      For example:

      $ cinder transfer-accept 3f5dc551-c675-4205-a13a-d30f88527490 f03bf51ce7ead189
Note

You can view all available volume transfers using:

$ cinder transfer-list
Red Hat logoGithubRedditYoutubeTwitter

Apprendre

Essayez, achetez et vendez

Communautés

À propos de la documentation Red Hat

Nous aidons les utilisateurs de Red Hat à innover et à atteindre leurs objectifs grâce à nos produits et services avec un contenu auquel ils peuvent faire confiance.

Rendre l’open source plus inclusif

Red Hat s'engage à remplacer le langage problématique dans notre code, notre documentation et nos propriétés Web. Pour plus de détails, consultez leBlog Red Hat.

À propos de Red Hat

Nous proposons des solutions renforcées qui facilitent le travail des entreprises sur plusieurs plates-formes et environnements, du centre de données central à la périphérie du réseau.

© 2024 Red Hat, Inc.