配置cinder使用NFS后端


首先先使用“cinder delete”命令删除所有实例,释放磁盘空间。


停止cinder服务:
service openstack-cinder-api stop
service openstack-cinder-scheduler stop
service openstack-cinder-volume stop


备份配置文件:
cp -a /etc/cinder/cinder.conf /etc/cinder/cinder.conf.bak
cat /etc/cinder/cinder.conf.bak|grep -v '#'|grep -v '^$'>/etc/cinder/cinder.conf


修改配置文件:
[DEFAULT]
iscsi_ip_address=168.5.22.4
volume_backend_name=DEFAULT
iscsi_helper=tgtadm
volume_group=cinder
改为:
nfs_shares_config=/etc/cinder/nfs_shares
nfs_sparsed_volumes=true
nfs_mount_options=v3
volume_driver=cinder.volume.drivers.nfs.NfsDriver


创建挂载点配置文件:
echo '168.5.22.100:/volumes'>/etc/cinder/nfs_shares
chown root:cinder /etc/cinder/nfs_shares
chmod 0640 /etc/cinder/nfs_shares


查看cinder用户密码:
cat /etc/cinder/cinder.conf|grep connection
connection=mysql://cinder:eVUZuEyb@168.5.23.2/cinder?charset=utf8&read_timeout=60
密码是:eVUZuEyb


在任一节点重建数据库:
mysql -h 168.5.23.2 -u cinder -p -e 'drop database cinder;'
mysql -h 168.5.23.2 -u cinder -p -e 'create database cinder;'
su -s /bin/sh -c "cinder-manage db sync" cinder


启动cinder服务:
service openstack-cinder-volume start
service openstack-cinder-scheduler start
service openstack-cinder-api start


测试:
# source openrc
# nova list
+--------------------------------------+-----------------+--------+------------+-------------+---------------------+
| ID                                   | Name            | Status | Task State | Power State | Networks            |
+--------------------------------------+-----------------+--------+------------+-------------+---------------------+
| 312ba535-4279-4338-862e-4892a8393c65 | admin-instance1 | ACTIVE | -          | Running     | VLAN549=168.5.49.33 |
+--------------------------------------+-----------------+--------+------------+-------------+---------------------+
# cinder create --display-name admin-instance1-vol01 50
+---------------------+--------------------------------------+
|       Property      |                Value                 |
+---------------------+--------------------------------------+
|     attachments     |                  []                  |
|  availability_zone  |                 nova                 |
|       bootable      |                false                 |
|      created_at     |      2016-01-13T01:29:36.916617      |
| display_description |                 None                 |
|     display_name    |        admin-instance1-vol01         |
|      encrypted      |                False                 |
|          id         | 3f84fef7-50bc-4794-9d24-07e13967cd6b |
|       metadata      |                  {}                  |
|         size        |                  50                  |
|     snapshot_id     |                 None                 |
|     source_volid    |                 None                 |
|        status       |               creating               |
|     volume_type     |                 None                 |
+---------------------+--------------------------------------+
# cinder show 3f84fef7-50bc-4794-9d24-07e13967cd6b
+---------------------------------------+--------------------------------------+
|                Property               |                Value                 |
+---------------------------------------+--------------------------------------+
|              attachments              |                  []                  |
|           availability_zone           |                 nova                 |
|                bootable               |                false                 |
|               created_at              |      2016-01-13T01:29:37.000000      |
|          display_description          |                 None                 |
|              display_name             |        admin-instance1-vol01         |
|               encrypted               |                False                 |
|                   id                  | 3f84fef7-50bc-4794-9d24-07e13967cd6b |
|                metadata               |                  {}                  |
|         os-vol-host-attr:host         |    node-1.evecom.net#Generic_NFS     |
|     os-vol-mig-status-attr:migstat    |                 None                 |
|     os-vol-mig-status-attr:name_id    |                 None                 |
|      os-vol-tenant-attr:tenant_id     |   df54866bc83f4f5f96fae17b3810a343   |
|   os-volume-replication:driver_data   |                 None                 |
| os-volume-replication:extended_status |                 None                 |
|                  size                 |                  50                  |
|              snapshot_id              |                 None                 |
|              source_volid             |                 None                 |
|                 status                |              available               |
|              volume_type              |                 None                 |
+---------------------------------------+--------------------------------------+
# nova volume-attach admin-instance1 3f84fef7-50bc-4794-9d24-07e13967cd6b
+----------+--------------------------------------+
| Property | Value                                |
+----------+--------------------------------------+
| device   | /dev/vdb                             |
| id       | 3f84fef7-50bc-4794-9d24-07e13967cd6b |
| serverId | 312ba535-4279-4338-862e-4892a8393c65 |
| volumeId | 3f84fef7-50bc-4794-9d24-07e13967cd6b |
+----------+--------------------------------------+

原文地址:https://www.cnblogs.com/endoresu/p/5126489.html