返回总目录 描述详细 创建 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 的。 查看日志cinder-volume日志: cinder-volume 也会启动 Flow 来完成 volume 创建工作,Flow 的名称为 volume_create_manager。 1 2 3 4 5 6 Jun 24 15:15:29 controller cinder-volume[10526]: DEBUG cinder.volume.manager [None req-ebb16520-df22-445e-82f7-4c8b8bf942f2 admin None] (ce8afde5-ad68-4b11-b356-e9d0272021ca) transitioned into state from state {{(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。 1 2 3 4 5 6 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.;volume:create' (13ad3eb3-3d4e-4f9d-87d3-8c60cd4ee1c7) transitioned into state from state {{(pid=10540) _task_receiver /usr/local/lib/python2.7/dist-packages/taskflow/listeners/logging.py:194 1 2 3 4 5 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] {'status': u'creating', 'volume_size': 1, 'volume_name': u'volume-588b6bbe-8965-4dcb-ae87-1970b906a847'} 首先 mount 远程 NFS 目录挂载到本地。 1 2 3 4 5 Jun 24 15:15:29 controller cinder-volume[10526]: DEBUG cinder.volume.drivers. [None req-ebb16520-df22-445e-82f7-4c8b8bf942f2 admin None] {{(pid=10540) _load_shares_config /opt/stack/cinder/cinder/volume/drivers/remotefs.py:499 1 2 3 4 Jun 24 15:15:29 controller cinder-volume[10526]: DEBUG cinder.volume.drivers. [None req-ebb16520-df22-445e-82f7-4c8b8bf942f2 admin None] 1 2 3 4 5 6 {{(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): {{(pid=10540) execute /usr/local/lib/python2.7/dist-packages/oslo_concurrency/processutils.py:372 1 2 3 4 Jun 24 15:15:29 controller cinder-volume[10526]: INFO os_brick.remotefs.remotefs [None req-ebb16520-df22-445e-82f7-4c8b8bf942f2 admin None] 执行stat、du 命令检查 NFS 目录。 1 2 3 4 5 6 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 -f -c %S %b %a {{(pid=10540) execute /usr/local/lib/python2.7/dist-packages/oslo_concurrency/processutils.py:372 1 2 3 4 5 6 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 -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 文件 1 2 3 4 5 Jun 24 15:15:30 controller cinder-volume[10526]: DEBUG cinder.volume.drivers.nfs [None req-ebb16520-df22-445e-82f7-4c8b8bf942f2 admin None] . {{(pid=10540) _find_share /opt/stack/cinder/cinder/volume/drivers/nfs.py:263 1 2 3 4 Jun 24 15:15:30 controller cinder-volume[10526]: INFO cinder.volume.drivers.remotefs [None req-ebb16520-df22-445e-82f7-4c8b8bf942f2 admin None] 1 2 3 4 5 6 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 -s 1G {{(pid=10540) execute /usr/local/lib/python2.7/dist-packages/oslo_concurrency/processutils.py:372 设置 volume 文件为可读写。 1 2 3 4 5 6 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 {{(pid=10540) execute /usr/local/lib/python2.7/dist-packages/oslo_concurrency/processutils.py:372 create 操作完成 1 2 3 4 5 6 7 8 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.;volume:create' (13ad3eb3-3d4e-4f9d-87d3-8c60cd4ee1c7) transitioned into state 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 1 2 3 4 5 6 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.;volume:create, create.end' (c63640e9-ecca-4789-a09a-65a853b1ad8f) transitioned into state from state 'PENDING' {{(pid=10540) _task_receiver /usr/local/lib/python2.7/dist-packages/taskflow/listeners/logging.py:194 1 2 3 4 5 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] 1 2 3 4 5 6 7 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.;volume:create, create.end' (c63640e9-ecca-4789-a09a-65a853b1ad8f) transitioned into state from state 'RUNNING' with result 'None' {{(pid=10540) _task_receiver /usr/local/lib/python2.7/dist-packages/taskflow/listeners/logging.py:183 1 2 3 4 5 6 Jun 24 15:15:31 controller cinder-volume[10526]: DEBUG cinder.volume.manager [None req-ebb16520-df22-445e-82f7-4c8b8bf942f2 admin None] (ce8afde5-ad68-4b11-b356-e9d0272021ca) transitioned into state from state 'RUNNING' {{(pid=10540) _flow_receiver /usr/local/lib/python2.7/dist-packages/taskflow/listeners/logging.py:145 Volume 在 NFS 上以文件存在,命名为“volume-<volume ID>”。