可用区域对运行服务(如DHCP,L3,FW和其他)的网络节点进行分组。 它被定义为网络节点上的代理的属性。 这允许用户将可用性区域与其资源相关联,以便资源获得高可用性。
用例
可用性区域用于使网络资源高度可用。 运营商将在不同的可用性区域下连接到不同电源的节点分组,并为具有高可用性的资源配置调度,以便将它们安排在不同的可用区域上。
必需的扩展
核心插件必须支持availability_zone扩展。 核心插件还必须支持network_availability_zone扩展,以根据可用区域计划网络。 Ml2插件支持它。 路由器服务插件必须支持router_availability_zone扩展,以根据可用区域计划路由器。 L3RouterPlugin支持它。
$ neutron ext-list
+---------------------------+-----------------------------------------------+
| alias | name |
+---------------------------+-----------------------------------------------+
...
| network_availability_zone | Network Availability Zone |
...
| availability_zone | Availability Zone |
...
| router_availability_zone | Router Availability Zone |
...
+---------------------------+-----------------------------------------------+
代理的可用区域
可以在dhcp-agent和l3-agent中定义availability_zone属性。 要为每个代理定义可用区域,请将该值设置到/etc/neutron/dhcp_agent.ini或/etc/neutron/l3_agent.ini的[AGENT]部分中:
[AGENT]
availability_zone = zone-1
要确认代理的可用区:
$ neutron agent-show ca203db1-9f7f-40a7-91aa-4b184886e65d
+---------------------+----------------------------------------------------------+
| Field | Value |
+---------------------+----------------------------------------------------------+
| admin_state_up | True |
| agent_type | DHCP agent |
| alive | True |
| availability_zone | zone-1 |
| binary | neutron-dhcp-agent |
| configurations | { |
| | "subnets": 0, |
| | "dhcp_lease_duration": 86400, |
| | "dhcp_driver": "neutron.agent.linux.dhcp.Dnsmasq", |
| | "networks": 0, |
| | "log_agent_heartbeats": false, |
| | "ports": 0 |
| | } |
| created_at | 2015-12-10 00:30:19 |
| description | |
| heartbeat_timestamp | 2015-12-10 00:54:09 |
| host | mitaka |
| id | ca203db1-9f7f-40a7-91aa-4b184886e65d |
| started_at | 2015-12-10 00:45:09 |
| topic | dhcp_agent |
+---------------------+----------------------------------------------------------+
$ neutron agent-show 4d8aa289-21eb-4997-86f2-49a884f78d0b
+---------------------+---------------------------------------------+
| Field | Value |
+---------------------+---------------------------------------------+
| admin_state_up | True |
| agent_type | L3 agent |
| alive | True |
| availability_zone | zone-1 |
| binary | neutron-l3-agent |
| configurations | { |
| | "router_id": "", |
| | "agent_mode": "legacy", |
| | "gateway_external_network_id": "", |
| | "handle_internal_only_routers": true, |
| | "routers": 0, |
| | "interfaces": 0, |
| | "floating_ips": 0, |
| | "interface_driver": "openvswitch", |
| | "log_agent_heartbeats": false, |
| | "external_network_bridge": "br-ex", |
| | "ex_gw_ports": 0 |
| | } |
| created_at | 2015-12-10 00:30:22 |
| description | |
| heartbeat_timestamp | 2015-12-10 00:54:48 |
| host | mitaka |
| id | 4d8aa289-21eb-4997-86f2-49a884f78d0b |
| started_at | 2015-12-10 00:45:18 |
| topic | l3_agent |
+---------------------+---------------------------------------------+
可用区相关属性
以下属性添加到网络和路由器中:
属性名称 | 访问 | 需求 | 输入类型 | 描述 |
---|---|---|---|---|
availability_zone_hints | RW(POST only) | No | list of string | 资源的候选可用区域 |
availability_zones | RO | N/A | list of string | 资源的可用区域 |
使用availability_zone_hints指定资源所在的区域:
$ neutron net-create --availability-zone-hint zone-1 \
--availability-zone-hint zone-2 net1
Created a new network:
+---------------------------+--------------------------------------+
| Field | Value |
+---------------------------+--------------------------------------+
| admin_state_up | True |
| availability_zone_hints | zone-1 |
| | zone-2 |
| id | 0ef0597c-4aab-4235-8513-bf5d8304fe64 |
| mtu | 1450 |
| name | net1 |
| port_security_enabled | True |
| provider:network_type | vxlan |
| provider:physical_network | |
| provider:segmentation_id | 1054 |
| router:external | False |
| shared | False |
| status | ACTIVE |
| subnets | |
| tenant_id | 32f5512c7b3f47fb8924588ff9ad603b |
+---------------------------+--------------------------------------+
$ neutron router-create --ha True --availability-zone-hint zone-1 \
--availability-zone-hint zone-2 router1
Created a new router:
+-------------------------+--------------------------------------+
| Field | Value |
+-------------------------+--------------------------------------+
| admin_state_up | True |
| availability_zone_hints | zone-1 |
| | zone-2 |
| availability_zones | |
| distributed | False |
| external_gateway_info | |
| ha | True |
| id | 272f9be2-e352-4138-92a7-f022449b83a0 |
| name | router1 |
| routes | |
| status | ACTIVE |
| tenant_id | 32f5512c7b3f47fb8924588ff9ad603b |
+-------------------------+--------------------------------------+
如果在没有availability_zone_hints的情况下创建资源,则可用区域从/etc/neutron/neutron.conf中的default_availability_zones中选择:
default_availability_zones = zone-1,zone-2
要确认系统定义的可用区:
$ neutron availability-zone-list
+--------+----------+-----------+
| name | resource | state |
+--------+----------+-----------+
| zone-2 | router | available |
| zone-1 | router | available |
| zone-2 | network | available |
| zone-1 | network | available |
+--------+----------+-----------+
查看每个资源的availability_zones属性以确认资源所在的区域:
$ neutron net-show net1
+---------------------------+--------------------------------------+
| Field | Value |
+---------------------------+--------------------------------------+
| admin_state_up | True |
| availability_zone_hints | zone-1 |
| | zone-2 |
| availability_zones | zone-1 |
| | zone-2 |
| id | 0ef0597c-4aab-4235-8513-bf5d8304fe64 |
| mtu | 1450 |
| name | net1 |
| port_security_enabled | True |
| provider:network_type | vxlan |
| provider:physical_network | |
| provider:segmentation_id | 1054 |
| router:external | False |
| shared | False |
| status | ACTIVE |
| subnets | b24490b9-a3dd-4103-895f-a28aaf2c9bff |
| tenant_id | 32f5512c7b3f47fb8924588ff9ad603b |
+---------------------------+--------------------------------------+
$ neutron router-show router1
+-------------------------+--------------------------------------+
| Field | Value |
+-------------------------+--------------------------------------+
| admin_state_up | True |
| availability_zone_hints | zone-1 |
| | zone-2 |
| availability_zones | zone-1 |
| | zone-2 |
| distributed | False |
| external_gateway_info | |
| ha | True |
| id | 272f9be2-e352-4138-92a7-f022449b83a0 |
| name | router1 |
| routes | |
| status | ACTIVE |
| tenant_id | 32f5512c7b3f47fb8924588ff9ad603b |
+-------------------------+--------------------------------------+
在调度资源之前,availability_zones属性没有值。 一旦网络服务根据availability_zone_hints将资源调度到区域,availability_zones显示资源在哪个区域实际托管。 availability_zone可能与availability_zone_hints不匹配。 例如,即使您指定了具有availability_zone_hints的区域,该区域的所有代理也可能在调度资源之前死亡。 一般来说,它们应该匹配,除非有故障或在请求的区域中没有剩余容量。
网络调度器(Network scheduler)
在文件/etc/neutron/neutron.conf中将AZLeastRoutersScheduler设置为router_scheduler_driver,以便网络服务根据可用区域计划路由器:
router_scheduler_driver = neutron.scheduler.l3_agent_scheduler.AZLeastRoutersScheduler
网络服务使用LeastRouterScheduler将路由器调度到所选区域内的其中一个代理。
通过可用区域实现高可用性
虽然,网络服务为路由器提供高可用性和高可用性和容错的网络的DHCP服务,可用区域通过分离在孤立的故障域中的网络服务部署提供额外的保护层。 通过在不同的可用区域中部署HA节点,可以保证网络服务在面临影响部署的区域范围故障时保持可用。
本节介绍如何通过L3和DHCP的可用区域获得高可用性。 您应该自然地设置可用区的以上配置选项。
L3高可用性
在文件/etc/neutron/neutron.conf中设置以下配置选项,以便获得L3高可用性。
l3_ha = True
max_l3_agents_per_router = 3
min_l3_agents_per_router = 2
HA路由器在创建路由器时选择的可用区域上创建。
DHCP高可用性
在文件/etc/neutron/neutron.conf中设置以下配置选项,以便获得DHCP高可用性。
dhcp_agents_per_network = 2
在创建网络时选择的可用区域上创建DHCP服务。