08.存儲Cinder→5.場景學習→07.Snapshot Volume

  1. Snapshot 能夠爲 volume 建立快照,快照中保存了 volume 當前的狀態,之後能夠經過 snapshot 回溯。
  2. 若當前 volume 已經 attach 到某個 instance,建立 snapshot 可能致使數據不一致,建議先 detach volume 在作 sanpshot。
描述 詳細
  1. 向 cinder-api 發送 snapshot 請求
    1. 客戶(能夠是 OpenStack 最終用戶,也能夠是其餘程序)向 cinder-api 發送請求:「請 snapshot 指定的 volume。
    2. 這裏咱們將 delete volume 「vol-1」。進入 GUI 操做菜單 Project -> Volumes -> Volumes。
    3. 選擇「vol-1」,點擊 「Create Snapshot」。爲 snapshot 命名。


  1. cinder-api 將接收到 snapshot volume 的請求
    1. 查看日誌c-api
1
2
3
4
Jun 20 20:10:08 controller devstack@c-api.service[31309]: 
INFO cinder.api.openstack.wsgi 
[None req-e75e535b-9565-49e8-a63b-d16166b31918 admin admin] 
POST http://172.16.1.17/volume/v3/51743f081cb7477f9a1f4ccdf6490d8e/snapshots
1
2
3
4
5
6
7
Jun 20 20:10:08 controller devstack@c-api.service[31309]: 
DEBUG cinder.api.openstack.wsgi 
[None req-e75e535b-9565-49e8-a63b-d16166b31918 admin admin] 
Action: 'create', calling method: <bound method SnapshotsController.create of <cinder.api.v3....
body: {"snapshot": {"description": "", "metadata": {}, "force": false, "name": "vol-1-snapshot", 
"volume_id": "6d448344-8260-4e82-a63b-9be6b2a00fef" 
{(pid=31313) _process_stack /opt/stack/cinder/cinder/api/openstack/wsgi.py:868}}
1
2
3
4
Jun 20 20:10:08 controller devstack@c-api.service[31309]: 
INFO cinder.api.v2.snapshots
 [None req-e75e535b-9565-49e8-a63b-d16166b31918 admin admin] 
Create snapshot from volume 6d448344-8260-4e82-a63b-9be6b2a00fef
  1. cinder-api 發送消息
    1. cinder-api 發送消息 snapshot 消息。cinder-api 沒有打印發送消息的日誌,只能經過源代碼查看 /opt/stack/cinder/cinder/volume/api.py,方法爲 _create_snapshot。

爲何還有cinder-scheuler的參與?參考見08.存儲Cinder→5.場景學習→5.Extend Volume
  1. cinder-volume 執行 snapshot 操做
    1. cinder-volume 執行 lvcreate 建立 snapshot。
      1. 查看c-vol日誌
1
2
3
4
5
6
7
Jun 20 20:10:10 controller cinder-volume[304]: 
DEBUG oslo_concurrency.processutils 
[None req-e75e535b-9565-49e8-a63b-d16166b31918 admin None] 
CMD "sudo cinder-rootwrap /etc/cinder/rootwrap.conf env LC_ALL=C 
lvcreate --name _snapshot-a6fdef0d-5cb9-45f9-affb-b2ed38b2a6ee --snapshot stack-volumes-lvmdriver-1/volume-6d448344-8260-4e82-a63b-9be6b2a00fef" returned: 0 in 1.020s 
{{(pid=460) execute /usr/local/lib/python2.7/dist-packages/oslo_concurrency/processutils.py:409
1
2
3
Jun 20 20:10:11 controller cinder-volume[304]: INFO cinder.volume.manager
 [None req-e75e535b-9565-49e8-a63b-d16166b31918 admin None] 
Create snapshot completed successfully
  1. 對於 LVM volume provider,snapshot 實際上也是一個 LV,同時記錄了與源 LV 的 snapshot 關係,能夠經過 lvdisplay 查看。

  1. GUI 的 Volume Snapshots 標籤中能夠看到新建立的 「vol-1-snapshot」。
  1. 有了 snapshot,咱們就能夠將 volume 回溯到建立 snapshot 時的狀態。方法是經過 snapshot 建立新的 volume。
    1. 新建立的 volume 容量必須大於或等於 snapshot 的容量。
    2. 其過程與 Create Volume 相似,不一樣之處在於 LV 建立以後會經過 dd 將 snapshot 的數據 copy 到新的 volume。



  1. 若是一個 volume 存在 snapshot,則這個 volume 是沒法刪除的。這是由於 snapshot 依賴於 volume,snapshot 沒法獨立存在。
    1. 在 LVM 做爲 volume provider 的環境中,snapshot 是從源 volume 徹底 copy 而來,因此這種依賴關係不強。
    2. 但在其餘 volume provider(好比商業存儲設備或者分佈式文件系統如EMC易安信公司、IBM等商業存儲產品和方案),snapshot 一般是源 volume 建立快照時數據狀態的一個引用(指針),佔用空間很是小,在這種實現方式裏 snapshot 對源 volume 的依賴就很是明顯了。
相關文章
相關標籤/搜索