張宸瑜
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # OpenStack [TOC] 雲端: 讓主機連上網,供遠端使用者使用。 如何整合各地不同的主機、硬體設備? 如何管理不同節點的所有虛擬伺服器、虛擬儲存空間等虛擬資源? ## 關於 OpenStack ![](https://i.imgur.com/kxHdn0I.png) [圖片來源](https://www.openstack.org/software/) - 提供雲端服務的 IaaS (基礎架構)管理的平台。 - 伺服器、網路、儲存設備等。 - 整合虛擬機、網路、儲存設備等等資源。 - 可透過 web 或命令列控制整個系統。 - 自由、開源的運算平台。 - 由不同相互關聯的組件組成。 - 每個套件都提供各自的 API 以便存取資源。 - 運用範圍: - 管理虛擬機器以及網路、儲存、身份認證等服務。 ## 架構 ![](https://i.imgur.com/bPj48iF.png) [圖片來源](https://www.openstack.org/software/) - OpenStack 以好幾個不同服務所組成,每個服務有不同的套件可以運用。 - 其中 9 個 OpenStack 的核心套件: | 服務 | 套件(英) | 套件(中) | 負責事項 | | -------- | ------------ | -------- | --------| | Identity(認證)| KeyStone |身份認證套件| 提供對 User(使用者或服務)驗證與授權 | | Compute(計算) | Nova |運算套件 | 提供部署與管理虛擬機器的功能 | | Bare Metal(裸機) | Ironic | 裸機管理套件 | 提供裸機的部署和安裝。 | Image(映像) | Glance |映像檔管理套件 | 提供硬碟或伺服器的映象檔尋找、註冊以及服務交付等功能 | Network(網路) | Neutron |網路套件 | 提供網路服務| | Block Storage(區塊儲存) | Cinder |區塊儲存套件| 提供 Block Storage 服務 | Object Storage(物件儲存)| Swift |物件儲存套件| 用於存放非結構性資料| | Dashdoard(儀表板)| Horizon |儀表板套件 | 提供 IT 人員一個圖形化的網頁介面,管理所有運用的資源 | | Orchestrate(編排) | Heat | 編排套件 | 提供模板自動化配置資源 | ![](https://i.imgur.com/vm64D2j.png) - 不同套件之間以 RESTful API 進行存取。 ::: info **RESTful API** ![](https://i.imgur.com/YmnhTx3.png =400x) - REST: Representational State Transfer,一種設計規範(非協定或標準)。 - RESTful: 形容以此規範設計的 API。 - 充份利用 HTTP protocol(GET/POST/PUT/DELETE)。 - 一般無規範 API: ``` 獲取使用者列表 /getAllUsers 獲取使用者資料 /getUser/1 新增使用者資料 /createUser 更新使用者資料 /updateUser/1 刪除使用者資料 /deleteUser/1 ``` > 詳讀 API 文件,理解所有設計命名規則後,才可使用。 - RESTful API: ``` 獲取使用者列表 GET /user 獲取使用者資料 GET /user/1 新增使用者資料 POST /user 更新使用者資料 PUT /user/1 刪除使用者資料 DELETE /user/1 ``` > 用一個唯一的 URL 定位資源,將動作藏在 HTTP 的 method 裡面。 - 特點 - 無狀態 (Stateless): - 登入為例: - 有狀態: 登入時 Server 端儲存 Session(使用者登入資訊),再次請求時,依照 Session 去 request。 - 儲存資料,增加 server 的壓力。 - 多次請求必須訪問同一臺伺服器。 - 無狀態: Client 端自行保存狀態,請求時一並附上給 Server。 EX: 登入時 Server 返還 token,請求時使用 token 給 Server。 - 意即所有的資源都可以 URI 定位,而且這個定位與其他資源無關,也不會因為其他資源的變化而變化,資源相互的依賴性降低。 [資料來源](https://medium.com/itsems-frontend/api-%E6%98%AF%E4%BB%80%E9%BA%BC-restful-api-%E5%8F%88%E6%98%AF%E4%BB%80%E9%BA%BC-a001a85ab638) ::: - 一些 OpenStack 名詞說明: | 名詞 | 說明 | 舉例 | 操作 | -------- | -------- | -------- | --------------| | User | OpenStack 的實體 | 用戶、服務、其他系統 | 當 User 要訪問 OpenStack 時,KeyStone 就會對其進行驗證。 | | Credentials | User 用來證明自己身份的訊息 | 帳號、密碼、Token、API Key | | Authentication | KeyStone 驗證 User 身份的過程| | 當 User 透過帳密取得 Keystone 授權後就會獲得一個 Token 作為訪問服務的 Credential | | Token | 取得服務的鑰匙 | | User 利用 Token 認證後可以取得服務的 Endpoint | | Project | OpenStack 資源的組合 | **一些**CPU、**一些**儲存設備 | User 必須在 Project 中才能使用其資源 | Service | OpenStack 服務 | Nova、Neutron | User 透過 Endpoint 訪問 Service 取得資源 | Role | 角色權限分級 | admin、member | 除了驗證, KeyStone 也會確定 User 是否有對 Service 的訪問權限| :::info **Project** 一些資源的組合,並且可以將多個使用者加入 Project 中。 為了防止系統在沒有通知情況下耗盡資源,可以設置每個 Project 的資源上限。 每個 Project 預設資源(可從命令列更改): - Web 介面無法查看 project 的資源額度,要查看跟修改只能從命令列。 [資料來源](https://docs.openstack.org/horizon/pike/admin/set-quotas.html) ![](https://i.imgur.com/sxbQ156.png) [圖片來源](https://docs.openstack.org/cinder/rocky/cli/cli-cinder-quotas.html) ::: ### KeyStone - 身份認證套件 | 服務 | 套件(英) | 套件(中) | 負責事項 | | -------- | ------------ | -------- | --------| | Identity(認證)| KeyStone |身份認證套件| 提供對 User(使用者或服務)驗證與授權 提供 OpenStack 身份認證、服務認證的功能,可以說是一張 OpenStack 的註冊表,記錄了每個服務的 Endpoint ( API 訪問位址 ),服務之間的授權都需要透過 KeyStone,KeyStone 會做以下事情: 1. 管理用戶及其權限。 2. 管理 OpenStack 服務的 Endpoint。 3. Authentication(認證) 及 Authorization(授權)。 - KeyStone 架構: ![](https://i.imgur.com/D9mTeri.png) [圖片來源](https://www.cnblogs.com/itzhao/p/11333478.html) 1. Token: 用來生成和管理 Token。 2. Catalog: 用來儲存 Service/Endpoint 3. Identity: 用來管理 project/user/role 和驗證。 4. policy: 用來管理訪問權限。 - KeyStone 驗證流程: ![](https://i.imgur.com/uUMywO8.png) [圖片來源](https://www.sdnlab.com/17872.html) - 情境:科科想要使用學校的電腦教室 1. 去系辦( KeyStone ) 利用學生證( Credential )換教室鑰匙( Token ) 2. 利用鑰匙( Token )開啟電腦教室( Service ) 3. 電腦教室(Service)與系辦( KeyStone )確認是否是經授權的鑰匙( Token ) 4. 取得電腦教室( Service ) ### Nova - 運算套件 | 服務 | 套件(英) | 套件(中) | 負責事項 | | -------- | ------------ | -------- | --------| | Compute(計算) | Nova |運算套件 | 提供部署與管理虛擬機器的功能。 ![](https://i.imgur.com/v1gJazR.png) [圖片來源](http://blueskyfreeway2.blogspot.com/2019/05/openstack.html) - nova-api:接收外部請求。 - 說明:其他 OpenStack 的元件僅能透過 nova-api 使用 nova 的服務(如透過 Dashboard 請求 nova 創建一個 instance) 。 - nova-scheduler:根據目前資源使用情況,決定啟動哪一個節點建立虛擬機。 - 說明:用戶在創建 instance 時,會透過 nova-api 提出請求,請求中會包含了對資源需求,如 CPU、Memory 等,nova-schedule 接收到請求後,會檢視所有運行 nova-compute 的節點,並進行 Filtering 以及 Weighting ,挑選出合適的節點創建instance。 :::info **Filtering** nova-schedule 中有許多不同的 filter,nova-schedule 透過這些 filter 替除掉不適合的節點,接著進行在根據資源利用率進行 Weighting。 例如: - ComputeCapabilitiesFilter: 檢查主機提供的計算功能是否滿足 instance,滿足才會通過。 EX: `vcpus_total (compared with a number, values like: "= 48", ">=24")` `free_disk_mb (compared with a number, values like ">= 10240")` - NumInstancesFilter- 按 instance 數量過濾計算節點。實例過多的節點將被過濾。 ![](https://i.imgur.com/LxU1lQk.png) [圖片來源](https://docs.openstack.org/nova/wallaby/user/filter-scheduler.html) ::: :::info **Weighting** 依照目前資源的使用率 (costs),計算出各個節點的 weight,然後進行排序,決定出最適合部屬的節點,並傳送請求給這個節點的 nova-compute,進行 instance 的佈署。 - 權重 = 權重係數 x 權重器: `weight = w1_multiplier * norm(w1) + w2_multiplier * norm(w2) + ...` - 權重器: 例如: RAMWeigter - 根據計算節點上的可用 RAM 計算權重。 - 權重係數: 相較其他權重器的優先程度。 ![](https://i.imgur.com/ilmMOmf.png) [圖片來源](https://docs.openstack.org/nova/wallaby/user/filter-scheduler.html) ::: - nova-compute:接負責建立虛擬機。 - 說明:nova-compute 提供 instance 的佈署和運行,並透過 libvirt 支援 QEMU、KVM、Xen 等多種不同的 Hypervisor。 - libvirt: 提供統一的應用程式介面,以供不同種類 Hypervisor 連接。 - Nova-compute 非直接面對 Hypervisor ,而是透過 libvirt。 ![](https://i.imgur.com/xzPuKQM.png) [圖片來源](http://blueskyfreeway2.blogspot.com/2019/05/openstack.html) :::info **Hypervisor** 虛擬機管理平台,提供虛擬機與主機硬體間的管理,共同分享硬體資源。 ![](https://i.imgur.com/N57NL0G.png) - Type1 : 直接執行在宿主機的硬體上來控制硬體和管理客作業系統。 - Nova 裝在 dom 0(leader VM) 上。 - Tpye2 : 執行在傳統的作業系統上,就像其他電腦程式那樣執行。 - VituralBox - Nova 裝在 Host Operating System 上。 ::: - nova-conductor:根據請求讀取資料庫。 - 說明:一個介於 service(nova-compute等 )與 database 中間的間接程式,主要作用是避免 nova-compute 直接接觸 database,增加系統的安全性 ![](https://i.imgur.com/OoT3ti2.png) [圖片來源](https://docs.openstack.org/security-guide/databases/database-access-control.html) - 因為 nova-compute 管理租戶的 instance,比較不受信任,所以引入 conductor 作為 DB 的代理。 - 只有 compute 需要經由 conduntor 存取 DB 。 - 為了避免大量系統直接新增/修改/刪除 DB 資料。 - 建立虛擬機請求流程 ![](https://i.imgur.com/pvpRv3x.png =600x) [圖片來源](https://www.cnblogs.com/ajunyu/p/11111468.html) 1. 使用者跟 KeyStone 請求認證。 2. KeyStone 返回一 token 給使用者。 3. 使用者發送創建虛擬機請求給 nova-api (附帶 token)。 4. nova-api 拿 token 跟 KeyStone 確認。 5. 返回有效認證和對應的 role (有些操作需要 role 權限)。 6. 通過認證後和 DB 通訊。 7. 初始化新建虛擬機的 DB 紀錄。 8. nova-api 向 nova-scheduler 請求是否有創建虛擬機的資源。 9. nova-scheduler 取得 nova-api 的請求。 10. nova-scheduler 透過查詢 DB 計算符合需求的主機。 11. 對於有符合需求的物理主機,更新虛擬機對應物理主機的資料。 12. nova-scheduler 向 nova-compute 請求創建虛擬機。 13. nova-compute 取得 nova-scheduler 的請求。 14. nova-compute 向 nova-conductor 請求取得虛擬機訊息。 15. nova-conductor 取得 nova-compute 的請求。 16. nova-conductor 根據消息查詢虛擬機對應的資訊。 17. nova-conductor 從 DB 獲得虛擬機對應的資訊。 18. nova-conductor 將虛擬機資訊發送到 message queue 中。 19. nova-compute 從 message queue 中取得虛擬機資訊。 20. nova-compute 透過從 KeyStone 拿到的 token 向 glance-api 請求映像檔。 21. glance-api 向 keyStone 認證 token ,並返回結果。 22. nova-compute 取得映像檔。 23. nova-compute 透過從 KeyStone 拿到的 token 向 neutron server 請求網路資源。 24. neutron server 向 keyStone 認證 token ,並返回結果。 25. nova-compute 取得網路資源。 26. nova-compute 透過從 KeyStone 拿到的 token 向 cinder-api 請求儲存資源。 27. cinder-api 向 keyStone 認證 token ,並返回結果。 28. nova-compute 取得儲存資源。 29. nova-compute 根據虛擬機資訊來創建虛擬機。 :::info **AMQP** - Advanced Message Queuing Protocol - OpenStack 服務內部元件之間傳送訊息的方式。 - 是應用層的協定,目的在於訊息的排序與路由、保持可靠性。 - 降低應用間的耦合性(不需知道其他應用的語言、系統等..)。 - 支援非同步執行 - 發送消息設計成是不需要等待消息處理的完成。 [資料來源](https://docs.openstack.org/nova/queens/reference/rpc.html) ::: [參考資料](http://blueskyfreeway2.blogspot.com/2019/05/openstack.html) [參考資料](https://hackmd.io/@ncnu-opensource/book/%2F%403FqdH0BLSMGbFcpVdH08FA%2FH1uNCkaPO?type=book#%E7%94%9A%E9%BA%BC%E6%98%AF-OpenStack) https://docs.openstack.org/nova/pike/reference/rpc.html http://blueskyfreeway2.blogspot.com/2019/05/openstack.html ### Ironic - 裸機管理套件 | 服務 | 套件(英) | 套件(中) | 負責事項 | | -------- | ------------ | -------- | --------| | Bare Metal(裸機) | Ironic | 裸機管理套件 | 提供裸機的部署和安裝。| 在一些場景下,虛擬化的環境是不合適的,這些場景的用戶需要的是物理的裸機伺服器。爲了能夠滿足這些場景的服務需求,OpenStack 需要支持裸機的部署。 - 裸機優勢: - 單租戶,資訊安全較好。 - 效能比較好。 - 部署裸機: - 可以直接操作硬體設備。 - 部署映像到真正的物理機器。 --- ![](https://i.imgur.com/CYFOPwS.png) [圖片來源](https://docs.openstack.org/ironic/xena/install/get_started.html) > Fixme:怎麼無中生有 - Ironic 元件: - Ironic API: 接受外部請求,將請求傳給 Ironic Conductor 來處理。 - Ironic Conductor: 利用 Driver 在硬體上執行操作。 - 新增 / 編輯 / 刪除裸機節點。 - 每個 Conductor 可以 run 多個 Driver。 - Dirver: 透過不同的類型與介面,以支援不同廠商的硬體(物理機器)。 - DataBase: 儲存裸機硬體訊息及狀態。 - 使用者建立裸機流程: 1. 使用者請求由 Nova-API 與 Nova-Scheduler 傳遞給 Nova-Compute。 2. Nova-Compute 使用 Ironic Virt Driver 將請求交給 Bare Metal 服務(此 Ironic 服務)。 3. Ironic-API 將請求交給 Ironic-Conductor 處理。 4. Ironic-Conductor 與其他服務請求所需資源並交由 Driver 配置裸機。 [資料來源](https://ppfocus.com/0/te1deaa0e.html) [資料來源](https://docs.openstack.org/ironic/latest/install/get_started.html) ### Glance - 映像檔管理套件 | 服務 | 套件(英) | 套件(中) | 負責事項 | | -------- | ------------ | -------- | --------| | Image(映像) | Glance |映像檔管理套件 | 提供硬碟或伺服器的映象檔尋找、註冊以及服務交付等功能。 | ![](https://i.imgur.com/7ifkoQ5.png) [圖片來源](https://blog.csdn.net/qq_33909098/article/details/104414587) - Glance 主要工作: 1. 提供 API 給使用者查詢或獲取映像檔 (image) 和映像檔的 matadata。 2. 支援多種方式儲存映像檔,包括一般的文件系統、Swift等。 3. 對 instance 執行快照功能創建新的映像 :::info **metadata** 又稱中繼資料,用於描述其他資料資訊的資料。 例如: id, size, location... ::: - Glance 元件: 1. glance-api: 對外部請求做處理。 - 如果是映像檔 matadata 的相關操作,會把請求轉發給 glance-registry 做處理。 - 如果是映像檔的存取,會轉發給儲存該 image 的儲存後端。 2. glance-registry: 儲存或取得映像檔的 metadata,與 DB 進行交換。 - 依照 metadata 知其映像檔的 location ,進而去後端儲存設備取得資料。 3. store backend: 真正儲存映像檔的位址。 - 流程 ![](https://i.imgur.com/bBA0oZf.png) [資料來源](https://blog.csdn.net/qq_33909098/article/details/104414587) ### Neutron - 網路套件 | 服務 | 套件(英) | 套件(中) | 負責事項 | | -------- | ------------ | -------- | --------| | Network(網路) | Neutron |網路套件 | 提供網路服務。| - Neutron 是 OpenStack 的網絡服務。它將網絡、子網、埠和路由器抽象化,由 Nova 啟動的虛擬主機就可以連接到這個虛擬網絡上,讓虛擬主機有上網的功能。 - 透過不同後端的 plugin (外掛程式),提供不同的網路設備、軟體。 - 功能: - 交換器: 提供同一網段的 VM 於 Layer 2 的連通性。 - 路由器: 提供 L3 網路功能, SNAT、DNAT 等。 - 防火牆: 提供基本防火牆,port blocking 等。 - 架構: ![](https://i.imgur.com/ZiVpgbn.png) [圖片來源](http://blueskyfreeway2.blogspot.com/2019/05/openstack.html) - Neutron Server: 接受請求,並轉發至相應的 Plug-in 執行操作。 - Plugin & Agent: 提供不同的虛擬網路服務,創建網路、子網路、IP 位置...。 - 根據不同供應商和技術而異。 - 常見的 Plugin 有: Linux bridge 、 Open vSwitch(OVS)等。 - Message Queue: neutron-server 和 agent 之間交換訊息用。 - Database: 儲存網路狀態及資訊。 :::info - **SDN (SoftWare-Defined Networking Service):** - 將控制層 (Control layer) 與資料層 (Data layer) 分離開來。 - 不更改網路基礎設備前提下,以軟體的方式修改網路。 ![](https://i.imgur.com/uZtDRW0.png) [圖片來源](https://ithelp.ithome.com.tw/articles/10197629) - Applictation Layer: 向使用者提供的服務。 - 主要透過 Restful API 跟 Control layer 溝通。 (northbound) - Control Layer:SDN的核心,透過它去控制 Infastructure Layer。 (southbound) - 主要透過 OpenFlow 協議跟 Infrastructure layer 溝通。 - Infrastructure Layer:指基礎的網路設備,如:硬體 switch。 > FIXME: control plan、data plan - **OpenFlow:** 一種協議,使 SDN 控制器能夠與物理和虛擬的交換機和路由器等網路裝置的 Infrastructure layer 進行互動。 ::: - Neutron Server 就像 SDN 控制器一樣對上提供 API ,對下提供各種 agent 不同的網路服務,但如果 Neutron 要涵蓋所有網路服務功能與協議的話需要重寫一堆 agent 跟 driver,功能上也會變更複雜,因此一些網路服務直接使用現成的 SDN 控制器即可。 [資料來源](https://www.zhihu.com/question/37126320) - 以 Linux Bridge with Provider Network 為例,架構及資訊流向: - Provider Networks - 只有管理員才能創建或更新。 - 需要跟實際物理的網路基礎設施吻合,連接到資料中心現有的 L2 網路。 - 使用 VLAN (802.1Q) tagging 來識別和隔離。 :::info **802.1Q 格式** ![](https://i.imgur.com/u00Gd88.png) [圖片來源](https://support.huawei.com/enterprise/en/doc/EDOC1100088104) - TPID: 識別是否為 802.1Q 封包,若為 0x8100 則是。 - PRI: 0~7 用來指定優先權。 - CFI: 0 表示 MAC 位址為標準格式,1 則相反。用來做乙太與權杖還不同介質的網路相容。 - VID: 表示不同區段的 VLAN,0 與 4096 為保留,所以可用數 4094 個。 ::: ![](https://i.imgur.com/cJNlAuY.png) [圖片來源](https://igene.tw/openstack-neutron-linux-bridge-provider) - 如果有多個 Provider NetWork ,會在每個 compute node 上對應到一個 Linux Bridge,並且用 VLAN 隔離。 - instance 會接到對應的 Linux Bridge 上。 - Instance 將封包送往外部網路流程: ![](https://i.imgur.com/1Rknsb8.png) [圖片來源](https://igene.tw/openstack-neutron-linux-bridge-provider) - Instance 的網路介面 (1) 透過 veth 將封包送往 Linux bridge 的 instance port (2) - 在 Linux bridge 上 iptables (3) 會處理防火牆功能 - Linux bridge 上的 VLAN sub-interface port (4) 會將封包送往實體網路介面 (5) - 實體網路介面將封包加上 VLAN tag 101 並且送往實體網路設施中的 Switch (6) - 後續步驟跟實體網路一樣。 - 同 VLAN 下的 Instances 互傳: ![](https://i.imgur.com/1ktHHWc.png) [圖片來源](https://igene.tw/openstack-neutron-linux-bridge-provider) 1. 從 node1 發送出去: - Instance 的網路介面 (1) 透過 veth 將封包送往 Linux bridge 的 instance port (2) - 在 Linux bridge 上 iptables (3) 會處理防火牆功能 - bridge 上的 VLAN sub-interface port (4) 會將封包送往實體網路介面 (5) :::info **sub-interface** 將物理介面虛擬出來的多個虛擬邏輯介面 (sub-interface) ,使能夠在一個物理介面中與多個 VLAN 通訊。 [資料來源](https://baike.baidu.hk/item/%E5%AD%90%E6%8E%A5%E5%8F%A3/10693062) ::: - 實體網路介面將封包加上 VLAN tag 101 並且送往實體網路設施中的 Switch (6) 2. 在實際網路基礎設施中: - switch 將封包從 compute node 1 送往 compute node 2 3. 到達 node2 後: - 實體網路介面 (8) 將 VLAN tag 101 拿掉並且送往 Linux bridge 上的 VLAN sub-interface port (9) - 在 Linux bridge 上 iptables (10) 會處理防火牆功能 - Linux bridge 上的 instance port (11) 透過 veth 將封包送往 instance 2 的網路介面 (12) - 不同 VLAN 下的 Instances 互傳: ![](https://i.imgur.com/mWdzudX.png) [圖片來源](https://igene.tw/openstack-neutron-linux-bridge-provider) 1. 從 instance 1 發送出去: - Instance 的網路介面 (1) 透過 veth 將封包送往 Linux bridge 的 instance port (2) - 在 Linux bridge 上 iptables (3) 會處理防火牆功能 - bridge 上的 VLAN sub-interface port (4) 會將封包送往實體網路介面 (5) - 實體網路介面將封包加上 VLAN tag 101 並且送往實體網路設施中的 Switch (6) 2. 在實際網路基礎設施中: - switch 將封包 VLAN tag 101 拿掉並且送往 router (7) - router 將封包從 provider network 1 (8) 路由到 provider network 2 (9) - router 將封包送往 switch (10) - switch 將封包加上 VLAN tag 102 並且送往 compute node 1 (11) 3. 回到 compute node 1 上: - 實體網路介面 (12) 將 VLAN tag 102 拿掉並且送往 Linux bridge 上的 VLAN sub-interface port (13) - 在 Linux bridge 上 iptables (14) 會處理防火牆功能 - Linux bridge 上的 instance port (15) 透過 veth 將封包送往 instance 2 的網路介面 (16) ### Cinder - 區塊儲存套件 | 服務 | 套件(英) | 套件(中) | 負責事項 | | -------- | ------------ | -------- | --------| | Block Storage(區塊儲存) | Cinder |區塊儲存套件| 提供 Block Storage 服務 - 作業系統獲得儲存空間的方式: 1. 通過某種協議 (SAS,SCSI,SAN,iSCSI 等) 掛接裸硬碟,然後分割槽、格式化、建立檔案系統。 2. 通過 NFS、CIFS 等 協議,mount (掛載)遠端的檔案系統。 - Cinder 本身不為儲存設備,而是作為儲存服務中間的管理者。 - 向外提供穩定統一的 Block Storage 服務,讓使用者可以取資源。 - 向內透過 Plugin & Driver 對接多樣化的後端儲存設備。 - 運行 Cinder 的節點稱為儲存節點。 ![](https://i.imgur.com/x3rz9TS.png) [圖片來源](https://netapp.github.io/openstack-deploy-ops-guide/liberty/content/section_cinder-processes.html) :::info **volume (卷)** 從虛擬主機角度看,每一個掛載的 volume 都是一塊硬碟,為主機提供外部儲存空間。 ::: - Cinder 元件: - cinder-api: 接收 API 請求,呼叫 cinder-volume 執行操作。 - cinder-volume: 管理 volume 的服務,與 volume provider 協調工作,管理 volume 的生命週期。執行 cinder-volume 服務的節點被稱作為儲存節點。 - cinder-scheduler: 通過排程演算法選擇最合適的儲存節點建立 volume。 - message queue: Cinder 各個子服務通過訊息佇列實現程序間通訊和相互協作。 - 功能: - 提供 REST API 使使用者能夠查詢和管理 volume、volume snapshot 以及 volume type。 - 提供 scheduler 排程 volume 建立請求,合理優化儲存資源的分配。 - 提供 nova 儲存資源。 - Nova 本身不會管儲存的事,必須依靠 cinder 來模擬硬碟服務給 VM 用。 - 通過 driver 架構支援多種 backend(後端)儲存方式,包括 LVM,NFS,Ceph 等儲存產品和方案。 :::info **Driver 架構** 因為 Cinder 支援多種 volume provider (LVM, NFS, Ceph...),Cinder 為這些 provider 提供一個統一的介面,provider 只需要對接這個介面就可以隨插隨用到 OpenStack 中。 ![](https://i.imgur.com/QninZHq.png) [圖片來源](https://blog.csdn.net/qq_42533216/article/details/114693454) --- **Ceph** 是一個叢集式的儲存環境,由存叢集、函式庫、服務存取介面三層架構組成。 ![](https://i.imgur.com/S3hVFYh.png) [圖片來源](https://www.ithome.com.tw/tech/98860) - 儲存叢集 - RADOS(Reliable, Autonomic Distributed Object Store): 可靠、能自我管理的分散式物件儲存區。 - Ceph OSD Daemon (OSD) : - 負責儲存資料、彼此覆寫或回覆資料、傳回硬碟與資料狀態。 - 伺服器內的每一臺硬碟都會配備一個 OSD 程式。 - Ceph Monitor (MON): - 提供給使用者存取,掌握整個叢集的狀態。 - 函式庫 - RADOUS Library: - 提供了原生的應用程式存取介面。 - 使用者可自行開發應用程式,以這些API直接存取Ceph儲存叢集的節點。 - 服務存取介面 - Ceph Clients: - Ceph Object Storage: - Ceph 的物件儲存裝置。 - 又稱 RADOS Gateway(RADOSGW,RGW)。 - 相容 Amazon S3、OpenStack Swift。 - Openstack 利用 LIBGW 函式庫存取。 - Ceph Block Device: - Ceph 的區塊儲存裝置。 - 又稱RADOS Block Device(RBD)。 - OpenStack系統,透過RBD來存取Ceph儲存叢集時,主要是借助LIBRBD這個函式庫來直接存取。 - Ceph Filesystem: - 可供使用者掛載,以便存取檔案或資料夾。 - MDS(Metadata Server): - 儲存檔案系統的 metadata。 - 記載了目錄(directory)、檔案擁有權、存取模式等資料。 ::: - nova 請求 volume 流程 ![](https://i.imgur.com/fbURwDi.png) 1. 使用者調用 nova-api 發出 volume 的請求。 2. nova-api 驗證使用者後向 cinder-api 索取特定 volume 的連接資訊。 3. cinder-api 驗證使用者後,將請求消息發到 messaging bus 中。 4. cinder-volume 從 messaging bus 取得請求消息,調用 volume 對應的 driver。 5. driver 準備 volume 以準備連接。 6. cinder-volume 將回應訊息透過 messaging bus 傳給 cinder-api。 7. cinder-api 從 messaging bus 取得連接訊息並傳給 nova 調用者。 8. nova 透過返回連接資訊準備與儲存設備連接。 9. nova 將 volume 設備位址、檔案給 hypervisor,hypervisor 將 volume 掛載到 guest VM 作為儲存設備。 [資料來源](https://netapp.github.io/openstack-deploy-ops-guide/liberty/content/section_cinder-processes.html) [資料來源](https://blog.csdn.net/qq_42533216/article/details/114693454) [資料來源](https://www.796t.com/article.php?id=133569) ### Swift - 物件儲存套件 | 服務 | 套件(英) | 套件(中) | 負責事項 | | -------- | ------------ | -------- | --------| | Object Storage(物件儲存)| Swift |物件儲存套件| 用於存放非結構性資料。 :::info **結構化 vs 非結構化資料** ![](https://i.imgur.com/ttuK25x.png) [圖片來源](https://ithelp.ithome.com.tw/articles/10200157) - 結構化資料:資料可以被呈現在資料庫table的行、欄中。 - 統計術語:每一行代表一個觀測,欄位是那筆觀測的表徵。 - 非結構化資料:形式自由且不遵循標準的格式規範,一團沒有組織的數據。 - 無經過正規劃的表徵: ![](https://i.imgur.com/P6ep1N8.png =300x) [圖片來源](https://ithelp.ithome.com.tw/articles/10200157) 以此例子來說,一筆觀測由日期與狀態組成(不同屬性的表徵),屬於非結構。 - 沒有統一的格式: ![](https://i.imgur.com/EEuUlwm.png) [圖片來源](https://ithelp.ithome.com.tw/articles/10200157) 整體表徵無ㄧ致,屬於非結構。 ::: Swift 一般用於存放非結構性資料,如網路內容、備份、影像和 VM 快照,它透過 REST API 操作 (儲存、刪除、取得) 物件 (object) 。 - 特色: - 擴展性高:需要擴展時: - 新增儲存點 (storage node) 因應儲存空間的需求。 - 新增伺服器點 (proxy node) 因應連線需求的增加。 - 可靠度高: - 所有儲存在 Swift 的物件 (Object) 都以一式三份(預設)的複製,分散於叢集 (cluster) 中。所以每一次的資料寫入,都會確認是否也同時寫入其他兩個位置才會視為成功。 - replica-count: 複製的數量,預設為 3 份,可更改,但不建議設定在 3 以下,比較不可靠。 >FIXME:讀取是3份嗎?貌似是1份 :::info **cluster - 電腦叢集** ![](https://i.imgur.com/7k7QjBZ.png) 一組電腦以某種方式(區域網路)連接起來,共同完成計算。 - 提高運算速度與可用性。 - 從用戶的角度視為一台強大處理能力的伺服器。 ::: ![](https://i.imgur.com/bb0Ngbs.png) [圖片來源](http://blueskyfreeway2.blogspot.com/2019/05/openstack.html) - Swift 元件: - proxy server: Proxy server process 是 Swift 中直接與外部的 client 連線的部分,用來處理來自外部的 HTTP request & response。 > FIXME:2.哪些使用者有哪些object要在哪裡查 只找到列出 Account 裡的 container 或 container 裡的 object [來源](https://docs.openstack.org/ocata/cli-reference/swift.html) - Ring: 名稱與實體位置的 mapping,利用此去查到在 cluster 中的存放位置。 - Object server: 負責實際檔案的儲存(如 volume),檔案是以二進位的方式儲存於磁碟中。 - Container server: 處理 Container metadata & 包含在內的 object 資訊。 - 可以想像成 Google Drive 裡面的資料夾,是使用者自行定義的儲存區域(Storage Area)。 - 跟 Docker & Container 的 Container 不同。 - Account server: 用來處理與 Account 相關的 metadata & Account 內所包含的 Container 資訊 - 一堆 Container 的集合 - 可以想成放置一堆資料夾的檔案櫃。 ![](https://i.imgur.com/7c8o4K8.png) [圖片來源](https://platform.swiftstack.com/docs/introduction/openstack_swift.html) :::info **ACL (Access Control List)** 控制哪個使用者可以存取/寫入 - Container ACL: - X-Container-Write: 授予對象 PUT、POST 和 DELETE 操作的能力。 - X-Container-Read: 授予對象 GET 和 HEAD 操作的能力。 - Keystone Auth ACL: - [project-id] : [user-id] => 授予使用者存取某 project 的能力,同時也授予 project 中 X-Container-Read 的能力。 [資料來源](https://docs.openstack.org/swift/latest/overview_acl.html#acl-common-elements) ::: - 為了保持每個節點的資料一致: - Auditor server: 運作在每一個 storage node 中,持續掃描磁碟確認沒有任何錯誤的發生,若是有錯誤發生,Auditor service 就會將有問題的 object 移到隔離區。 ![](https://i.imgur.com/Va5vrpq.png =300x) [圖片來源](https://platform.swiftstack.com/docs/introduction/openstack_swift.html) - 例如: **Bit rot** Bit rot 是指資料發生位元隨機翻轉的現象(0 變 1 或 1 變 0),通常在: 1. 儲存媒介或硬體逐漸磨損過程中老化而發生。 2. 宇宙射線。 - Replicator server: 在後端運行,用來確保本地端的資料與 Cluster 中其他 storage node 的資料是一致的。 ![](https://i.imgur.com/c5cKtky.png =500x) [圖片來源](https://platform.swiftstack.com/docs/introduction/openstack_swift.html) - Auditor & Replicator 相互運作: ![](https://i.imgur.com/EDR8ije.png) [參考資料](https://platform.swiftstack.com/docs/introduction/openstack_swift.html) [參考資料](http://blueskyfreeway2.blogspot.com/2019/05/openstack.html) [參考資料](http://godleon.blogspot.com/2014/10/openstack-swift_14.html) [參考資料](https://ithelp.ithome.com.tw/articles/10092536) [Auditor, Replicator流程](https://read01.com/zh-tw/Pk6B4B.html#.Ykv8PJNByqk) ### Horizon - 儀表板套件 ![](https://i.imgur.com/m9boHc6.png) [圖片來源](http://blueskyfreeway2.blogspot.com/2019/05/openstack.html) Horizon 是使用者操作介面,可以用瀏覽器開啟,可以綜觀雲端服務目前的規模與狀態,並且能夠統一存取、部署與管理所有雲端服務所使用到的資源。 ### Heat - 編排套件 | 服務 | 套件(英) | 套件(中) | 負責事項 | | -------- | ------------ | -------- | --------| | Orchestrate(編排) | Heat | 編排套件 | 提供模板自動化配置資源 | - 當管理的東西太多時,一項項設定太麻煩,利用 templete (模板) 來定義一系列 resource 設定。 - 例如:虛擬機啟動、IP 設定、volume 掛載等... - 舉例:創建 instance 和 volume ,將 volume 掛載到 instance 上: ![](https://i.imgur.com/bYhRp93.png) [圖片來源](http://wsfdl.com/openstack/2014/02/14/Introduction_to_heat.html) - Stack: 解析 templete 後生成一個 stack , 代表 resource 的集合, 透過創建一個 stack 就可以完成一系列操作。 ![](https://i.imgur.com/C0o3FFa.png) [資料來源](http://wsfdl.com/openstack/2014/02/14/Introduction_to_heat.html) [資料來源](https://kknews.cc/zh-tw/code/2nbkmeg.html) ## 實作 選擇使用 microstack - 安裝快速。 - 輕量化的 OpenStack - 包在 snap 裡,包含了 Keystone、Nova、Cinder、Glance 等 OpenStack 服務。 - 不需要自行安裝、設定各項套件。 ### 安裝 MicroStack - 安裝需求: - 8G RAM - 多核心處理器 - linux 作業系統 - Ubuntu 18.04 LTS 或 Ubuntu 20.04 LTS ``` sudo snap install microstack --beta --devmode ``` - `--beta`: 測試版的 channel - `--devmode`: 對系統有完全存取權限 ![](https://i.imgur.com/VIKIim6.png) - 看到 microstack (beta) ussuri from Canonical✓ installed 表示安裝成功 - ussuri 為版本 [資料來源](https://snapcraft.io/docs/snap-confinement) ### 初始化 ``` sudo microstack init --auto --control ``` - microstack 使用前需要先初始化,配置 DataBase 、網路、映像檔等基本安裝與設定。 - 需要 15-20 分鐘,OpenStack 就會被設定好了! ![](https://i.imgur.com/odvItMt.png) - 查看哪些服務可以使用: ``` microstack.openstack catalog list ``` ![](https://i.imgur.com/5KQk43j.png) ### 利用 Web 操作 OpenStack - 安裝 net-tools ``` sudo apt install net-tools ``` - ifconfig 查看 IP 地址 ![](https://i.imgur.com/tgkbksm.png) 使用 10.20.20.1 進入 OpenStack 登入畫面 - 此用系統預設好的 admin 座椅下操作,登入密碼用下面指令取得: ``` sudo snap get microstack config.credentials.keystone-password ``` 密碼範例: `OAEHxLgCBz7Wz4usvolAAt61TrDUz6zz` - 10.20.20.1 進入登入畫面: ![](https://i.imgur.com/UILxQps.png) - 登入後可以使用 Web 查看與管理資源: ![](https://i.imgur.com/sYQPdDx.png) 可以看到已經有一些剛剛 init 初始化後自動裝上的一些資源 例如: cirros 映像檔 ![](https://i.imgur.com/vcY3D7k.png) ### 建立虛擬機 ``` microstack launch cirros --name 'VM名稱' ``` - cirros 是映像檔(初始化時 microstack 自動裝的) ![](https://i.imgur.com/9NWju8C.png) - 建立完後可以得到 VM 的 ssh 資訊 查看虛擬機資源 ``` microstack.openstack server list ``` - 可以看到剛剛建立的 VM ![](https://i.imgur.com/4yJrfGO.png) - Web 也有出現 ![](https://i.imgur.com/Cn5NyTQ.png) 接著就可以連線到 VM 了! ![](https://i.imgur.com/ioeEgw2.png) ### 停用 / 啟用虛擬機 如果暫時不用 microstack 時可以停用,之後再重啟 - 停用 ``` sudo snap disable microstack ``` - 啟用 ``` sudo snap enable microstack ``` ### 新增 Project 與 User - 查看 project 清單 ``` microstack.openstack project list ``` ![](https://i.imgur.com/2onb7u5.png) - 新增 project ``` microstack.openstack project create 'Project 名稱' ``` ![](https://i.imgur.com/9gN9y9C.png) - 成功建立 ![](https://i.imgur.com/uS7Rk9y.png) - 新增 User ``` microstack.openstack user create --password '密碼' '使用者名稱' ``` ![](https://i.imgur.com/oEvnHg6.png) - 將 User 加入到 Project 中 ``` microstack.openstack role add member --project 'project 名稱' --user 'user 名稱' ``` ![](https://i.imgur.com/KYkNy28.png) - 重新登入新的 User ![](https://i.imgur.com/P0Er1iU.png) - 可以開始備置自己的資源! ![](https://i.imgur.com/vhOXUP5.png) [資料來源](https://discourse.ubuntu.com/t/get-started-with-microstack/13998) [資料來源](https://blog.csdn.net/qq_45945548/article/details/112710277)

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully