OpenStack-T版——Neutron网络服务理论+实验!

一、Neutron网络服务简介

1.Neutron网络在OpenStack中有什么作用?

  • 网络是openstack最重要的资源之一,没有网络,虚拟机将被隔离。Openstack的网络服务最主要的功能就是为虚拟机实例提供网络连接,最初由nova的一个单独模块nova-compute实现,但是nova-compute支持的网络服务有限(瓶颈问题),无法适应大规模、高密度和多项目的云计算,现已被专门的网络服务项目Neutron所取代。

  • Neutron为整个openstack环境提供软件定义网络支持,主要功能包括二层交换、三层路由、防火墙、VPN,以及负载均衡等。Neutron在由其他openstack服务(如 nova)管理的网络接口设备(如虚拟网卡)之间提供网络连接即服务。

2.Openstack网络基础服务

OpenStack网络服务提供一个API让用户在云中建立和定义网络连接。该网络服务的项目名称是Neutron。OpenStack网络负责创建和管理虚拟网络基础架构,包括网络、交换机、子网和路由器,这些设备由OpenStack计算服务Nova管理(nova-network组件管理ip转发,网桥或虚拟局域网的nova网络组件)。同时,网络服务还提供防火墙和VPN这样的高级服务。可以将网络服务部署到特定主机上。OpenStack网络组件与身份服务、计算服务和仪表板等多个OpenStack组件进行整合

解析:
集合:两者属于同一级别,相互进行调用,合作,共同完成一个需求
整合:该技术贯穿整个架构

2.1 Neutron网络结构

  • 1.一个简化的典型的Neutron网络结构,包括一个外部网络、一个内部网络和一个路由器。

  • 2.外部网络:负责连接OpenStack项目之外的网络环境,又称公共网络。与其他网络不同,它不仅仅是一个虚拟网络,更重要的是,它表示OpenStack网络能被外部物理网络接入并访问。外部网络可能是企业的局域网(Intranet),也可能是互联网(Internet),这类网络并不是由Neutron直接管理。
    解析:openstack公共网络用于和openstack外部的网络进行连接

  • 3.内部网络:完全由软件定义,又称私有网络。它是虚拟机实例所在的网络,能够直接连接到虚拟机。项目用户可以创建自己的内部网络。默认情况下,项目之间的内部网络是相互隔离的,不能共享。该网络由Neutron直接配置与管理。
    解析:
    a.内部网络用于连接,管理实例
    b.用户可自行配置内部网络
    c.不同内部网络之间默认是相互隔离的

  • 4.路由器:用于将内部网络与外部网络连接起来,因此,要使虚拟机访问外部网络,必须创建一个路由器。

  • 5.Neutron需要实现的主要是内部网络和路由器。内部网络是对二层(L2)网络的抽象,模拟物理网络的二层局域网,对于项目来说,它是私有的。路由器则是对三层(L3)网络的抽象,模拟物理路由器,为用户提供路由、NAT(映射)等服务。

2.2 网络子网与端口

  • 1.网路:一个隔离的二层广播域,类似交换机中的VLAN。Neutron支持多种类型的网络(openstack支持的网络模式),如FLAT、VLAN、VXLAN等。
    解析:什么是广播域的覆盖范围?
    假设10台设备,其中可以是主机,二层交换机,路由器,其中一台主机发送广播包,广播包能够覆盖,传递的范围就是答案

  • 2.子网:一个IPV4或者IPV6的地址段及其相关配置状态。虚拟机实例的IP地址从子网中分配。每个子网需要定义IP地址的范围和掩码(这个有点像DHCP中定义的作用域(地址池)的概念)。

  • 3.端口:连接设备的连接点,类似虚拟交换机上的一个网络端口。端口定义了MAC地址和IP地址,当虚拟机的虚拟网卡绑定到端口时,端口会将MAC和IP分配给该虚拟网卡。

  • 4.通常可以创建和配置网络、子网和端口来为项目搭建虚拟网络。网络必须属于某个项目,一个项目中可以创建多个网络。一个子网只能属于某个网络,一个网络可以有多个子网。一个端口必须属于某个子网,一个子网可以有多个端口。

