6. cinder - Block Storage

 

介紹

cinder-api: Accepts API requests and routes them to cinder-volume for action.[Block Storage services]

cinder-volume: Responds to requests to read from and write to the Block Storage database to maintain state, interacting with other processes
                          (like cinder-scheduler)[provides storage]

cinder-scheduler daemon: picks the optimal block storage provider node on which to create the volume

Messaging queue: Routes information between the Block Storage service processes.

 

 

Controller node:

 

安裝:

yum install openstack-cinder

建立 DB:

mysql -u root -p
mysql> CREATE DATABASE cinder;
mysql> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' IDENTIFIED BY 'CINDER_DBPASS';
mysql> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%' IDENTIFIED BY 'CINDER_DBPASS';
mysql> flush privileges;
mysql> exit

設定 DB Setting:

openstack-config --set /etc/cinder/cinder.conf database connection mysql://cinder:CINDER_DBPASS@controller_pri/cinder

建立 Tables:

su -s /bin/sh -c "cinder-manage db sync" cinder

設定:

keystone user-create --name=cinder --pass=CINDER_PASS [email protected]

+----------+----------------------------------+
| Property |              Value               |
+----------+----------------------------------+
|  email   |      [email protected]       |
| enabled  |               True               |
|    id    | 57e1f66f361a4bec874984e9fcf28f7b |
|   name   |              cinder              |
| username |              cinder              |
+----------+----------------------------------+

keystone user-role-add --user=cinder --tenant=service --role=admin

設定 keystone:

openstack-config --set /etc/cinder/cinder.conf DEFAULT auth_strategy keystone
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_uri http://controller_pri:5000
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_host controller_pri
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_protocol http
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_port 35357
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken admin_user cinder
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken admin_tenant_name service
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken admin_password CINDER_PASS

設定 Q:

openstack-config --set /etc/cinder/cinder.conf DEFAULT rpc_backend cinder.openstack.common.rpc.impl_qpid
openstack-config --set /etc/cinder/cinder.conf DEFAULT qpid_hostname controller_pri

設定 Service:

# V1

keystone service-create --name=cinder --type=volume --description="OpenStack Block Storage"

keystone endpoint-create \
--service-id=$(keystone service-list | awk '/ volume / {print $2}') \
--publicurl=http://controller_pub:8776/v1/%\(tenant_id\)s \
--internalurl=http://controller_pri:8776/v1/%\(tenant_id\)s \
--adminurl=http://controller_pri:8776/v1/%\(tenant_id\)s

# V2

keystone service-create --name=cinderv2 --type=volumev2 --description="OpenStack Block Storage v2"

+-------------+----------------------------------+
|   Property  |              Value               |
+-------------+----------------------------------+
| description |    OpenStack Block Storage v2    |
|   enabled   |               True               |
|      id     | 3aff42079cde4d4ab2b57e4719272b5e |
|     name    |             cinderv2             |
|     type    |             volumev2             |
+-------------+----------------------------------+

keystone endpoint-create \
--service-id=$(keystone service-list | awk '/ volumev2 / {print $2}') \
--publicurl=http://controller_pub:8776/v2/%\(tenant_id\)s \
--internalurl=http://controller_pri:8776/v2/%\(tenant_id\)s \
--adminurl=http://controller_pri:8776/v2/%\(tenant_id\)s

+-------------+---------------------------------------------+
|   Property  |                    Value                    |
+-------------+---------------------------------------------+
|   adminurl  | http://controller_pri:8776/v2/%(tenant_id)s |
|      id     |       764978247fb34c24899ec81b5eaff63b      |
| internalurl | http://controller_pri:8776/v2/%(tenant_id)s |
|  publicurl  | http://controller_pub:8776/v2/%(tenant_id)s |
|    region   |                  regionOne                  |
|  service_id |       3aff42079cde4d4ab2b57e4719272b5e      |
+-------------+---------------------------------------------+

啟動 Service:

service openstack-cinder-api start
service openstack-cinder-scheduler start

chkconfig openstack-cinder-api on
chkconfig openstack-cinder-scheduler on

Troubleshoot

 

/var/log/cinder/api.log

2014-10-03 11:23:53.600 14983 ERROR oslo.messaging._drivers.impl_qpid [req-43aa3e38-04fe-404d-b07c-67ed322730a0 065f59bd572c45e59e68b801f32a5ada 0e61ba054af84f6f99e52766b6ff441f - - -] Unable to connect to AMQP server: [Errno -2] Name or service not known. Sleeping 5 seconds

修正問題後

/etc/init.d/openstack-cinder-api restart

 

 

 


Block Storage service node

 

介紹:

Set the host name to block1 and use 192.168.123.72 as IP address on the management network interface.

