![](/style/images/good.png)
![](/style/images/bad.png)
OpenStack实战七——Neutron网络服务部署
source link: https://chegva.com/2072.html
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
OpenStack实战七——Neutron网络服务部署
1. Neutron服务介绍
OpenStack Networking Service (Neutron) 是 OpenStack 核心项目之一,提供云计算环境下的虚拟网络功能。Neutron组件的各个服务进程也是以数据库和队列为中心进行通信的,它的相关运行进程与数据库和消息队列都有交互,并且对外接受其它OpenStack组件进程的访问和调用。
Neutron 网络目的是(为OpenStack云更灵活地)划分物理网络,在多租户环境下提供给每个租户独立的网络环境。另外,Neutron 提供 API 来实现这种目标。
Neutron中“网络”是一个可以被用户创建的对象,如果要和物理环境下的概念映射的话,这个对象相当于一个巨大的交换机,可以拥有无限多个动态可创建和销毁的虚拟端口。在物理网络环境中,端口是用于连接设备进入网络的地方。
Neutron 中的端口起着类似的功能,它是路由器和虚拟机挂接网络的着附点。 路由器 和物理环境下的路由器类似,Neutron 中的路由器也是一个路由选择和转发部件。只不过在 Neutron 中,它是可以创建和销毁的软部件。
2. Neutron组件介绍
Neutron 作为 OpenStack 的一个独立组件,既可以独立部署在单独的主机上,也能与其它组件组合部署在同一主机上。但大多数情况下,Neutron 组件在 OpenStack 架构中常以单独的 host 形式提供网络服务,作为网络节点,Neutron 提供多种服务,包括:
2.1 Neutron-server 服务
neutron-server 是一个守护进程,用来提供外部调用的 API 和与其它组件交互的接口。
从下面的 Neutron 软件架构图中可看出 Neutron 的交互连接,其中包括 horizon 组件,nova-compute 服务和 keystone 认证服务。因此 Neutron 不可避免的要与消息队列系统和数据库 neutron database 交互。
2.2 Neutron agent 服务:
Plug-in Agent(neutron-*-agent) 插件代理,需要部署在每一个运行 hypervisor 的主机上,它提供本地的 vSwitch 配置,更多的时候得依赖你具体所使用的插件类型。 常用的插件是
ML2 plugin
、OpenvSwitch
、Linux Bridge,还包括 Big Switch,Floodinght REST Proxy,Brocade,NSX,PLUMgrid,Ryu 等。DHCP-Agent
(neutron-dhcp-agent) DHCP 代理,给租户网络提供动态主机配置服务,主要用途是为租户网络内的虚拟机动态地分配 IP 地址。L3 Agent
(neutron-l3-agent) L3 代理,提供三层网络功能和网络地址转换(NAT)功能,来让租户的虚拟机可以与外部网络通信。LBAAS-Agent
负载均衡即服务,提供负载均衡服务。Metering Agent
(neutron-metering-agent) 计量代理,为租户网络提供三层网络流量数据计量服务。一般在私有云中不会使用到。 Neutron服务架构图
3. Neutron控制节点部署
3.1 配置Neutron公共网络
1.在控制节点上安装并配置网络组件
[root@linux-node1 ~]# yum install -y openstack-neutron openstack-neutron-ml2 openstack-neutron-linuxbridge ebtables
2.编辑
/etc/neutron/neutron.conf
文件并完成如下操作#1.在 [database] 部分,配置数据库访问(无需同步数据库)
[database]
...
connection = mysql+pymysql://neutron:[email protected]/neutron
#2.在 [DEFAULT] 和[keystone_authtoken] 部分,配置认证服务访问
[DEFAULT]
...
auth_strategy = keystone
[keystone_authtoken]
...
auth_uri = http://192.168.56.11:5000
auth_url = http://192.168.56.11:35357
memcached_servers = 192.168.56.11:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = neutron
password = neutron
#3.在 [DEFAULT] 和 [oslo_messaging_rabbit] 部分,配置 RabbitMQ 消息队列的连接
[DEFAULT]
...
rpc_backend = rabbit
[oslo_messaging_rabbit]
...
rabbit_host = 192.168.56.11
rabbit_userid = openstack
rabbit_password = openstack
#4.在 [DEFAULT] 部分,启用ML2插件并禁用其他插件
[DEFAULT]
...
core_plugin = ml2
service_plugins = #打开注释表示禁用其他插件
#5.在 [DEFAULT] 和 [nova] 部分,配置网络服务来通知计算节点的网络拓扑变化
[DEFAULT]
...
notify_nova_on_port_status_changes = True
notify_nova_on_port_data_changes = True
[nova]
...
auth_url = http://192.168.56.11:35357
auth_type = password
project_domain_name = default
user_domain_name = default
region_name = RegionOne
project_name = service
username = nova
password = nova
#6.在 [oslo_concurrency] 部分,配置锁路径
[oslo_concurrency]
...
lock_path = /var/lib/neutron/tmp3.查看/etc/neutron/neutron.conf配置
[root@linux-node1 ~]# grep "^[a-z]" /etc/neutron/neutron.conf
auth_strategy = keystone
core_plugin = ml2
service_plugins =
notify_nova_on_port_status_changes = true
notify_nova_on_port_data_changes = true
rpc_backend = rabbit
connection = mysql+pymysql://neutron:[email protected]/neutron
auth_uri = http://192.168.56.11:5000
auth_url = http://192.168.56.11:35357
memcached_servers = 192.168.56.11:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = neutron
password = neutron
auth_url = http://192.168.56.11:35357
auth_type = password
project_domain_name = default
user_domain_name = default
region_name = RegionOne
project_name = service
username = nova
password = nova
lock_path = $state_path/lock
rabbit_host = 192.168.56.11
rabbit_userid = openstack
rabbit_password = openstack
3.2 配置 Modular Layer 2 (ML2) 插件
ML2插件使用Linuxbridge机制来为实例创建layer-2虚拟网络基础设施
1.编辑
/etc/neutron/plugins/ml2/ml2_conf.ini
文件并完成以下操作#1.在 [ml2] 部分,启用flat和VLAN网络
[ml2]
...
type_drivers = flat,vlan,gre,vxlan,geneve
#2.在 [ml2] 部分,启用Linuxbridge机制来创建网络,列表类型可以写多个
[ml2]
...
mechanism_drivers = linuxbridge,openvswitch
#3.在 [ml2] 部分,设置租户网络类型,禁用私有网络
[ml2]
...
tenant_network_types =
#4.在 [ml2] 部分,启用端口安全扩展驱动
[ml2]
...
extension_drivers = port_security
#5.在 [ml2_type_flat] 部分,配置公共虚拟网络为flat网络
[ml2_type_flat]
...
flat_networks = public
#6.在 [securitygroup] 部分,启用 ipset 增加安全组规则的高效性
[securitygroup]
...
enable_ipset = True2.查看ml2插件配置
[root@linux-node1 ~]# grep "^[a-z]" /etc/neutron/plugins/ml2/ml2_conf.ini
type_drivers = flat,vlan,gre,vxlan,geneve
tenant_network_types =
mechanism_drivers = linuxbridge,openvswitch
extension_drivers = port_security
flat_networks = public
enable_ipset = true
3.3 配置Linuxbridge代理
Linuxbridge代理为实例建立layer-2虚拟网络并且处理安全组规则。
1.编辑
/etc/neutron/plugins/ml2/linuxbridge_agent.ini
文件并且完成以下操作#1.在``[linux_bridge]``部分,将公共虚拟网络和公共物理网络接口对应起来:
[linux_bridge]
physical_interface_mappings = public:eth0
将 PUBLIC_INTERFACE_NAME 替换为底层的物理公共网络接口。请查看:ref:environment-networking for more information。
#2.在 [vxlan] 部分,禁止VXLAN覆盖网络:
[vxlan]
enable_vxlan = False
#3.在 [securitygroup] 部分,启用安全组并配置 Linuxbridge iptables firewall driver
[securitygroup]
...
enable_security_group = True
firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver2.查看Linuxbridge配置
[root@linux-node1 ~]# grep "^[a-z]" /etc/neutron/plugins/ml2/linuxbridge_agent.ini
physical_interface_mappings = public:eth0 #将ml2中创建的public网络映射到eth0
firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
enable_security_group = true
enable_vxlan = false
3.4 配置DHCP代理
The DHCP agent provides DHCP services for virtual networks.
1.编辑
/etc/neutron/dhcp_agent.ini
文件并完成下面的操作:3在 [DEFAULT] 部分,配置Linuxbridge驱动接口,DHCP驱动并启用隔离元数据,这样在公共网络上的实例就可以通过网络来访问元数据
[DEFAULT]
...
#使用linuxbridge作为linux接口驱动
interface_driver = neutron.agent.linux.interface.BridgeInterfaceDriver
dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq #使用dnsmasq管理dhcp和dns
enable_isolated_metadata = True #刷新路由2.查看DHCP配置
[root@linux-node1 ~]# grep '^[a-z]' /etc/neutron/dhcp_agent.ini
interface_driver = neutron.agent.linux.interface.BridgeInterfaceDriver
dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq
enable_isolated_metadata = true
3.5 配置元数据代理
The term:metadata agent <Metadata agent>
负责提供配置信息,例如:访问实例的凭证
1.编辑
/etc/neutron/metadata_agent.ini
文件并完成以下操作:在 [DEFAULT] 部分,配置元数据主机以及共享密码:
[DEFAULT]
...
nova_metadata_ip = 192.168.56.11
metadata_proxy_shared_secret = anzhihe #共享密钥就是个字符串
#用你为元数据代理设置的密码替换 METADATA_SECRET。2.查看元数据代理配置
[root@linux-node1 ~]# grep '^[a-z]' /etc/neutron/metadata_agent.ini
nova_metadata_ip = 192.168.56.11
metadata_proxy_shared_secret = anzhihe
4. Nova-api配置网络服务
4.1 编辑/etc/nova/nova.conf
文件并完成以下操作
在
[neutron]
部分,配置访问参数,启用元数据代理并设置密码[neutron]
url = http://192.168.56.11:9696 #9696为neutron端口
auth_url = http://192.168.56.11:35357
auth_type = password
project_domain_name = default
user_domain_name = default
region_name = RegionOne
project_name = service
username = neutron
password = neutron
service_metadata_proxy = true
metadata_proxy_shared_secret = anzhihe
5. 完成安装
网络服务初始化脚本需要一个超链接 /etc/neutron/plugin.ini
指向ML2插件配置文件/etc/neutron/plugins/ml2/ml2_conf.ini
。如果超链接不存在,使用下面的命令创建它:
5.1 创建软链接
[root@linux-node1 ~]# ln -s /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.ini
5.2 同步数据库:
[root@linux-node1 ~]# 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
注意:数据库的同步发生在 Networking 之后,因为脚本需要完成服务器和插件的配置文件。
5.3 重启计算API 服务:
[root@linux-node1 ~]# systemctl restart openstack-nova-api.service
5.4 当系统启动时,启动 Networking 服务并配置它启动。
#开机启动
[root@linux-node1 ~]# systemctl enable neutron-server.service neutron-linuxbridge-agent.service neutron-dhcp-agent.service neutron-metadata-agent.service
#启动neutron
[root@linux-node1 ~]# systemctl start neutron-server.service neutron-linuxbridge-agent.service neutron-dhcp-agent.service neutron-metadata-agent.service
6. Neutron服务注册Keystone
6.1 创建neutron服务
[root@linux-node1 ~]# openstack service create --name neutron --description "OpenStack Networking" network
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | OpenStack Networking |
| enabled | True |
| id | 144b2eeafb9248b4ad7247318cdbd219 |
| name | neutron |
| type | network |
+-------------+----------------------------------+
6.2 创建Neutron服务API端点
[root@linux-node1 ~]# openstack endpoint create --region RegionOne network public http://192.168.56.11:9696
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | c9ab5d468d8940af958201d0d65816ba |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 144b2eeafb9248b4ad7247318cdbd219 |
| service_name | neutron |
| service_type | network |
| url | http://192.168.56.11:9696 |
+--------------+----------------------------------+
[root@linux-node1 ~]# openstack endpoint create --region RegionOne network internal http://192.168.56.11:9696
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 60c9f4d22f534a52a290895307b073e7 |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 144b2eeafb9248b4ad7247318cdbd219 |
| service_name | neutron |
| service_type | network |
| url | http://192.168.56.11:9696 |
+--------------+----------------------------------+
[root@linux-node1 ~]# openstack endpoint create --region RegionOne network admin http://192.168.56.11:9696
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 51471dfe465445c6b66684d02f93f1f8 |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 144b2eeafb9248b4ad7247318cdbd219 |
| service_name | neutron |
| service_type | network |
| url | http://192.168.56.11:9696 |
+--------------+----------------------------------+
7. 验证Neutron服务
能看到Metadata、DHCP、Linux bridge agent
,说明创建成功,后边会有三个笑脸哦。
[root@linux-node1 ~]# neutron agent-list
+--------------------+--------------------+--------------------+-------------------+-------+----------------+-----------------------+
| id | agent_type | host | availability_zone | alive | admin_state_up | binary |
+--------------------+--------------------+--------------------+-------------------+-------+----------------+-----------------------+
| 359b9e64-5cd1 | Metadata agent | linux- | | :-) | True | neutron-metadata- |
| -499d- | | node1.example.com | | | | agent |
| 8f94-5da454944257 | | | | | | |
| bca4f7fc-9c45-4ba2 | DHCP agent | linux- | nova | :-) | True | neutron-dhcp-agent |
| -83b6-5f5f9d1974e2 | | node1.example.com | | | | |
| c549a7a4-2c0d-4842 | Linux bridge agent | linux- | | :-) | True | neutron-linuxbridge- |
| -9620-9b1e19625947 | | node1.example.com | | | | agent |
+--------------------+--------------------+--------------------+-------------------+-------+----------------+-----------------------+
![anzhihe](https://cdn.chegva.com/wp-content/uploads/2016/06/179f8716-60x60.png)
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK