添加 Pool Member - 天天5分鐘玩轉 OpenStack(123)

咱們已經有了 Load Balance Pool 「web servers」和 VIP,接下來須要往 Pool 裏添加 member 並學習如何使用 cloud image。 先準備兩個 instance: 「Web1」 和 「Web2」。web

使用 Ubuntu Cloud Image

因爲 cirros 鏡像不能運行 HTTP 服務,咱們將使用 Ubuntu Cloud Image。
下載地址爲 http://uec-images.ubuntu.com/trusty/current/trusty-server-cloudimg-amd64-disk1.imgubuntu

與之前的 instance 不一樣,Web1 和 Web2 使用了命名爲「cloud」的 Key Pair。
這是由於 Ubuntu Cloud Image 默認用戶 「ubuntu」 的密碼是隨機生成的,經過 Key Pair 訪問是一個比較方便的方法。網絡

下面是 Key Pair 的配置方法:ssh

  1. 經過 ssh-keygen 生成 Key Pair。

    其中 cloud.key.pub 是公鑰,須要添加到 instance 的 ~/.ssh/authorized_keys 文件中。 cloud.key 是私鑰,用於訪問 instance。學習

  2. 將 Pair Key 導入 OpenStack 進入 Project -> Compute -> Access & Security 菜單,點擊 Key Pairs 標籤頁的 「Import Key Pair」 按鈕。


    複製 cloud.key.pub 的內容。


    粘貼到 Public Key 輸入框中,給 Key Pair 命名爲 「cloud」,並點擊 「Import Key Pair」。

    Key Pair 「cloud」 成功導入。
    spa

  3. 使用 Key Pair 「cloud」。 launch instance 的時候,在 Access & Security 標籤頁中選擇 Key Pair 「cloud」。 OpenStack 會自動將公鑰添加進 instance 的  ~/.ssh/authorized_keys 文件。
    router

  4. ssh instance。 用 -i cloud.key 指定私鑰,並以 ubuntu 用戶 ssh 「Web1」 和 「Web2」。

    無需密碼直接登陸 instance。
    注:爲了便於演示,這裏咱們是在 router 的 namespace 中執行 ssh,主要目的是網絡可達。server

「Web1」 和 「Web2」 準備就緒了,能夠添加到 Pool 中了。 在 Project -> Network -> Load Balancers 的 Members 標籤頁中 點擊 「Add Member」 按鈕。ci

Pool 選擇 「web servers」。 Member(s) 中多選 「Web1」 和 「Web2」。 Protocol Port 設置爲 「80」。get

點擊 「Add」,member 添加成功。

Pool Member 有了,下一節咱們將爲 Pool 建立 Monitor,用於 Member 健康檢查。

 

二維碼+指紋.png

相關文章
相關標籤/搜索