OpenStack Queens三节点从零部署-配置网络(VXLAN_OpenvSwitch)

最后修改时间:2018年7月3日

文档版本:1.0

本操作分别在三个节点上完成

一. 配置控制节点

root@controller:~(keystone)# vim /etc/neutron/plugins/ml2/ml2_conf.ini
 
# 第130行:添加网络类型
tenant_network_types = vxlan
 
# 第181行:添加
flat_networks = physnet1
 
# 第235行:添加
vni_ranges = 1:1000
 
root@controller:~(keystone)# systemctl restart neutron-server

二. 配置网络节点

# 添加一个ovs桥
root@network:~# ovs-vsctl add-br br-ens3
# 把网卡添加到桥端口上
root@network:~# ovs-vsctl add-port br-ens3 ens3
root@network:~# vim /etc/neutron/plugins/ml2/ml2_conf.ini
 
# 第130行:添加网络类型
tenant_network_types = vxlan
 
# 第181行:添加
flat_networks = physnet1
 
# 第235行:添加
vni_ranges = 1:1000
 
root@network:~# vim /etc/neutron/plugins/ml2/openvswitch_agent.ini
 
# 第118行:添加
[agent]
tunnel_types = vxlan
l2_population = True
prevent_arp_spoofing = True
 
# 第196行:添加
[ovs]
local_ip = 172.16.0.20
bridge_mappings = physnet1:br-ens3
 
root@network:~# for service in dhcp-agent l3-agent metadata-agent openvswitch-agent; do
systemctl restart neutron-$service
done

三. 配置计算节点

root@compute:~# vim /etc/neutron/plugins/ml2/ml2_conf.ini
 
# 第130行:添加网络类型
tenant_network_types = vxlan
 
# 第181行:添加
flat_networks = physnet1
 
# 第235行:添加
vni_ranges = 1:1000
 
root@network:~# vim /etc/neutron/plugins/ml2/openvswitch_agent.ini
 
# 第118行:添加
[agent]
tunnel_types = vxlan
l2_population = True
prevent_arp_spoofing = True
 
# 第196行:添加
[ovs]
local_ip = 172.16.0.30
 
root@compute# systemctl restart neutron-openvswitch-agent

四. 开启DVR(选做)

以下操作分别在三个节点上完成

[1] 修改控制节点配置文件

# 在[DEFAULT]中添加
root@controller:~(keystone)# vim /etc/neutron/neutron.conf
 
[DEFAULT]
router_distributed = True
 
# 重启相关服务
root@controller:~(keystone)# systemctl restart neutron-server

[2] 修改网络节点配置文件

root@network:~# vim /etc/neutron/plugins/ml2/openvswitch_agent.ini
 
# 第156行:取消注释并修改
enable_distributed_routing = True
 
root@network:~# vim /etc/neutron/l3_agent.ini
 
# 第40行:取消注释并修改
agent_mode = dvr_snat
 
# 重启相关服务
root@network:~# systemctl restart openvswitch-switch neutron-openvswitch-agent neutron-l3-agent neutron-dhcp-agent neutron-metadata-agent

[3] 在计算节点上安装软件包并修改配置文件

root@compute:~# apt install -y neutron-l3-agent
 
# 添加一个ovs桥
root@compute:~# ovs-vsctl add-br br-ens3
# 把网卡添加到桥端口上
root@compute:~# ovs-vsctl add-port br-ens3 ens3
 
root@compute:~# vim /etc/neutron/plugins/ml2/openvswitch_agent.ini
 
# 第156行:取消注释并修改
enable_distributed_routing = True
 
# 第196行:添加
[ovs]
bridge_mappings = physnet1:br-ens3
 
root@compute:~# vim /etc/neutron/l3_agent.ini
 
# 第17行:取消注释并修改
interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver
 
# 第100行:取消注释并修改
external_network_bridge =
 
# 第40行:取消注释并修改
agent_mode = dvr
 
# 重启相关服务
root@network:~# systemctl restart openvswitch-switch neutron-openvswitch-agent neutron-l3-agent neutron-metadata-agent

五. 创建网络及路由(控制节点上完成)

[1] 创建虚拟路由

root@controller:~(keystone)# openstack router create router_01
+-------------------------+--------------------------------------+
| Field                   | Value                                |
+-------------------------+--------------------------------------+
| admin_state_up          | UP                                   |
| availability_zone_hints |                                      |
| availability_zones      |                                      |
| created_at              | 2018-07-01T09:23:14Z                 |
| description             |                                      |
| distributed             | False                                |
| external_gateway_info   | None                                 |
| flavor_id               | None                                 |
| ha                      | False                                |
| id                      | c3ls8351-1952-3s85-2f95-02335s8j30s1 |
| name                    | router_01                            |
| project_id              | 29j348sj583h6i1j238zk20so1jf91j2     |
| revision_number         | 0                                    |
| routes                  |                                      |
| status                  | ACTIVE                               |
| tags                    |                                      |
| updated_at              | 2018-07-01T09:23:14Z                 |
+-------------------------+--------------------------------------+

