- 创建 NFS volume 操作方法与 LVM volume 一样,唯一区别是在 volume type 的下拉列表中选择“nfs”。
- 点击“Create Volume”,cinder-api,cinder-scheduler 和 cinder-volume 共同协作创建 volume “vol-3”。这个流程与 LVM volume 一样。由于只有一个存储节点,因此筛选出的还是控制节点。
- 下面我们重点分析 cinder-volume 日志,看看 NFS volume provider 是如何创建 volume 的。
| ![技术分享图片](http://zhaolei.xuexihaike.com/paste-147502061846531.jpg)
![技术分享图片](http://zhaolei.xuexihaike.com/paste-148249386156035.jpg) |
- 查看日志cinder-volume日志:
- cinder-volume 也会启动 Flow 来完成 volume 创建工作,Flow 的名称为 volume_create_manager。
| | Jun 24 15:15:29 controller cinder-volume[10526]:
DEBUG cinder.volume.manager
[None req-ebb16520-df22-445e-82f7-4c8b8bf942f2 admin None]
Flow ‘volume_create_manager‘ (ce8afde5-ad68-4b11-b356-e9d0272021ca)
transitioned into state ‘RUNNING‘ from state ‘PENDING‘
{{(pid=10540) _flow_receiver /usr/local/lib/python2.7/dist-packages/taskflow/listeners/logging.py:145 |
|
- volume_create_manager 首先执行 ExtractVolumeRefTask, OnFailureRescheduleTask, ExtractVolumeSpecTask, NotifyVolumeActionTask 为 volume创建做准备。然后由 CreateVolumeFromSpecTask 真正创建 volume。
| | Jun 24 15:15:29 controller cinder-volume[10526]:
DEBUG cinder.volume.manager
[None req-ebb16520-df22-445e-82f7-4c8b8bf942f2 admin None]
Task ‘cinder.volume.flows.manager.create_volume.CreateVolumeFromSpecTask;volume:create‘
(13ad3eb3-3d4e-4f9d-87d3-8c60cd4ee1c7) transitioned into state ‘RUNNING‘ from state ‘PENDING‘
{{(pid=10540) _task_receiver /usr/local/lib/python2.7/dist-packages/taskflow/listeners/logging.py:194 |
| Jun 24 15:15:29 controller cinder-volume[10526]:
INFO cinder.volume.flows.manager.create_volume
[None req-ebb16520-df22-445e-82f7-4c8b8bf942f2 admin None]
Volume 588b6bbe-8965-4dcb-ae87-1970b906a847: being created as raw with specification:
{‘status‘: u‘creating‘, ‘volume_size‘: 1, ‘volume_name‘: u‘volume-588b6bbe-8965-4dcb-ae87-1970b906a847‘} |
|
- 首先 mount 远程 NFS 目录挂载到本地。
| | Jun 24 15:15:29 controller cinder-volume[10526]:
DEBUG cinder.volume.drivers.remotefs
[None req-ebb16520-df22-445e-82f7-4c8b8bf942f2 admin None]
Loading shares from /etc/cinder/nfs_shares.
{{(pid=10540) _load_shares_config /opt/stack/cinder/cinder/volume/drivers/remotefs.py:499
|
| Jun 24 15:15:29 controller cinder-volume[10526]:
DEBUG cinder.volume.drivers.remotefs
[None req-ebb16520-df22-445e-82f7-4c8b8bf942f2 admin None]
shares loaded: {‘172.16.1.55:/storage‘: None}
|
| {{(pid=10540) _load_shares_config /opt/stack/cinder/cinder/volume/drivers/remotefs.py:531
Jun 24 15:15:29 controller cinder-volume[10526]:
DEBUG oslo_concurrency.processutils
[None req-ebb16520-df22-445e-82f7-4c8b8bf942f2 admin None]
Running cmd (subprocess): mount
{{(pid=10540) execute /usr/local/lib/python2.7/dist-packages/oslo_concurrency/processutils.py:372
|
| Jun 24 15:15:29 controller cinder-volume[10526]:
INFO os_brick.remotefs.remotefs
[None req-ebb16520-df22-445e-82f7-4c8b8bf942f2 admin None]
Already mounted: /opt/stack/data/cinder/mnt/784d250b26b539400de552b6137dccd0 |
|
- 执行stat、du 命令检查 NFS 目录。
| | Jun 24 15:15:29 controller cinder-volume[10526]:
DEBUG oslo_concurrency.processutils
[None req-ebb16520-df22-445e-82f7-4c8b8bf942f2 admin None]
Running cmd (subprocess): sudo cinder-rootwrap /etc/cinder/rootwrap.conf stat -f -c
%S %b %a /opt/stack/data/cinder/mnt/784d250b26b539400de552b6137dccd0
{{(pid=10540) execute /usr/local/lib/python2.7/dist-packages/oslo_concurrency/processutils.py:372 |
| Jun 24 15:15:29 controller cinder-volume[10526]:
DEBUG oslo_concurrency.processutils
[None req-ebb16520-df22-445e-82f7-4c8b8bf942f2 admin None]
Running cmd (subprocess): sudo cinder-rootwrap /etc/cinder/rootwrap.conf du -sb
--apparent-size --exclude *snapshot* /opt/stack/data/cinder/mnt/784d250b26b539400de552b6137dccd0
{{(pid=10540) execute /usr/local/lib/python2.7/dist-packages/oslo_concurrency/processutils.py:372 |
|
- 执行truncate [?tr??ke?t]vt. 缩短; 创建 volume 文件
| | Jun 24 15:15:30 controller cinder-volume[10526]:
DEBUG cinder.volume.drivers.nfs
[None req-ebb16520-df22-445e-82f7-4c8b8bf942f2 admin None]
Selected 172.16.1.55:/storage as target NFS share.
{{(pid=10540) _find_share /opt/stack/cinder/cinder/volume/drivers/nfs.py:263
|
| Jun 24 15:15:30 controller cinder-volume[10526]:
INFO cinder.volume.drivers.remotefs
[None req-ebb16520-df22-445e-82f7-4c8b8bf942f2 admin None]
casted to 172.16.1.55:/storage
|
| Jun 24 15:15:30 controller cinder-volume[10526]:
DEBUG oslo_concurrency.processutils
[None req-ebb16520-df22-445e-82f7-4c8b8bf942f2 admin None]
Running cmd (subprocess): sudo cinder-rootwrap /etc/cinder/rootwrap.conf truncate -s 1G
/opt/stack/data/cinder/mnt/784d250b26b539400de552b6137dccd0/volume-588b6bbe-8965-4dcb-ae87-1970b906a847
{{(pid=10540) execute /usr/local/lib/python2.7/dist-packages/oslo_concurrency/processutils.py:372
|
|
- 设置 volume 文件为可读写。
| | Jun 24 15:15:30 controller cinder-volume[10526]:
DEBUG oslo_concurrency.processutils
[None req-ebb16520-df22-445e-82f7-4c8b8bf942f2 admin None]
Running cmd (subprocess): sudo cinder-rootwrap /etc/cinder/rootwrap.conf chmod ugo+rw
/opt/stack/data/cinder/mnt/784d250b26b539400de552b6137dccd0/volume-588b6bbe-8965-4dcb-ae87-1970b906a847
{{(pid=10540) execute /usr/local/lib/python2.7/dist-packages/oslo_concurrency/processutils.py:372 |
|
- create 操作完成
| | Jun 24 15:15:31 controller cinder-volume[10526]:
DEBUG cinder.volume.manager
[None req-ebb16520-df22-445e-82f7-4c8b8bf942f2 admin None]
Task ‘cinder.volume.flows.manager.create_volume.CreateVolumeFromSpecTask;volume:create‘
(13ad3eb3-3d4e-4f9d-87d3-8c60cd4ee1c7) transitioned into state ‘SUCCESS‘ from state ‘RUNNING‘
with result ‘{‘status‘: u‘creating‘, ‘volume_size‘: 1, ‘volume_name‘:
u‘volume-588b6bbe-8965-4dcb-ae87-1970b906a847‘}‘
{{(pid=10540) _task_receiver /usr/local/lib/python2.7/dist-packages/taskflow/listeners/logging.py:183
|
| Jun 24 15:15:31 controller cinder-volume[10526]:
DEBUG cinder.volume.manager
[None req-ebb16520-df22-445e-82f7-4c8b8bf942f2 admin None]
Task ‘cinder.volume.flows.manager.create_volume.CreateVolumeOnFinishTask;volume:create, create.end‘
(c63640e9-ecca-4789-a09a-65a853b1ad8f) transitioned into state ‘RUNNING‘ from state ‘PENDING‘
{{(pid=10540) _task_receiver /usr/local/lib/python2.7/dist-packages/taskflow/listeners/logging.py:194
|
| Jun 24 15:15:31 controller cinder-volume[10526]:
INFO cinder.volume.flows.manager.create_volume
[None req-ebb16520-df22-445e-82f7-4c8b8bf942f2 admin None]
Volume volume-588b6bbe-8965-4dcb-ae87-1970b906a847 (588b6bbe-8965-4dcb-ae87-1970b906a847):
created successfully
|
| Jun 24 15:15:31 controller cinder-volume[10526]:
DEBUG cinder.volume.manager
[None req-ebb16520-df22-445e-82f7-4c8b8bf942f2 admin None]
Task ‘cinder.volume.flows.manager.create_volume.CreateVolumeOnFinishTask;volume:create,
create.end‘ (c63640e9-ecca-4789-a09a-65a853b1ad8f) transitioned into state ‘SUCCESS‘
from state ‘RUNNING‘ with result ‘None‘
{{(pid=10540) _task_receiver /usr/local/lib/python2.7/dist-packages/taskflow/listeners/logging.py:183
|
| Jun 24 15:15:31 controller cinder-volume[10526]:
DEBUG cinder.volume.manager
[None req-ebb16520-df22-445e-82f7-4c8b8bf942f2 admin None]
Flow ‘volume_create_manager‘ (ce8afde5-ad68-4b11-b356-e9d0272021ca) transitioned into state ‘SUCCESS‘
from state ‘RUNNING‘
{{(pid=10540) _flow_receiver /usr/local/lib/python2.7/dist-packages/taskflow/listeners/logging.py:145 |
|
- Volume 在 NFS 上以文件存在,命名为“volume-<volume ID>”。
![技术分享图片](http://zhaolei.xuexihaike.com/paste-159296042041347.jpg)
| ![技术分享图片](http://zhaolei.xuexihaike.com/paste-159046933938179.jpg)
![技术分享图片](http://zhaolei.xuexihaike.com/paste-159150013153283.jpg) |