2.3 网络拓扑类型

2.3.1 Local

  • local:对于生产环境的实际意义不大,主要用于测试环境。

  • Local网络与其他网络和节点隔离。该网络中的虚拟机实例只能与位于同一节点上同一网络的虚拟机实例通信,实际意义不大,主要用于测试环境。位于同一Local网络的实例之间可以通信,位于不同Local网络的示例之间无法通信。一个Local网络只能位于同一个物理节点上,无法跨节点部署。

2.3.3 VLAN

  • VLAN是支持802.1q协议的虚拟局域网,使用VLAN标签标记数据包,实现网络隔离。同一VLAN网络中的实例可以通信,不同VLAN网络中的实例只能通过路由器来通信。VLAN网络可以跨节点,是应用最广泛的网络拓扑类型之一。

  • VLAN功能:隔离。便于管理,节省ip地址,安全

2.3.4 VXLAN

  • VXLAN(虚拟扩展局域网)可以看作是VLAN的一种扩展,相比于VLAN,它有更大的扩展性和灵活性,是目前支持大规模多租房网络环境的解决方案。由于VLAN包头部限长是12位,导致VLAN的数量限制是4096(212)个,不能满足网络空间日益增长的需求。目前VXLAN的封包头部有24位用作VXLAN标识符(VNID)来区分VXLAN网段,最多可以支持16777216(224)个网段。

  • VXLAN使用STP(生成树协议)防止环路,导致一半的网络路径被阻断。VXLAN的数据包是封装到UDP通过三层传输和转发的,可以完整地利用三层路由,能克服VLAN和物理网络基础设施的限制,更好地利用已有的网络路径。

2.3.4.1 VLAN与VXLAN的区别?
  • 1.vxlan相比于vlan具有更强的扩展性和灵活性
  • 2.vxlan支持的网段远远多与vlan(2的24次方=16777216)
  • 3.vxlan是以2层数据(2的12次方=4096)封装在3层的形式(2的24次方=16777216)完成转发的
  • 4.由此Vxlan是一种“隧道技术”
2.3.4.2 VXLAN的优点
  • 1.网络资源消耗少
  • 2.安全
  • 3.便于管理
  • 4.大大减少数据传输时的复杂性

2.3.5 GRE

GRE(通用路由封装)是用一种网络层协议去封装另一种网络层协议的隧道技术。GRE的隧道由两端的源IP地址和目的IP地址定义,它允许用户使用IP封装IP等协议,并支持全部的路由协议。在OpenStack环境中使用GRE意味着“IP over IP”,GRE与VXLAN的主要区别在于,它是使用IP包而非UDP进行封装的。

2.3.5.4 简单概括GRE(通用路由封装)
  • 1.GRE也是一种网络隧道技术
  • 2.VXLAN是L2层数据(数据帧)封装L3层(数据包)的方式完成转发,而GRE是L3层数据封装L3层的方式完成转发

2.3.6 GENEVE

  • GENEVE(通用网络虚拟封装)的目标宣称是仅定义封装数据格式,尽可能实现数据格式的弹性和扩展性。GENEVE封装的包通过标准的网络设备传送,即通过单播或多播寻址,包从一个隧道端点传送到另一个或多个隧道端点。GENEVE帧格式由一个封装在IPV4或IPV6的UDP里的简化的隧道头部组成。GENEVE推出的主要目的是为了解决封装时添加的元数据信息问题(到底多少位,怎么用GENEVE自动识别与调整),以适应各种虚拟化场景。

2.4 小总结

  • 1.网络可以分为两层:一层是承载网络,一层是覆盖/叠加
  • 2.叠加网络特性:简化网络拓扑结构(交互),方便管理,降低拓扑复杂和网络消耗

二、neutron配置流程

1. 创建数据库neutron,并进行授权

● 创建数据库neutron

mysql -u root -p123456
MariaDB [(none)]> CREATE DATABASE neutron;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'localhost' IDENTIFIED BY 'NEUTRON_DBPASS';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'%' IDENTIFIED BY 'NEUTRON_DBPASS';
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> exit

