OpenStack网络服务提供了一个API接口,允许用户在云上设置和定义网络连接和地址。这个网络服务的项目代码名称是Neutron。OpenStack网络处理虚拟设备的创建和管理网络基础设施,包括网络、交换机、子网以及由计算服务(nova)管理的设备路由器。高级服务,如防火墙或虚拟私人网络(VPN)也可以使用。
OpenStack网络由neutron-server,持久化存储数据库,和任意数量的插件代理组成,这些代理提供其他服务,如与本地linux联网接口机制、外部设备或SDN控制器。
OpenStack网络是完全独立的,可以部署到一个专用主机。如果你的部署使用了一个控制器主机运行集中计算组件,你可以部署网络服务来取代主机的设定。
OpenStack网络集成了各种组件:
neutron-server可以理解为类似于nova-api那样的一个组件,一个专门用来接收neutron REST API调用的服务器。负责将不同的rest api发送到不同的neutron-plugin
neutron-plugin可以理解为不同网络功能实现的入口,现在大部分都是软件定义网络,各个厂商都开发自己的plugin(插件)。neutron-plugin接收netron-server发过来的rest api,向neutron database完成一些信息注册(比如用户要建端口)。然后将具体要执行的业务操作和参数通知给自身对应的neutron-agent
neutron-agent可以直观的理解为neutron-plugin在设备上的代理,接受相应的neutron-plugin通知的业务操作和参数,并转换为具体的设备级操作,以指导设备的动作。当本地设备发生问题时,neutron-agent会将情况通知给neutron-plugin(说白了就是neutron-server就是与各个组件交互的,接收请求,neutron-plugin是操作数据库的,neutron-agent就是具体干活的)
neutron database就是数据库,一些业务相关的参数都存在这里
Neutron分别提供了二层(L2)vSwitch交换和三层(L3)Router路由抽象的功能,对应于物理网络环境中的交换机和路由器实现。具体实现了如下功能:
注意:学习openstack重中之重network的类型包括:Flat,Vlan,Vxlan,GRE,还有一个local 五种网络模式指的是二层网络
flat network:基于不实用vlan的物理网络实现的虚拟网络。所有网络都在一个网络中。不推荐使用,用不到生产环境中。 local network:一个只允许在本服务器内通信的虚拟网络,所有服务都装在一台机器上 不推荐中。 vlan network:基于物理vlan网络实现的虚拟网络。共享同一个物理网络的多个vlan网络是相互隔离的,并且可以使用重叠IP地址空间。最重要的一点是有效的VLAN ID 范围为1-4095 GRE network:(通过路由封装网络):一个使用GRE封装网络包的虚拟网络,GRE封装的数据包基于IP路由表来进行路由,因此GRE network不和具体的网络网络绑定 VXLAN network:(虚拟可扩展网络)基于vxlan实现虚拟网络。同GRE network一样,vxlan network中IP包的路由也基于IP路由表,也不和具体的物理网络绑定
CREATE DATABASE neutron;
GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'localhost' \
IDENTIFIED BY '123456';
GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'%' \
IDENTIFIED BY '123456';
openstack user create --domain default --password neutron neutron
openstack role add --project service --user neutron admin
openstack service create --name neutron \
--description "OpenStack Networking" network
openstack endpoint create --region RegionOne \
network public http://master01.boysec.cn:9696
openstack endpoint create --region RegionOne \
network internal http://master01.boysec.cn:9696
openstack endpoint create --region RegionOne \
network admin http://master01.boysec.cn:9696
yum install openstack-neutron openstack-neutron-ml2 openstack-neutron-linuxbridge ebtables -y
cp /etc/neutron/neutron.conf{,.bak}
egrep -v "^$|#" /etc/neutron/neutron.conf.bak >/etc/neutron/neutron.conf
[root@master01.boysec.cn ~]# cat /etc/neutron/neutron.conf
[DEFAULT]
core_plugin = ml2
service_plugins =
transport_url = rabbit://openstack:openstack@master01.boysec.cn
auth_strategy = keystone
notify_nova_on_port_status_changes = true
notify_nova_on_port_data_changes = true
[cors]
[database]
connection = mysql+pymysql://neutron:123456@master01.boysec.cn/neutron
[keystone_authtoken]
www_authenticate_uri = http://master01.boysec.cn:5000
auth_url = http://master01.boysec.cn:5000
memcached_servers = master01.boysec.cn:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = neutron
password = neutron
[nova]
auth_url = http://master01.boysec.cn:5000
auth_type = password
project_domain_name = default
user_domain_name = default
region_name = RegionOne
project_name = service
username = nova
password = nova
[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]
# 编辑ml2配置
cp /etc/neutron/plugins/ml2/ml2_conf.ini{,.bak}
egrep -v "^$|#" /etc/neutron/plugins/ml2/ml2_conf.ini.bak> /etc/neutron/plugins/ml2/ml2_conf.ini
cat /etc/neutron/plugins/ml2/ml2_conf.ini
[DEFAULT]
[ml2]
type_drivers = flat,vlan
tenant_network_types =
mechanism_drivers = linuxbridge
extension_drivers = port_security
[ml2_type_flat]
flat_networks = provider
[securitygroup]
enable_ipset = true
# 编辑linuxbridge_agent配置
cp /etc/neutron/plugins/ml2/linuxbridge_agent.ini{,.bak}
egrep -v "^$|#" /etc/neutron/plugins/ml2/linuxbridge_agent.ini.bak >/etc/neutron/plugins/ml2/linuxbridge_agent.ini
cat /etc/neutron/plugins/ml2/linuxbridge_agent.ini
[linux_bridge]
physical_interface_mappings = provider:eth0
# 编辑dhcp_agent配置
vim /etc/neutron/dhcp_agent.ini
[DEFAULT]
# ...
interface_driver = linuxbridge
dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq
enable_isolated_metadata = true
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
systemctl restart openstack-nova-api.service
systemctl enable neutron-server.service \
neutron-linuxbridge-agent.service neutron-dhcp-agent.service \
neutron-metadata-agent.service
systemctl start neutron-server.service \
neutron-linuxbridge-agent.service neutron-dhcp-agent.service \
neutron-metadata-agent.service
yum install openstack-neutron openstack-neutron-ml2 \
openstack-neutron-linuxbridge ebtables -y
[root@node01 ~]# cp /etc/neutron/neutron.conf{,.bak}
[root@node01 ~]# egrep -v "^$|#" /etc/neutron/neutron.conf.bak >/etc/neutron/neutron.conf
[root@node01 ~]# vim /etc/neutron/neutron.conf
[root@node01 ~]# cat /etc/neutron/neutron.conf
[DEFAULT]
transport_url = rabbit://openstack:openstack@master01.boysec.cn
auth_strategy = keystone
[cors]
[database]
[keystone_authtoken]
www_authenticate_uri = http://master01.boysec.cn:5000
auth_url = http://master01.boysec.cn:5000
memcached_servers = master01.boysec.cn:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = neutron
password = neutron
[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]
[root@node01 ~]# scp master01.boysec.cn:/etc/neutron/plugins/ml2/linuxbridge_agent.ini /etc/neutron/plugins/ml2/linuxbridge_agent.ini
[root@node01 ~]# cat /etc/neutron/plugins/ml2/linuxbridge_agent.ini
[DEFAULT]
[linux_bridge]
physical_interface_mappings = provider:eth0
[vxlan]
enable_vxlan = false
[securitygroup]
enable_security_group = true
firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
systemctl restart openstack-nova-compute.service
systemctl enable neutron-linuxbridge-agent.service
systemctl start neutron-linuxbridge-agent.service
[root@master01 ~]# openstack network agent list
+--------------------------------------+--------------------+--------------------+-------------------+-------+-------+---------------------------+
| ID | Agent Type | Host | Availability Zone | Alive | State | Binary |
+--------------------------------------+--------------------+--------------------+-------------------+-------+-------+---------------------------+
| 614d6a20-cfec-43e5-825d-89f60da8c401 | Metadata agent | master01.boysec.cn | None | :-) | UP | neutron-metadata-agent |
| 9300f5c5-1f59-46bc-89e0-88222e9ccd16 | DHCP agent | master01.boysec.cn | nova | :-) | UP | neutron-dhcp-agent |
| afafc9b0-566e-48ac-be6a-e54510229770 | Linux bridge agent | master01.boysec.cn | None | :-) | UP | neutron-linuxbridge-agent |
| c6cc8d26-7b2b-46d6-96e8-56cb46689cf1 | Linux bridge agent | node01.boysec.cn | None | :-) | UP | neutron-linuxbridge-agent |
+--------------------------------------+--------------------+--------------------+-------------------+-------+-------+---------------------------+