天天看點

Restore Volume 操作 - 每天5分鐘玩轉 OpenStack(60) 向 cinder-api 發送 restore 請求 cinder-backup 執行 restore 操作

Restore Volume 操作 - 每天5分鐘玩轉 OpenStack(60) 向 cinder-api 發送 restore 請求 cinder-backup 執行 restore 操作

前面我們 backup 了 voluem,今天我們将讨論如何 restore volume。

restore 的過程其實很簡單,兩步走:

在存儲節點上建立一個空白 volume。

将 backup 的資料 copy 到空白 voluem 上。

下面我們來看 restore 操作的詳細流程:

Restore Volume 操作 - 每天5分鐘玩轉 OpenStack(60) 向 cinder-api 發送 restore 請求 cinder-backup 執行 restore 操作

向 cinder-api 發送 restore 請求

cinder-api 發送消息

cinder-scheduler 挑選最合适的 cinder-volume

cinder-volume 建立空白 volume

cinder-backup 将 backup 資料 copy 到空白 volume 上

我們先來看第 1 步。

客戶(可以是 OpenStack 最終使用者,也可以是其他程式)向 cinder-api 發送請求:“請 restore 指定的 backup。這裡我們将 restore 之前建立的 backup。

目前 restore 隻能在 CLI 中執行。

Restore Volume 操作 - 每天5分鐘玩轉 OpenStack(60) 向 cinder-api 發送 restore 請求 cinder-backup 執行 restore 操作
Restore Volume 操作 - 每天5分鐘玩轉 OpenStack(60) 向 cinder-api 發送 restore 請求 cinder-backup 執行 restore 操作

cinder-api 接收到 restore 請求。日志檔案在 /opt/stack/logs/c-api.log。

Restore Volume 操作 - 每天5分鐘玩轉 OpenStack(60) 向 cinder-api 發送 restore 請求 cinder-backup 執行 restore 操作

這裡看到 cinder-api 轉發請求,為 restore 建立 volume。 之後 cinder-scheduler 和 cinder-volume 将建立空白 volume,這個過程與 create volume 一樣,不再贅述。

接下來分析資料恢複的過程。 首先,在 cinder-api 日志中可以看到相關資訊。

Restore Volume 操作 - 每天5分鐘玩轉 OpenStack(60) 向 cinder-api 發送 restore 請求 cinder-backup 執行 restore 操作

這裡注意日志中的 volume_id 和 backup_id 與前面 backup-restore 指令的輸出是一緻的。

下面來看 cinder-backup 是如何恢複資料的。

日志為 /opt/stack/logs/c-vol.log。

啟動 restore 操作,mount NFS。

Restore Volume 操作 - 每天5分鐘玩轉 OpenStack(60) 向 cinder-api 發送 restore 請求 cinder-backup 執行 restore 操作

讀取 container 目錄中的 metadata。

Restore Volume 操作 - 每天5分鐘玩轉 OpenStack(60) 向 cinder-api 發送 restore 請求 cinder-backup 執行 restore 操作

将資料解壓并寫到 volume 中。

Restore Volume 操作 - 每天5分鐘玩轉 OpenStack(60) 向 cinder-api 發送 restore 請求 cinder-backup 執行 restore 操作

恢複 volume 的 metadata,完成 restore 操作。

Restore Volume 操作 - 每天5分鐘玩轉 OpenStack(60) 向 cinder-api 發送 restore 請求 cinder-backup 執行 restore 操作

此時,在 GUI 中已經可以看到 restore 建立的 volume。

Restore Volume 操作 - 每天5分鐘玩轉 OpenStack(60) 向 cinder-api 發送 restore 請求 cinder-backup 執行 restore 操作

以上就是 volume restore 的分析,下一節我們讨論如何将 volume 作為 instance 的啟動盤。

Restore Volume 操作 - 每天5分鐘玩轉 OpenStack(60) 向 cinder-api 發送 restore 請求 cinder-backup 執行 restore 操作