● 创建neutron用户,用于在keystone做认证

[root@ct ~]# openstack user create --domain default --password NEUTRON_PASS neutron
+---------------------+----------------------------------+
| Field               | Value                            |
+---------------------+----------------------------------+
| domain_id           | default                          |
| enabled             | True                             |
| id                  | f9e1e410270243bcaafc967a55d19f91 |
| name                | neutron                          |
| options             | {
    
    }                               |
| password_expires_at | None                             |
+---------------------+----------------------------------+

● 将neutron用户添加到service项目中拥有管理员权限

[root@ct ~]# openstack role add --project service --user neutron admin

● 创建network服务,服务类型为network

[root@ct ~]# openstack service create --name neutron --description "OpenStack Networking" network 
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | OpenStack Networking             |
| enabled     | True                             |
| id          | c8839731dc564062958616d3f3f97297 |
| name        | neutron                          |
| type        | network                          |
+-------------+----------------------------------+

● 注册API到neutron服务,给neutron服务关联端口,即添加endpoint

[root@ct ~]# openstack endpoint create --region RegionOne network public http://ct:9696
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 273b37b1d7ad46a789090292a4f92b63 |
| interface    | public                           |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | c8839731dc564062958616d3f3f97297 |
| service_name | neutron                          |
| service_type | network                          |
| url          | http://ct:9696                   |
+--------------+----------------------------------+
[root@ct ~]# openstack endpoint create --region RegionOne network internal http://ct:9696
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | ad5d3f1eda814b778622cc68ebe1fb50 |
| interface    | internal                         |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | c8839731dc564062958616d3f3f97297 |
| service_name | neutron                          |
| service_type | network                          |
| url          | http://ct:9696                   |
+--------------+----------------------------------+
[root@ct ~]# openstack endpoint create --region RegionOne network admin http://ct:9696
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | d57d27917cf04b3c8982c6e421fd5ea7 |
| interface    | admin                            |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | c8839731dc564062958616d3f3f97297 |
| service_name | neutron                          |
| service_type | network                          |
| url          | http://ct:9696                   |
+--------------+----------------------------------+

2. 安装提供者网络(桥接)

● ebtables包是用来管理iptables规则的

[root@ct ~]# yum -y install openstack-neutron openstack-neutron-ml2 openstack-neutron-linuxbridge ebtables conntrack-tools

3. 更改主配置文件

[root@ct ~]# cp -a /etc/neutron/neutron.conf{
    
    ,.bak}
[root@ct ~]# grep -Ev '^$|#' /etc/neutron/neutron.conf.bak > /etc/neutron/neutron.conf

openstack-config --set /etc/neutron/neutron.conf database connection mysql+pymysql://neutron:NEUTRON_DBPASS@ct/neutron
openstack-config --set /etc/neutron/neutron.conf DEFAULT core_plugin ml2
openstack-config --set /etc/neutron/neutron.conf DEFAULT service_plugins router
openstack-config --set  /etc/neutron/neutron.conf DEFAULT allow_overlapping_ips true
openstack-config --set /etc/neutron/neutron.conf DEFAULT transport_url rabbit://openstack:RABBIT_PASS@ct
openstack-config --set /etc/neutron/neutron.conf DEFAULT auth_strategy keystone
openstack-config --set /etc/neutron/neutron.conf DEFAULT notify_nova_on_port_status_changes true
openstack-config --set /etc/neutron/neutron.conf DEFAULT notify_nova_on_port_data_changes true
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken www_authenticate_uri http://ct:5000
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken auth_url http://ct:5000
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken memcached_servers ct:11211
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken auth_type password
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken project_domain_name default
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken user_domain_name default
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken project_name service
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken username neutron
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken password NEUTRON_PASS
openstack-config --set /etc/neutron/neutron.conf oslo_concurrency lock_path /var/lib/neutron/tmp
openstack-config --set  /etc/neutron/neutron.conf nova  auth_url http://ct:5000
openstack-config --set  /etc/neutron/neutron.conf nova  auth_type password
openstack-config --set  /etc/neutron/neutron.conf nova  project_domain_name default
openstack-config --set  /etc/neutron/neutron.conf nova  user_domain_name default
openstack-config --set  /etc/neutron/neutron.conf nova  region_name RegionOne
openstack-config --set  /etc/neutron/neutron.conf nova  project_name service
openstack-config --set  /etc/neutron/neutron.conf nova  username nova
openstack-config --set  /etc/neutron/neutron.conf nova  password NOVA_PASS
  • 查看配置文件
