openstack虚拟机VIP配置步骤

在openstack上的虚拟机绑定vip

有时候需要配置vip搭建高可用集群,下面我就简单的说下在openstack上的虚拟机如何绑定vip

操作步骤

1、 执行命令neutron net-list查看网络,找到自己需要设置的网络,获取subnet_id和network_id

1
2
3
4
5
6
7
8
[root@controller neutron]# neutron net-list
neutron CLI is deprecated and will be removed in the future. Use openstack CLI instead.
+--------------------------------------+-------------+----------------------------------+------------------------------------------------------+
| id | name | tenant_id | subnets |
+--------------------------------------+-------------+----------------------------------+------------------------------------------------------+
| 0417bb19-0986-43cc-ae28-7515b6b94a7e | vlan135-test | b4cf8c990abb481a908a735104ec6724 | 0aaaa1f7-9ed1-4e48-9fcb-c3803ab91199 172.17.14.0/22 |
| 0ae2f077-799c-400b-97b7-68007867d020 | vlan136-dev | b4cf8c990abb481a908a735104ec6724 | 7b0f287f-0bde-44c0-9680-152371c4b4d0 172.17.10.0/22 |
+--------------------------------------+-------------+----------------------------------+------------------------------------------------------+

2、创建port来占用ip,保证neutron不会将此IP在分配出去,导致IP冲突问题。

1
2
3
4
5
neutron port-create --fixed-ip subnet_id=<subnet_id>,ip_address=<vip> <network_id>
注:
替换subnet_id为neutron net-list中查看到的subnet_id
替换vip为需要配置的vip地址
替换network_ID为neutron net-list中查看到的network_id

3、执行命令neutron port-list查看端口,找到VIP的Port ID以及需要使用VIP的虚拟机的IP对应的Port id
比如两台虚拟机做HA绑定vip,那么需要查看两台虚拟机的port ID和这个vip的port ID

1
2
3
4
比如:
neutron port-list|grep 172.17.14.244 vip地址
neutron port-list|grep 172.17.14.139 机器1地址
neutron port-list|grep 172.17.14.165 机器2地址

4、 取消安全组对应端口的管理

1
2
3
4
neutron port-update --no-security-groups <Port_id>
neutron port-update --port_security_enabled=false <Port_id>
注:
替换Port_id为之前neutron port-list中找到的Port_id

参考文档:

1
https://www.lijiawang.org/posts/%E5%9C%A8openstack%E4%B8%8A%E7%9A%84%E8%99%9A%E6%8B%9F%E6%9C%BA%E7%BB%91%E5%AE%9Avip.html
Donate