[2] 创建外部网络

root@controller:~(keystone)# openstack network create \
--provider-physical-network physnet1 \
--provider-network-type flat --external ext_net
+---------------------------+--------------------------------------+
| Field                     | Value                                |
+---------------------------+--------------------------------------+
| admin_state_up            | UP                                   |
| availability_zone_hints   |                                      |
| availability_zones        |                                      |
| created_at                | 2018-07-01T09:24:12Z                 |
| description               |                                      |
| dns_domain                | None                                 |
| id                        | 25j29sj3-sd21-9s1a-1d02-2296038k28sj |
| ipv4_address_scope        | None                                 |
| ipv6_address_scope        | None                                 |
| is_default                | False                                |
| is_vlan_transparent       | None                                 |
| mtu                       | 1500                                 |
| name                      | ext_net                              |
| port_security_enabled     | True                                 |
| project_id                | 29j348sj583h6i1j238zk20so1jf91j2     |
| provider:network_type     | flat                                 |
| provider:physical_network | physnet1                             |
| provider:segmentation_id  | None                                 |
| qos_policy_id             | None                                 |
| revision_number           | 5                                    |
| router:external           | External                             |
| segments                  | None                                 |
| shared                    | False                                |
| status                    | ACTIVE                               |
| subnets                   |                                      |
| tags                      |                                      |
| updated_at                | 2018-07-01T09:24:12Z                 |
+---------------------------+--------------------------------------+
 
# 创建外部网络的子网
root@controller:~(keystone)# openstack subnet create subnet_01 \
--network ext_net --subnet-range 10.0.0.0/24 \
--allocation-pool start=10.0.0.50,end=10.0.0.100 \
--gateway 10.0.0.1 --dns-nameserver 10.0.0.1 --no-dhcp
+-------------------+--------------------------------------+
| Field             | Value                                |
+-------------------+--------------------------------------+
| allocation_pools  | 10.0.0.50-10.0.0.100                 |
| cidr              | 10.0.0.0/24                          |
| created_at        | 2018-07-01T09:24:49Z                 |
| description       |                                      |
| dns_nameservers   | 10.0.0.1                             |
| enable_dhcp       | False                                |
| gateway_ip        | 10.0.0.1                             |
| host_routes       |                                      |
| id                | 239n75s8-2bx8-1953-1k9s-3js9gz55q934 |
| ip_version        | 4                                    |
| ipv6_address_mode | None                                 |
| ipv6_ra_mode      | None                                 |
| name              | subnet2                              |
| network_id        | 25j29sj3-sd21-9s1a-1d02-2296038k28sj |
| project_id        | 29j348sj583h6i1j238zk20so1jf91j2     |
| revision_number   | 0                                    |
| segment_id        | None                                 |
| service_types     |                                      |
| subnetpool_id     | None                                 |
| tags              |                                      |
| updated_at        | 2018-07-01T09:24:49Z                 |
+-------------------+--------------------------------------+
 
# 连接外部网络到路由
root@controller:~(keystone)# openstack router set router_01 --external-gateway ext_net

[3] 创建内部网络

root@controller:~(keystone)# openstack network create int_net --provider-network-type vxlan
+---------------------------+--------------------------------------+
| Field                     | Value                                |
+---------------------------+--------------------------------------+
| admin_state_up            | UP                                   |
| availability_zone_hints   |                                      |
| availability_zones        |                                      |
| created_at                | 2018-07-01T09:24:58Z                 |
| description               |                                      |
| dns_domain                | None                                 |
| id                        | 3396hn93-ak63-jj92-1l30-2394jsu2o49s |
| ipv4_address_scope        | None                                 |
| ipv6_address_scope        | None                                 |
| is_default                | False                                |
| is_vlan_transparent       | None                                 |
| mtu                       | 1450                                 |
| name                      | int_net                              |
| port_security_enabled     | True                                 |
| project_id                | 29j348sj583h6i1j238zk20so1jf91j2     |
| provider:network_type     | vxlan                                |
| provider:physical_network | None                                 |
| provider:segmentation_id  | 60                                   |
| qos_policy_id             | None                                 |
| revision_number           | 2                                    |
| router:external           | Internal                             |
| segments                  | None                                 |
| shared                    | False                                |
| status                    | ACTIVE                               |
| subnets                   |                                      |
| tags                      |                                      |
| updated_at                | 2018-07-01T09:24:58Z                 |
+---------------------------+--------------------------------------+
 
# 创建内部网络的子网
root@controller:~(keystone)# openstack subnet create subnet_02 --network int_net \
--subnet-range 192.168.100.0/24 --gateway 192.168.100.1 \
--dns-nameserver 10.0.0.1
 
# 连接内部网络到路由
root@controller:~(keystone)# openstack router add subnet router_01 subnet_02
Leave a Reply