[root@ct neutron]# cat neutron.conf
[DEFAULT]
core_plugin = ml2						#启用二层网络插件
service_plugins = router					#启用三层网络插件
allow_overlapping_ips = true
transport_url = rabbit://openstack:RABBIT_PASS@ct		#配置rabbitmq连接
auth_strategy = keystone					#认证的方式:keystone
notify_nova_on_port_status_changes = true			#当网络接口发生变化时,通知给计算节点	
notify_nova_on_port_data_changes = true			#当端口数据发生变化,通知计算节点
[cors]
[database]						#配置数据库连接
connection = mysql+pymysql://neutron:NEUTRON_DBPASS@ct/neutron
[keystone_authtoken]					#配置keystone认证信息
www_authenticate_uri = http://ct:5000
auth_url = http://ct:5000
memcached_servers = ct:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = neutron
password = NEUTRON_PASS
[oslo_concurrency]						#配置锁路径
lock_path = /var/lib/neutron/tmp
[oslo_messaging_amqp]
[oslo_messaging_kafka]
[oslo_messaging_notifications]
[oslo_messaging_rabbit]
[oslo_middleware]
[oslo_policy]
[privsep]
[ssl]
[nova]							#neutron需要给nova返回数据
auth_url = http://ct:5000					#到keystone认证nova
auth_type = password
project_domain_name = default
user_domain_name = default
region_name = RegionOne
project_name = service
username = nova						#通过nova的用户名和密码到keystone验证nova的token
password = NOVA_PASS

4. 修改 ML2 plugin 配置文件 ml2_conf.ini

[root@ct ~]# cp -a /etc/neutron/plugins/ml2/ml2_conf.ini{
    
    ,.bak}
[root@ct ~]# grep -Ev '^$|#' /etc/neutron/plugins/ml2/ml2_conf.ini.bak > /etc/neutron/plugins/ml2/ml2_conf.ini
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 type_drivers  flat,vlan,vxlan
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 tenant_network_types vxlan
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 mechanism_drivers  linuxbridge,l2population
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2 extension_drivers  port_security
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2_type_flat flat_networks  provider
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2_type_vxlan vni_ranges 1:1000
openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini securitygroup enable_ipset  true
  • 查看配置文件
[root@ct ~]# cat /etc/neutron/plugins/ml2/ml2_conf.ini
[DEFAULT]

[ml2]
type_drivers = flat,vlan,vxlan				#配置驱动类型;单一扁平网络(桥接)和vlan;让二层网络支持桥接,支持基于vlan做子网划分
tenant_network_types = vxlan				#租户网络类型(vxlan)
mechanism_drivers = linuxbridge,l2population		#启用Linuxbridge和l2机制,(l2population机制是为了简化网络通信拓扑,减少网络广播):
extension_drivers = port_security			#启用端口安全扩展驱动程序,基于iptables实现访问控制;但配置了扩展安全组会导致一些端口限制,造成一些服务无法启动 

[ml2_type_flat]
flat_networks = provider				#配置公共虚拟网络为flat网络

[ml2_type_vxlan]
vni_ranges = 1:1000				#为私有网络配置VXLAN网络识别的网络范围

[securitygroup]
enable_ipset = true					#启用 ipset 增加安全组的方便性

5. 修改 linux bridge network provider 配置文件

[root@ct ~]# cp -a /etc/neutron/plugins/ml2/linuxbridge_agent.ini{
    
    ,.bak}
[root@ct ~]# grep -Ev '^$|#' /etc/neutron/plugins/ml2/linuxbridge_agent.ini.bak > /etc/neutron/plugins/ml2/linuxbridge_agent.ini

openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini linux_bridge physical_interface_mappings  provider:eth1		###eth1网卡名称
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini vxlan enable_vxlan  true
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini vxlan local_ip 192.168.1.10 ##控制节点IP地址	
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini vxlan l2_population true
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini securitygroup enable_security_group  true
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini securitygroup firewall_driver  neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
  • 查看配置文件
[root@ct ~]# cat /etc/neutron/plugins/ml2/linuxbridge_agent.ini
[DEFAULT]


[linux_bridge]
physical_interface_mappings = provider:eth1


[vxlan]
enable_vxlan = true
local_ip = 192.168.1.10
l2_population = true


[securitygroup]
enable_security_group = true
firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver

6. 修改内核参数

[root@ct ~]#echo 'net.bridge.bridge-nf-call-iptables=1' >> /etc/sysctl.conf
[root@ct ~]#echo 'echnet.bridge.bridge-nf-call-ip6tables=1' >> /etc/sysctl.conf
[root@ct ~]#modprobe br_netfilter	#表示向内核加入参数
[root@ct ~]#sysctl -p

7. 配置Linuxbridge接口驱动和外部网络网桥

[root@ct ~]#cp -a /etc/neutron/l3_agent.ini{
    
    ,.bak}
[root@ct ~]#grep -Ev '^$|#' /etc/neutron/l3_agent.ini.bak > /etc/neutron/l3_agent.ini
[root@ct ~]#openstack-config --set /etc/neutron/l3_agent.ini DEFAULT interface_driver linuxbridge

[root@ct ~]#cat /etc/neutron/l3_agent.ini
[DEFAULT]
interface_driver = linuxbridge

8. 修改dhcp_agent 配置文件及内容

[root@ct ~]#cp -a /etc/neutron/dhcp_agent.ini{
    
    ,.bak}
[root@ct ~]# grep -Ev '^$|#' /etc/neutron/dhcp_agent.ini.bak > /etc/neutron/dhcp_agent.ini 
[root@ct ~]# openstack-config --set /etc/neutron/dhcp_agent.ini DEFAULT interface_driver linuxbridge
[root@ct ~]# openstack-config --set /etc/neutron/dhcp_agent.ini DEFAULT dhcp_driver neutron.agent.linux.dhcp.Dnsmasq
[root@ct ~]# openstack-config --set /etc/neutron/dhcp_agent.ini DEFAULT enable_isolated_metadata true

[root@ct ~]# cd /etc/neutron/
[root@ct neutron]# cat dhcp_agent.ini
[DEFAULT]
interface_driver = linuxbridge	#指定默认接口驱动为linux网桥
dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq	#指定DHCP驱动
enable_isolated_metadata = true			#开启iso元数据

9. 配置元数据代理、用于配置桥接与自服务网络的通用配置

[root@ct ~]# cp -a /etc/neutron/metadata_agent.ini{
    
    ,.bak}
[root@ct ~]# grep -Ev '^$|#' /etc/neutron/metadata_agent.ini.bak > /etc/neutron/metadata_agent.ini
[root@ct ~]# openstack-config --set /etc/neutron/metadata_agent.ini DEFAULT nova_metadata_host ct
[root@ct ~]# openstack-config --set /etc/neutron/metadata_agent.ini DEFAULT metadata_proxy_shared_secret METADATA_SECRET

# 配置文件内容
[root@ct neutron]# cat metadata_agent.ini
[DEFAULT]
nova_metadata_host = ct
metadata_proxy_shared_secret = METADATA_SECRET
[cache]

10. 修改nova配置文件,用于neutron交互

#修改CT配置文件

openstack-config --set /etc/nova/nova.conf neutron url http://ct:9696
openstack-config --set /etc/nova/nova.conf neutron auth_url http://ct:5000
openstack-config --set /etc/nova/nova.conf neutron auth_type password
openstack-config --set /etc/nova/nova.conf neutron project_domain_name default
openstack-config --set /etc/nova/nova.conf neutron user_domain_name default
openstack-config --set /etc/nova/nova.conf neutron region_name RegionOne
openstack-config --set /etc/nova/nova.conf neutron project_name service
openstack-config --set /etc/nova/nova.conf neutron username neutron
openstack-config --set /etc/nova/nova.conf neutron password NEUTRON_PASS
openstack-config --set /etc/nova/nova.conf neutron service_metadata_proxy true
openstack-config --set /etc/nova/nova.conf neutron metadata_proxy_shared_secret METADATA_SECRET