準備:

pvcreate /dev/vdb

vgcreate cinder-volumes /dev/vdb

安裝:

yum install openstack-cinder scsi-target-utils

# For testing

yum install mysql

設定

設定 keystone

openstack-config --set /etc/cinder/cinder.conf DEFAULT auth_strategy keystone
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_uri http://controller_pri:5000
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_host controller_pri
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_protocol http
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_port 35357
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken admin_user cinder
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken admin_tenant_name service
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken admin_password CINDER_PASS

設定 DB

openstack-config --set /etc/cinder/cinder.conf database connection mysql://cinder:CINDER_DBPASS@controller_pri/cinder

設定 Q

openstack-config --set /etc/cinder/cinder.conf DEFAULT rpc_backend cinder.openstack.common.rpc.impl_qpid
openstack-config --set /etc/cinder/cinder.conf DEFAULT qpid_hostname controller_pri

 

Configure Block Storage to use the Image Service.

# Block Storage needs access to images to create bootable volumes.

openstack-config --set /etc/cinder/cinder.conf DEFAULT glance_host controller_pri

 

# Configure the iSCSI target service to discover Block Storage volumes.

vi /etc/tgt/targets.conf

include /etc/cinder/volumes/*

 

啟動 Service:

service openstack-cinder-volume start
service tgtd start

chkconfig openstack-cinder-volume on
chkconfig tgtd on

 


Verify

 

Service Start 後, 會自動建立了 cinder-volumes-pool

lvdisplay -c

/dev/cinder-volumes/cinder-volumes-pool:cinder-volumes:3:1:-1:0:19922944:2432:-1:0:-1:253:2

# Login

source demo-openrc.sh

# create a new volume

cinder create --display-name myVolume 1

+---------------------+--------------------------------------+
|       Property      |                Value                 |
+---------------------+--------------------------------------+
|     attachments     |                  []                  |
|  availability_zone  |                 nova                 |
|       bootable      |                false                 |
|      created_at     |      2014-10-03T03:25:35.095784      |
| display_description |                 None                 |
|     display_name    |               myVolume               |
|      encrypted      |                False                 |
|          id         | 16b3e306-ab38-42ff-85b7-d41a8836a0c1 |
|       metadata      |                  {}                  |
|         size        |                  1                   |
|     snapshot_id     |                 None                 |
|     source_volid    |                 None                 |
|        status       |               creating               |
|     volume_type     |                 None                 |
+---------------------+--------------------------------------+

 

# If the status value is not available, the volume creation failed.

cinder list

+--------------------------------------+----------+--------------+------+-------------+----------+-------------+
|                  ID                  |  Status  | Display Name | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+----------+--------------+------+-------------+----------+-------------+
| 5b25d647-5d74-4d1f-a4b0-42338178d1a8 | creating |   myVolume   |  1   |     None    |  false   |             |
+--------------------------------------+----------+--------------+------+-------------+----------+-------------+

成功的話

+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
|                  ID                  |   Status  | Display Name | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
| e169060b-d843-40be-84a2-35edb89d3457 | available |  testVolume  |  1   |     None    |  false   |             |
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+

lvdisplay -c | grep volume

/dev/cinder-volumes/volume-e169060b-d843-40be-84a2-35edb89d3457:cinder-volumes:3:1:-1:0:2097152:256:-1:0:-1:253:6

# 查看 Volume 內容

cinder show e169060b-d843-40be-84a2-35edb89d3457

+--------------------------------+--------------------------------------+
|            Property            |                Value                 |
+--------------------------------+--------------------------------------+
|          attachments           |                  []                  |
|       availability_zone        |                 nova                 |
|            bootable            |                false                 |
|           created_at           |      2014-10-03T03:47:45.000000      |
|      display_description       |                 None                 |
|          display_name          |              testVolume              |
|           encrypted            |                False                 |
|               id               | e169060b-d843-40be-84a2-35edb89d3457 |
|            metadata            |                  {}                  |
|     os-vol-host-attr:host      |            compute.local             |
| os-vol-mig-status-attr:migstat |                 None                 |
| os-vol-mig-status-attr:name_id |                 None                 |
|  os-vol-tenant-attr:tenant_id  |   0e61ba054af84f6f99e52766b6ff441f   |
|              size              |                  1                   |
|          snapshot_id           |                 None                 |
|          source_volid          |                 None                 |
|             status             |              available               |
|          volume_type           |                 None                 |
+--------------------------------+--------------------------------------+

 


Command

 

<subcommand>

 

# Login 身份

    credentials         Show user credentials returned from auth.

    availability-zone-list          List all the availability zones.

+------+-----------+
| Name |   Status  |
+------+-----------+
| nova | available |
+------+-----------+

# 建立

    create               Add a new volume. (  --display-name <display-name> <size GB> )

# 查看

    list                     List all the volumes.
    show                 Show details about a volume.

# 刪除

    delete                  Remove volume(s).

    force-delete        Attempt forced removal of volume(s), regardless of the state(s).

# User

    absolute-limits                 Print a list of absolute limits for a user

+-------------------------+-------+
|           Name          | Value |
+-------------------------+-------+
|    maxTotalSnapshots    |   10  |
| maxTotalVolumeGigabytes |  1000 |
|     maxTotalVolumes     |   10  |
|    totalGigabytesUsed   |   1   |
|    totalSnapshotsUsed   |   0   |
|     totalVolumesUsed    |   1   |
+-------------------------+-------+

# backup

    backup-create       Creates a backup.
    backup-delete       Remove a backup.
    backup-list            List all the backups.
    backup-restore      Restore a backup.
    backup-show         Show details about a backup.

 

# Volumre

    extend              Attempt to extend the size of an existing volume.

    migrate             Migrate the volume to the new host.

    rename              Rename a volume.

# metadata

    metadata                     Set or Delete metadata on a volume.
    metadata-show           Show metadata of given volume.
    metadata-update-all    Update all metadata of a volume.

 

# QOS

    qos-associate             Associate qos specs with specific volume type.
    qos-create                  Create a new qos specs.
    qos-delete                  Delete a specific qos specs.
    qos-disassociate         Disassociate qos specs from specific volume type.
    qos-disassociate-all     Disassociate qos specs from all of its associations.
    qos-get-association    Get all associations of specific qos specs.
    qos-key                      Set or unset specifications for a qos spec.
    qos-list                       Get full list of qos specs.
    qos-show                   Get a specific qos specs.

# quota

    quota-class-show    List the quotas for a quota class.
    quota-class-update  Update the quotas for a quota class.
    quota-defaults      List the default quotas for a tenant.
    quota-delete        Delete the quotas for a tenant.
    quota-show          List the quotas for a tenant.
    quota-update        Update the quotas for a tenant.
    quota-usage         List the quota usage for a tenant.

# service

    service-disable     Disable the service.
    service-enable      Enable the service.
    service-list            List all the services. Filter by host & service  binary.

+------------------+------------------+------+---------+-------+----------------------------+-----------------+
|      Binary      |       Host       | Zone |  Status | State |         Updated_at         | Disabled Reason |
+------------------+------------------+------+---------+-------+----------------------------+-----------------+
| cinder-scheduler | controller.local | nova | enabled |   up  | 2014-10-03T05:28:23.000000 |       None      |
|  cinder-volume   |  compute.local   | nova | enabled |   up  | 2014-10-03T05:28:29.000000 |       None      |
+------------------+------------------+------+---------+-------+----------------------------+-----------------+

# snapshot

    snapshot-create               Add a new snapshot.
    snapshot-delete               Remove one or more snapshots.
    snapshot-list                 List all the snapshots.
    snapshot-metadata             Set or Delete metadata of a snapshot.
    snapshot-metadata-show        Show metadata of given snapshot.
    snapshot-metadata-update-all  Update all metadata of a snapshot.
    snapshot-rename               Rename a snapshot.
    snapshot-reset-state          Explicitly update the state of a snapshot.
    snapshot-show       Show details about a snapshot.

# transfer

    transfer-accept     Accepts a volume transfer.
    transfer-create     Creates a volume transfer.
    transfer-delete     Undo a transfer.
    transfer-list       List all the transfers.
    transfer-show       Show details about a transfer.

# type

    type-create         Create a new volume type.
    type-delete         Delete a specific volume type.
    type-key            Set or unset extra_spec for a volume type.
    type-list           Print a list of available 'volume types'.

 

# Other

    endpoints           Discover endpoints that get returned from the authenticate services.
    extra-specs-list    Print a list of current 'volume types and extra specs'  (Admin Only).

    reset-state         Explicitly update the state of a volume.

    rate-limits              Print a list of rate limits for a user
    readonly-mode-update     Update volume read-only access mode read_only.

    upload-to-image     Upload volume to image service as image.
    bash-completion     Print arguments for bash_completion.
    
    help                Display help about this program or one of its subcommands.
    list-extensions     List all the os-api extensions that are available.

 


Configure

 

設定檔:

  • /etc/cinder/cinder.conf

 

LVM 設定:

# Options defined in cinder.volume.drivers.lvm

# Name for the VG
volume_group=cinder-volumes

# requires lvm_mirrors + 2 pvs with available space
lvm_mirrors=0

# default or thin
lvm_type=default

 

 

Creative Commons license icon Creative Commons license icon