添加 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

相关文章
相关标签/搜索