11. 创建ML2插件文件符号连接

● 网络服务初始化脚本需要/etc/neutron/plugin.ini指向ML2插件配置文件的符号链接

 ln -s /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.ini

● 初始化数据库

 su -s /bin/sh -c "neutron-db-manage --config-file /etc/neutron/neutron.conf \
--config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade head" neutron

● 重启计算节点nova-api服务

systemctl restart openstack-nova-api.service

● 开启neutron服务、设置开机自启动

[root@ct ~]# systemctl enable neutron-server.service \
neutron-linuxbridge-agent.service neutron-dhcp-agent.service \
neutron-metadata-agent.service
[root@ct ~]# systemctl start neutron-server.service \
neutron-linuxbridge-agent.service neutron-dhcp-agent.service \
neutron-metadata-agent.service
[root@ct ~]# netstat -anutp |grep 9696
tcp        0      0 0.0.0.0:9696            0.0.0.0:*               LISTEN      17028/server.log  

● 因为配置了第三层L3网络服务、所以需要启动第三层服务

[root@ct ~]# systemctl enable neutron-l3-agent.service
[root@ct ~]# systemctl restart neutron-l3-agent.service

12. c1 节点操作

[root@c1 ~]#yum -y install openstack-neutron-linuxbridge ebtables ipset conntrack-tools
#ipset:iptables的扩展,允许匹配规则的集合而不仅仅是一个IP

● 修改neutron.conf文件

[root@c1 ~]# cp -a /etc/neutron/neutron.conf{
    
    ,.bak}
[root@c1 ~]# grep -Ev '^$|#' /etc/neutron/neutron.conf.bak > /etc/neutron/neutron.conf

openstack-config --set /etc/neutron/neutron.conf DEFAULT transport_url rabbit://openstack:RABBIT_PASS@ct
openstack-config --set /etc/neutron/neutron.conf DEFAULT auth_strategy keystone
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken www_authenticate_uri http://ct:5000
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken auth_url http://ct:5000
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken memcached_servers ct:11211
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken auth_type password
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken project_domain_name default
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken user_domain_name default
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken project_name service
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken username neutron
openstack-config --set /etc/neutron/neutron.conf keystone_authtoken password NEUTRON_PASS
openstack-config --set /etc/neutron/neutron.conf oslo_concurrency lock_path /var/lib/neutron/tmp
  • 查看配置文件
[root@c1 ~]# cd /etc/neutron/
[root@c1 neutron]# cat neutron.conf

[DEFAULT]					#neutron的server端与agent端通讯也是通过rabbitmq进行通讯的
transport_url = rabbit://openstack:RABBIT_PASS@ct
auth_strategy = keystone				#认证策略:keystone
[cors]
[database]

[keystone_authtoken]				#指定keystone认证的信息
www_authenticate_uri = http://ct:5000
auth_url = http://ct:5000
memcached_servers = ct:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = neutron
password = NEUTRON_PASS

[oslo_concurrency]					#配置锁路径(管理线程库)
lock_path = /var/lib/neutron/tmp

[oslo_messaging_amqp]
[oslo_messaging_kafka]
[oslo_messaging_notifications]
[oslo_messaging_rabbit]
[oslo_middleware]
[oslo_policy]
[privsep]
[ssl]

● 配置Linux网桥代理

[root@c1 ~]# cp -a /etc/neutron/plugins/ml2/linuxbridge_agent.ini{
    
    ,.bak}
[root@c1 ~]# grep -Ev '^$|#' /etc/neutron/plugins/ml2/linuxbridge_agent.ini.bak > /etc/neutron/plugins/ml2/linuxbridge_agent.ini

openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini linux_bridge physical_interface_mappings  provider:eth1
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini vxlan enable_vxlan  true
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini vxlan local_ip 192.168.1.20
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini vxlan l2_population true
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini securitygroup enable_security_group  true
openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini securitygroup firewall_driver  neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
  • 查看配置文件
[root@c1 ~]# cat /etc/neutron/plugins/ml2/linuxbridge_agent.ini
[DEFAULT]
[linux_bridge]
physical_interface_mappings = provider:eth1
# 直接将node节点external网络绑定在当前节点的指定的物理网卡,不需要node节点配置网络名称,node节点只需要接收controller节点指令即可;controller节点上配置的external网络名称是针对整个openstack环境生效的,所以指定external网络绑定在当前node节点的eth0物理网卡上(也可能是bind0或br0)

[vxlan]
enable_vxlan = true							#开启Vxlan网络
local_ip = 192.168.1.20
l2_population = true						#L2 Population 是用来提高 VXLAN 网络扩展能力的组件

[securitygroup]
enable_security_group = true						#开启安全组
firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver	#指定安全组驱动文件


● 修改内核
echo 'net.bridge.bridge-nf-call-iptables=1' >> /etc/sysctl.conf		#允许虚拟机的数据通过物理机出去
echo 'net.bridge.bridge-nf-call-ip6tables=1' >> /etc/sysctl.conf
modprobe br_netfilte #modprobe:用于向内核中加载模块或者从内核中移除模块modprobe -r 表示移除
sysctl -p

● 修改nova.conf配置文件

openstack-config --set /etc/nova/nova.conf neutron auth_url http://ct:5000
openstack-config --set /etc/nova/nova.conf neutron auth_type password
openstack-config --set /etc/nova/nova.conf neutron project_domain_name default
openstack-config --set /etc/nova/nova.conf neutron user_domain_name default
openstack-config --set /etc/nova/nova.conf neutron region_name RegionOne
openstack-config --set /etc/nova/nova.conf neutron project_name service
openstack-config --set /etc/nova/nova.conf neutron username neutron
openstack-config --set /etc/nova/nova.conf neutron password NEUTRON_PASS
  • 以下为修改字段内容
[neutron]
auth_url = http://ct:5000
auth_type = password
project_domain_name = default
user_domain_name = default
region_name = RegionOne
project_name = service
username = neutron
password = NEUTRON_PASS

C2节点部署neutron服务(与C1节点相同)

● 验证服务组件【ct节点】

[root@ct ~]# openstack network agent list
+--------------------------------------+--------------------+------+-------------------+-------+-------+---------------------------+
| ID                                   | Agent Type         | Host | Availability Zone | Alive | State | Binary                    |
+--------------------------------------+--------------------+------+-------------------+-------+-------+---------------------------+
| 12e4313d-bd10-4568-a13d-985153a0f103 | DHCP agent         | ct   | nova              | :-)   | UP    | neutron-dhcp-agent        |
| 17a60c80-8657-4052-9ac7-39f5bf45efb5 | L3 agent           | ct   | nova              | :-)   | UP    | neutron-l3-agent          |
| ba668a3c-46a8-4d68-bf59-8258ea857ba2 | Linux bridge agent | ct   | None              | :-)   | UP    | neutron-linuxbridge-agent |
| cdab78b1-23be-4a32-95ea-80939cd56a2d | Metadata agent     | ct   | None              | :-)   | UP    | neutron-metadata-agent    |
+--------------------------------------+--------------------+------+-------------------+-------+-------+---------------------------+

13.总结

三个节点都需要配置neutron网络,以下为部署思路:

  • 配置neutron组件的用户、认证、endpoint
  • 设置提供者provider网络(这里是桥接模式)
    ① 配置二层网络
    ② 配置网桥(插件)
    ③ 优化内核
    ④ 配置网桥接口与外部对接
    ⑤ 修改DHCP配置(修改配置文件、代理)
    ⑥ 配置网桥与内部组件的配置(修改配置文件、代理)
    设置neutron与nova对接的配置
    其中C1、C2节点配置相同

猜你喜欢

转载自blog.csdn.net/F2001523/article/details/114370262