Multi Attach volume with Cinder to several VM

The ability to attach a volume to multiple hosts/servers simultaneously is a use case desired for active/active or active/standby scenarios. Support was added in both Cinder and Nova in the Queens release to volume multi-attach with read/write (RW) mode.

It is the responsibility of the user to ensure that a multiattach or clustered file system is used on the volumes. Otherwise there may be a high probability of data corruption.

Creation of the Volume Type in cinder

An admin should create the Volume type with the appropriate metadata (i.e. multiattach volume type):

$cinder type-create multiattach
$cinder type-key multiattach set multiattach="<is> True"

Usage of multiattach type Volume

  1. As user create a Volume from cli or dashboard as multiattach type (and keep the Id for next):

    cinder type-list
    +--------------------------------------+-------------+-------------+-----------+
    | ID                                   | Name        | Description | Is_Public |
    +--------------------------------------+-------------+-------------+-----------+
    | 7e8179fb-e350-426c-8eb8-b61a24c3f46c | multiattach | -           | True      |
    +--------------------------------------+-------------+-------------+-----------+
    
    $cinder create <volume_size> --name <volume_name> --volume-type <volume_type_uuid>
    ...
    | id                             | 9f3d7ec9-8f5d-4886-b36b-40dc6bbd3e08                   |
    ...
    | multiattach                    | True                                                   |
    ...
    
  2. Attach it to the servers you wish to use it in from cli or dashboard

    $ nova volume-attach test0_multiattach 9f3d7ec9-8f5d-4886-b36b-40dc6bbd3e08 auto
    +----------+--------------------------------------+
    | Property | Value                                |
    +----------+--------------------------------------+
    | device   | /dev/vdc                             |
    | id       | 9f3d7ec9-8f5d-4886-b36b-40dc6bbd3e08 |
    | serverId | bb1ce05d-214b-4d99-8adc-3083bbe749fb |
    | tag      | -                                    |
    | volumeId | 9f3d7ec9-8f5d-4886-b36b-40dc6bbd3e08 |
    +----------+--------------------------------------+
    .....
    

repeat with all the VM you need Please note that at the moment of writing there is a bug with the OpenStack commands (so my workaround is to use the nova commands) and it’s not possible to multiattach volumes using the Volume tab on the dashboard

  1. Check from cli or dashboard that the volume is attached to all VM:

    $openstack volume list|grep  multiattach
    | 33bb904b-d8c0-49a7-97d3-06444402282d | multiattach_vol             | in-use    |    1 | /
    Attached to test0_multiattach on /dev/vdb /
    Attached to test1_multiattach on /dev/vdb /
    Attached to test2_multiattach on /dev/vdb  |
    
  2. (optional) You can also retype a Volume from cli or dashboard (Please note that you cannot retype a bootable Volume):

    $cinder retype <volume> <volume_type>
    

or from the volume tab in the dashboard

../../../../_images/retype.png

refer to https://docs.openstack.org/cinder/latest/admin/blockstorage-volume-multiattach.html for details about multiattach volumes