我們已經有了 Load Balance Pool “web servers”和 VIP,接下來需要往 Pool 裡添加 member 并學習如何使用 cloud image。 先準備兩個 instance: “Web1” 和 “Web2”。
由于 cirros 鏡像不能運作 HTTP 服務,我們将使用 Ubuntu Cloud Image。
與以前的 instance 不同,Web1 和 Web2 使用了命名為“cloud”的 Key Pair。
這是因為 Ubuntu Cloud Image 預設使用者 “ubuntu” 的密碼是随機生成的,通過 Key Pair 通路是一個比較友善的方法。
下面是 Key Pair 的配置方法:
通過 ssh-keygen 生成 Key Pair。
其中 cloud.key.pub 是公鑰,需要添加到 instance 的 ~/.ssh/authorized_keys 檔案中。 cloud.key 是私鑰,用于通路 instance。
将 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” 成功導入。
使用 Key Pair “cloud”。 launch instance 的時候,在 Access & Security 标簽頁中選擇 Key Pair “cloud”。 OpenStack 會自動将公鑰添加進 instance 的 ~/.ssh/authorized_keys 檔案。
ssh instance。 用 -i cloud.key 指定私鑰,并以 ubuntu 使用者 ssh “Web1” 和 “Web2”。
無需密碼直接登入 instance。
注:為了便于示範,這裡我們是在 router 的 namespace 中執行 ssh,主要目的是網絡可達。
“Web1” 和 “Web2” 準備就緒了,可以添加到 Pool 中了。 在 Project -> Network -> Load Balancers 的 Members 标簽頁中 點選 “Add Member” 按鈕。
Pool 選擇 “web servers”。 Member(s) 中多選 “Web1” 和 “Web2”。 Protocol Port 設定為 “80”。
點選 “Add”,member 添加成功。
Pool Member 有了,下一節我們将為 Pool 建立 Monitor,用于 Member 健康檢查。
本文轉自CloudMan6 51CTO部落格,原文連結:http://blog.51cto.com/cloudman/1881000