欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  网络运营

OpenStack安装部署Liberty Neutron

程序员文章站 2023-11-19 13:49:52
最近在两台物理机环境中部署了openstack的liberty版本,各个模块都遇到或多或少的问题,但尤以neutron的问题最让人头疼。尽管openstack一直致力于简化...

最近在两台物理机环境中部署了openstack的liberty版本,各个模块都遇到或多或少的问题,但尤以neutron的问题最让人头疼。尽管openstack一直致力于简化neutron的部署,但对于非网络技术人员来说依然存在着很大的挑战,根本原因还是由于网络自身的复杂性所导致的,因此想要成功部署neutron还是需要网络基础的,但这并不意味着没有网络基础就不能成功部署neutron并使其工作。本文将总结neutron的安装部署步骤,并对遇到的问题进行详细的描述,旨在提供解决问题的思路或者给与一定的启示。

根据官方部署文档的说法,neutron允许创建由其它openstack服务管理的接口设备,并将这样的设备附加到网络,可以实现各种插件或代理以适应不同的网络设备和软件,为openstack架构提供足够的灵活性。neutron主要包括以下组件:

  • neutron-server:接收并转发api请求到合适的neutron插件,如linuxbridge-agent。
  • neutron插件和代理:连接port,创建网络或子网,提供ip地址。根据云计算环境使用的厂商或者技术,这些插件和代理会有所区别。neutron为思科的虚拟和物理交换机、nec的openflow产品、open vswitch(ovs)、linux bridging和vmware的nsx产品提供了插件或代理。
  • 消息队列:neutron使用消息队列在neutron-server和各种代理之间路由消息,也存储特定插件的状态。主要的消息队列有rabbitmq、qpid和zeromq。

neutron将网络、子网和路由器抽象为对象,每个抽象对象都具有与其对应的物理概念或设备的功能,网络包含子网,路由器在不同的子网和网络之间路由消息。每个路由器有一个连接到网络的网关(gateway)和许多连接子网的虚拟网卡,连接到相同路由器的子网可以互相访问。这和实际物理环境中路由器的功能是一致的。

无论以何种方式部署neutron,在创建网络时至少需要创建一个external网络。与其它网络不同的是,external网络不仅仅是虚拟定义网络,它代表了物理的,openstack安装之外的外部网络的视图。external网络上的ip地址可以被外部物理网络访问,由于external网络仅仅表示外部网络的视图,因此在该网络总dhcp是禁用的。除了external网络,还要有一个或多个internal网络,vms直接连接到这些软件定义网络。相同internal网络上的vms可以互相访问,或连接到相同路由器上不同子网中的vms也可以互相访问,比如主机a位于子网n1,主机b位于子网n2,n1和n2连接到相同的路由器,那么a和b之间是网络可达的。外部网络访问vms或vms访问外部网络的功能有路由器完成,路由器的网关连接external网络,internal网络连接路由器的接口,与实际的物理网络结构相似。可以为internal网络中的ports分配external网络中的ip地址,port指的是连接到子网的连接。通过将external网络中的ip与vms的ports关联可以实现外部网络对vms的访问。neutron也支持安全组。安全组使管理员可以在组内定义防火墙规则,vm可以属于多个安全组,neutron根据安全组的规则或策略阻塞或允许ports,或vms允许的通信类型。

 本次将neutron部署在两台物理机controller和compute上,其中controller做为控制节点(网络节点),compute为计算节点,controller节点已经安装配置了mysql、rabbitmq和keystone。首先需要在mysql数据库中创建neutron对应的数据库:

 mariadb [(none)]> create database neutron; 
query ok, 1 row affected (0.04 sec) 
mariadb [(none)]> grant all privileges on neutron.* to 'neutron'@'localhost' identified by 'neutron'; 
query ok, 0 rows affected (0.24 sec) 
mariadb [(none)]> grant all privileges on neutron.* to 'neutron'@'%' identified by 'neutron';      
query ok, 0 rows affected (0.00 sec) 

其次在keystone中创建neutron对应的用户、service和endpoint:

[opst@controller ~]$ source admin-openrc.sh 
[root@controller opst]# openstack user create --domain default --password neutron neutron 
+-----------+----------------------------------+ 
| field   | value             | 
+-----------+----------------------------------+ 
| domain_id | default           | 
| enabled  | true             | 
| id    | 24a20abcf4324cfca09484959244aaf7 | 
| name   | neutron           | 
+-----------+------------------------------------+ 
  
[root@controller opst]# openstack role add --project service --user neutron admin 
[root@controller opst]# openstack service create --name neutron --description 'the networking service' network 
[root@controller opst]# openstack endpoint create --region regionone neutron public http://controller:9696 
+--------------+----------------------------------+ 
| field    | value             | 
+--------------+----------------------------------+ 
| enabled   | true             | 
| id      | a7aae0431e2948ce8070ddf0a14bbdf8 | 
| interface  | public             | 
| region    | regionone          | 
| region_id  | regionone         | 
| service_id  | ec4391191490440787799e973b54c816 | 
| service_name | neutron           | 
| service_type | network           | 
| url     | http://controller:9696     | 
+--------------+------------------------------------+ 
[root@controller opst]# openstack endpoint create --region regionone neutron internal http://controller:9696 
+--------------+----------------------------------+ 
| field    | value             | 
+--------------+----------------------------------+ 
| enabled   | true             | 
| id      | 8599ab44484b4c3dbc12f8c945490cef | 
| interface  | internal            | 
| region    | regionone          | 
| region_id  | regionone         | 
| service_id  | ec4391191490440787799e973b54c816 | 
| service_name | neutron           | 
| service_type | network           | 
| url     | http://controller:9696     | 
+--------------+-----------------------------------+ 
[root@controller opst]# openstack endpoint create --region regionone neutron admin http://controller:9696   
+--------------+----------------------------------+ 
| field    | value             | 
+--------------+----------------------------------+ 
| enabled   | true             | 
| id      | 66ef114548e84911873e83949ef76307 | 
| interface  | admin            | 
| region    | regionone          | 
| region_id  | regionone         | 
| service_id  | ec4391191490440787799e973b54c816 | 
| service_name | neutron           | 
| service_type | network           | 
| url     | http://controller:9696     | 
+--------------+-------------------------------------+ 

完成上述基础服务的配置管理后,要决定neutron部署架构,可以采用的架构有两种,provider网络和self-service网络。provider网络可能是最简单的neutron架构,仅支持为vm分配public(provider)网络,没有自服务网络,路由器或者浮动ip,只有admin或者其他特权用户可以管理provider网络。self-service网络支持layer-3服务,允许vms分配private网络,demo用户或其他非特权用户可以自行管理网络,比如连接self-service网络和provider网络的路由器。另外,浮动ip可以使外部网络,比如internet,访问vms。self-service网络也支持vms分配public(provider)网络。

本次部署采用self-service网络。在控制节点controller部署self-service网络相关安装包,根据操作系统是否已经安装了ebtables或ipset,最后两个安装包可做相应取舍。

[root@controller opst]# yum install openstack-neutron openstack-neutron-ml2 openstack-neutron-linuxbridge python-neutronclient ebtables ipset 

编辑/etc/neutron/neutron.conf:

[default] 
verbose = true 
core_plugin = ml2 
service_plugins = router 
allow_overlapping_ips = true 
rpc_backend=rabbit 
auth_strategy = keystone 
  
notify_nova_on_port_status_changes = true 
notify_nova_on_port_data_changes = true 
nova_url = http://controller:8774/v2 
  
[database] 
connection = mysql://neutron:neutron@controller/neutron 
  
[oslo_messaging_rabbit] 
rabbit_host = controller 
rabbit_userid = openstack 
rabbit_password = opst 
  
[keystone_authtoken] 
auth_uri = http://controller:5000 
auth_url = http://controller:35357 
auth_plugin = password 
project_domain_id = default 
user_domain_id = default 
project_name = service 
username = neutron 
password = neutron 
  
[nova] 
auth_url = http://controller:35357 
auth_plugin = password 
project_domain_id = default 
user_domain_id = default 
region_name = regionone 
project_name = service 
username = nova 
password = nova 
  
[oslo_concurrency] 
lock_path = /var/lib/tmp/neutron 

编辑/etc/neutron/plugins/ml2/ml2_conf.ini:

[ml2] 
type_drivers = flat,vlan,vxlan 
tenant_network_types = vxlan 
mechanism_drivers = linuxbridge,l2population 
extension_drivers = port_security 
  
[ml2_type_flat] 
flat_networks = public 
  
[ml2_type_vxlan] 
vni_ranges = 1:1000 
  
[securitygroup] 
enable_ipset = true 

编辑/etc/neutron/plugins/ml2/linuxbridge_agent.ini:

[linux_bridge] 
physical_interface_mappings = public:eno1 
  
[vxlan] 
enable_vxlan = true 
local_ip = 192.168.81.66 
l2_population = true 
  
[agent] 
prevent_arp_spoofing = true 
  
[securitygroup] 
enable_security_group = true 
firewall_driver = neutron.agent.linux.iptables_firewall.iptablesfirewalldrive 

 编辑/etc/neutron/l3_agent.ini:

[default] 
interface_driver = neutron.agent.linux.interface.bridgeinterfacedriver 
external_network_bridge = 
verbose = true 

编辑/etc/neutron/dhcp_agent.ini:

[default] 
interface_driver = neutron.agent.linux.interface.bridgeinterfacedriver 
dhcp_driver = neutron.agent.linux.dhcp.dnsmasq 
enable_isolated_metadata = true 
verbose = true 
dnsmasq_config_file = /etc/neutron/dnsmasq-neutron.conf 

创建/etc/neutron/dnsmasq-neutron.conf,并添加如下内容,启动dhcp的mtu选项(26),并将大小设置为1450字节。

dhcp-option-force=26,1450 

编辑/etc/neutron/metadata_agent.ini:

[default] 
  
auth_uri = http://controller:5000 
auth_url = http://controller:35357 
auth_region = regionone 
auth_plugin = password 
project_domain_id = default 
user_domain_id = default 
project_name = service 
username = neutron 
password = neutron 
  
nova_metadata_ip = controller 
metadata_proxy_shared_secret = test(与nova.conf中[neutron]metadata_proxy_shared_secret的值相同) 
verbose = true 

编辑/etc/nova/nova.conf:

[neutron] 
  
url = http://controller:9696 
auth_url = http://controller:35357 
auth_plugin = password 
project_domain_id = default 
user_domain_id = default 
region_name = regionone 
project_name = service 
username = neutron 
password = neutron 
  
service_metadata_proxy = true 
metadata_proxy_shared_secret = metadata_secret 

neutron的初始化脚本需要链接文件/etc/neutron/plugin.ini指向/etc/neutron/plugins/ml2/ml2_conf.ini:

 [root@controller opst]# ln -s /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.ini 

推送数据到mysql数据库中:

[root@controller opst]#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:

 [root@controller opst]# systemctl restart openstack-nova-api.service 

 配置neutron服务随系统启动(无论是provider网络还是self-service网络):

[root@controller opst]# systemctl enable neutron-server.service neutron-linuxbridge-agent.service neutron-dhcp-agent.service neutron-metadata-agent.service 

 启动neutron服务(无论是provider网络还是self-service网络):

[root@controller opst]# systemctl start neutron-server.service neutron-linuxbridge-agent.service neutron-dhcp-agent.service neutron-metadata-agent.service  

 如果是self-service网络,则还需要启动neutron-l3-agent.service服务:

[root@controller opst]# systemctl enable neutron-l3-agent.service 
[root@controller opst]# systemctl start neutron-l3-agent.service 

在计算节点compute部署self-service网络相关安装包,根据操作系统是否已经安装了ebtables或ipset,最后两个安装包可做相应取舍:

[root@controller opst]# systemctl enable neutron-l3-agent.service 
[root@controller opst]# systemctl start neutron-l3-agent.service 

编辑/etc/neutron/plugins/ml2/linuxbridge_agent.in:

[linux_bridge] 
physical_interface_mappings = public:eno1 
  
[vxlan] 
enable_vxlan = true 
local_ip = 192.168.81.65(compute ip地址) 
l2_population = true 
  
[agent] 
prevent_arp_spoofing = true 
  
[securitygroup] 
enable_security_group = true 
firewall_driver = neutron.agent.linux.iptables_firewall.iptablesfirewalldrive 

编辑/etc/nova/nova.conf:

[neutron] 
  
url = http://controller:9696 
auth_url = http://controller:35357 
auth_plugin = password 
project_domain_id = default 
user_domain_id = default 
region_name = regionone 
project_name = service 
username = neutron 
password = neutron 

重启nova:

[neutron] 
  
url = http://controller:9696 
auth_url = http://controller:35357 
auth_plugin = password 
project_domain_id = default 
user_domain_id = default 
region_name = regionone 
project_name = service 
username = neutron 
password = neutron 

启动neutron:

[root@compute opst]# systemctl enable neutron-linuxbridge-agent.service 
[root@compute opst]# systemctl start neutron-linuxbridge-agent.service 

 在控制节点验证neutron的安装:

[opst@controller ~]$ neutron ext-list 
+-----------------------+-----------------------------------------------+ 
| alias         | name                  | 
+-----------------------+-----------------------------------------------+ 
| dns-integration    | dns integration            | 
| ext-gw-mode      | neutron l3 configurable external gateway mode | 
| binding        | port binding              | 
| agent         | agent                  | 
| subnet_allocation   | subnet allocation           | 
| l3_agent_scheduler  | l3 agent scheduler          | 
| external-net     | neutron external network       | 
| flavors        | neutron service flavors        | 
| net-mtu        | network mtu             | 
| quotas        | quota management support      | 
| l3-ha         | ha router extension          | 
| provider       | provider network            | 
| multi-provider    | multi provider network         | 
| extraroute      | neutron extra route           | 
| router        | neutron l3 router            | 
| extra_dhcp_opt    | neutron extra dhcp opts       | 
| security-group    | security-group              | 
| dhcp_agent_scheduler | dhcp agent scheduler        | 
| rbac-policies    | rbac policies              | 
| port-security     | port security               | 
| allowed-address-pairs | allowed address pairs         | 
| dvr          | distributed virtual router        | 
+-----------------------+--------------------------------------------------+ 

 继续在控制节点执行下面的命令:

[opst@controller ~]$ neutron agent-list 
+--------------------------------------+--------------------+------------+-------+----------------+---------------------------+ 
| id                  | agent_type     | host    | alive | admin_state_up | binary          | 
+--------------------------------------+--------------------+------------+-------+----------------+---------------------------+ 
| 111e36b2-a1d6-4c86-90c3-e4e4725fa560 | l3 agent      | controller | :-)  | true      | neutron-l3-agent     | 
| 7aaa5eca-0436-423f-af2f-fbae0ebc6fa1 | linux bridge agent | compute  | :-)  | true      | neutron-linuxbridge-agent | 
| 7e394c14-ce7e-45e0-9ac6-3f9250c04984 | linux bridge agent | controller | :-)  | true      | neutron-linuxbridge-agent | 
| a6ec9a47-e8f1-4948-9d9b-b172fd6757d6 | metadata agent   | controller | :-)  | true      | neutron-metadata-agent  | 
| f99f491b-79e1-4d5d-8c3f-9ecdcf11452c | dhcp agent     | controller | :-)  | true      | neutron-dhcp-agent    | 
+--------------------------------------+--------------------+------------+-------+----------------+---------------------------+ 

这条命令的输出一是看相关服务是否已经全部部署成功,二是是否正常运行,可通过观察第四列的值来确定,:-) 为运行正常,xxxx则存在问题。在验证neutron部署成功后,将创建虚拟网络。根据所选择的网络架构(provider或者self-service),需要执行不同的命令创建不同的网络。由于部署的是self-service网络,因此既需要创建public provider网络也需要创建private project网络,public网络用于通过layer-2连接实际的物理网络,private网络使用layer-3和nat连接物理网络,并包含为vms分配ip的dhcp,vms能够访问internet,如果想要外部网络访问vms,则需要浮动ip地址与vm关联。

 即使成功完成了上述步骤,并且解决了可能出现的问题,比如配置问题,在创建虚拟网络时依然存在着巨大的风险。尽管openstack致力于简化创建网络的工作,但对于新手来说依然困难重重,尤其是部署的环境和官方文档所推荐的环境不一致时。根据官方文档的说明,当部署self-service网络时,在创建private网络之前必须先创建public网络,但在实际创建虚拟网络的过程中,发现即使先创建private网络再创建public网络,也并未影响网络创建成功与否,但为了与官方保持一致还是按照先创建public网络再创建private网络的顺序进行操作。

 执行下面的命令创建public网络,其中--provider:physical_networkpublic中的public与flat_networks = public中保持一致:

[opst@controller ~]$ neutron net-create public --shared --router:external --provider:physical_network public --provider:network_type flat 
created a new network: 
+---------------------------+--------------------------------------+ 
| field           | value              | 
+---------------------------+--------------------------------------+ 
| admin_state_up      | true             | 
| id            | a4b483a8-8331-4fd4-bfec-431e4df8b7ff | 
| mtu            | 0                | 
| name           | public             | 
| port_security_enabled  | true              | 
| provider:network_type   | flat              | 
| provider:physical_network | public             | 
| provider:segmentation_id |                | 
| router:external     | true               | 
| shared          | true               | 
| status          | active             | 
| subnets          |                  | 
| tenant_id         | a242aca931bb49e08a49e5e942c8129d | 
+---------------------------+----------------------------------------+ 

接下来创建子网,这条命令的执行结果将直接影响是否可以连通外部网络,在经过无数次失败的尝试后终于使neutron可以连通外网。错误的原因在于错误的设置了192.168.81.0/24及start和end的值,上述值必须为实际的物理网络地址或范围,比如我的物理机仅有一块网卡,通过dhcp分配的ip地址为192.168.81.xxx,因此public_network_cidr就必须为192.168.81.0/24,而start和end则为未使用的192.168.81.xxx地址。

[opst@controller ~]$ neutron subnet-create public 192.168.81.0/24 --name public --allocation-pool start=192.168.81.100,end=192.168.81.200 --dns-nameserver 192.168.85.253 --gateway 192.168.81.254 
created a new subnet: 
+-------------------+------------------------------------------------------+ 
| field       | value                     | 
+-------------------+------------------------------------------------------+ 
| allocation_pools | {"start": "192.168.81.100", "end": "192.168.81.200"} | 
| cidr       | 192.168.81.0/24                | 
| dns_nameservers  | 192.168.85.253               | 
| enable_dhcp    | true                      | 
| gateway_ip    | 192.168.81.254                | 
| host_routes    |                          | 
| id        | da0ff1d1-35e5-4adb-90d6-9c45bc7864c8    | 
| ip_version    | 4                         | 
| ipv6_address_mode |                        | 
| ipv6_ra_mode   |                         | 
| name       | public                      | 
| network_id    | a4b483a8-8331-4fd4-bfec-431e4df8b7ff   | 
| subnetpool_id   |                         | 
| tenant_id     | a242aca931bb49e08a49e5e942c8129d    | 
+-------------------+----------------------------------------------------------+ 

创建完public网络后,接下来创建private网络。private网络用于为vms分配ip地址,使其之间可以互联访问。

[root@controller opst]# neutron net-create private 
created a new network: 
+-----------------------+--------------------------------------+ 
| field         | value              | 
+-----------------------+--------------------------------------+ 
| admin_state_up    | true              | 
| id          | 23ec30de-c5dc-49b2-923c-3b7b83e1d9d1 | 
| mtu          | 0                | 
| name         | private             | 
| port_security_enabled | true              | 
| router:external    | false              | 
| shared        | false              | 
| status        | active            | 
| subnets        |                 | 
| tenant_id       | 25b21a1cd9aa474e95a8cfd8e175714c   | 
+-----------------------+---------------------------------------+ 

在private网络上创建子网的命令如下,其中172.16.1.0/24为子网的cidr,推荐值为10.0.0.0/8,172.16.0.0/12和192.168.0.0/16。

[root@controller opst]# neutron subnet-create private 172.16.1.0/24 --name private --dns-nameserver 192.168.85.253 --gateway 172.16.1.1 
created a new subnet: 
+-------------------+------------------------------------------------+ 
| field       | value                   | 
+-------------------+------------------------------------------------+ 
| allocation_pools | {"start": "172.16.1.2", "end": "172.16.1.254"} | 
| cidr       | 172.16.1.0/24              | 
| dns_nameservers | 192.168.85.253            | 
| enable_dhcp   | true                   | 
| gateway_ip    | 172.16.1.1               | 
| host_routes    |                      | 
| id        | dd9ee06a-fd00-41f5-93ba-82f3c0c1e052 | 
| ip_version    | 4                     | 
| ipv6_address_mode |                    | 
| ipv6_ra_mode   |                     | 
| name       | private                 | 
| network_id    | 23ec30de-c5dc-49b2-923c-3b7b83e1d9d1 | 
| subnetpool_id   |                     | 
| tenant_id     | 25b21a1cd9aa474e95a8cfd8e175714c | 
+-------------------+-------------------------------------------------+ 

创建完网络后,需要创建路由器以使private网络和public网络互连。创建路由器的命令及输出如下:

[opst@controller ~]$ neutron router-create router 
created a new router: 
+-----------------------+--------------------------------------+ 
| field        | value              | 
+-----------------------+---------------------------------------+ 
| admin_state_up    | true             | 
| external_gateway_info |                | 
| id          | 27512806-cac3-47f8-acff-b7bd847e2866 | 
| name         | router             | 
| routes        |                 | 
| status        | active            | 
| tenant_id       | 25b21a1cd9aa474e95a8cfd8e175714c | 
+-----------------------+--------------------------------------+ 

创建路由器后,需要为路由器添加内部网络的网卡,其中的private为内部网络子网的名称或id:

[opst@controller ~]$ neutron router-interface-add router private 
added interface f8979659-e714-4298-90cb-57d2b156166c to router router 

最后为路由器添加网关,其中public为external网络的名称或id:

[opst@controller ~]$ neutron router-gateway-set router public 
set gateway for router router 

完成上述步骤后,理论上neutron的部署就成功了,但在未实际测试网络的连通性的情况下,并不能百分百确定网络是连通的。测定连通性最简单的方式是执行ping操作,如果ping的结果没有错误信息,则可以大致认为网络是连通的。那具体应该ping什么样的地址,建议测试虚拟路由器的external网络和internal网络的ip地址,这些信息通过执行下面的命令获得:

[opst@controller ~]$ neutron router-port-list router 
+--------------------------------------+------+-------------------+---------------------------------------------------------------------------------------+ 
| id                  | name | mac_address    | fixed_ips                                       | 
+--------------------------------------+------+-------------------+---------------------------------------------------------------------------------------+ 
| 653e03b9-8e4a-41c7-97c9-f0a1fa4f086f |   | fa:16:3e:34:b6:5c | {"subnet_id": "da0ff1d1-35e5-4adb-90d6-9c45bc7864c8", "ip_address": "192.168.81.101"} | 
| f8979659-e714-4298-90cb-57d2b156166c |   | fa:16:3e:9f:fb:83 | {"subnet_id": "dd9ee06a-fd00-41f5-93ba-82f3c0c1e052", "ip_address": "172.16.1.1"}   | 
+--------------------------------------+------+-------------------+---------------------------------------------------------------------------------------+ 

通过ping 192.168.81.101.可以确定external网络是否连通,而要想确认internal网络是否连通则需要在路由器的网络命名空间下ping 172.16.1.1,网络命名空间通过执行下面的命令获得:

[opst@controller ~]$ ip netns 
qrouter-27512806-cac3-47f8-acff-b7bd847e2866 (id: 2) 
qdhcp-a4b483a8-8331-4fd4-bfec-431e4df8b7ff (id: 1) 
qdhcp-23ec30de-c5dc-49b2-923c-3b7b83e1d9d1 (id: 0)

然后以root用户执行下面的命令:

ip netns exec qrouter-27512806-cac3-47f8-acff-b7bd847e2866 ping 172.16.1.1 

如果上述命令的输出显示无错误,则基本可认为external网络和internal网络都是连通的,进而可以继续vm的创建,否则即使能够创建vm,也无法保证vm网络可用。

至此基本完成了neutron的部署和虚拟网络的创建,但可能遇到的问题或需要注意的地方远远超过了这篇文章所能涵盖的。下面就几个可能出现的问题进行简单的总结。

如果internal网络类型为vxlan,也即参数tenant_network_types的值为vxlan,则需要宿主操作系统的内核为3.13或者更高版本。可以通过uname –r查看内核版本,而升级则可通过下面的命令进行:

[root@controller opst]# rpm --import https://www.elrepo.org/rpm-gpg-key-elrepo.org 
[root@controller opst]# rpm -uvh http://www.elrepo.org/elrepo-release-7.0-2.el7.elrepo.noarch.rpm 
[root@controller opst]# yum --enablerepo=elrepo-kernel install kernel-ml-devel kernel-ml -y 
[root@controller opst]# awk -f\' '$1=="menuentry " {print $2}' /etc/grub2.cfg 
centos linux (4.5.0-1.el7.elrepo.x86_64) 7 (core) 
centos linux (3.10.0-327.10.1.el7.x86_64) 7 (core) 
[root@controller opst]# grub2-set-default 0 
reboot 

另外一些问题在命令行中是否无法察觉的,也就是说,当执行了某条命令后,输出信息并不足以判断是否成功,直到测试网络连通性或者创建vms时才发现某些步骤存在问题。应对类似问题的最好方法就是在创建虚拟网络及创建vms时观察neutron和nova日志的输出,这样没执行一条命令就能确定是否成功,有助于问题的定位,同时不会浪费时间或精力。比如在neutron的日志中常见的如下错误信息:

2016-04-06 17:12:51.605 3136 error neutron.plugins.ml2.managers [req-0dc4b947-ebbe-47a9-823c-a4f9ead7df74 - - - - -] failed to bind port 24191168-b2c0-47d8-aa81-c46ad9bcf7b6 on host controller 
2016-04-06 17:12:51.605 3136 error neutron.plugins.ml2.managers [req-0dc4b947-ebbe-47a9-823c-a4f9ead7df74 - - - - -] failed to bind port 24191168-b2c0-47d8-aa81-c46ad9bcf7b6 on host controller 
2016-04-06 17:12:51.623 3136 info neutron.plugins.ml2.plugin [req-0dc4b947-ebbe-47a9-823c-a4f9ead7df74 - - - - -] attempt 2 to bind port 24191168-b2c0-47d8-aa81-c46ad9bcf7b6 
2016-04-06 17:12:52.218 3136 warning neutron.plugins.ml2.rpc [req-8c5de5e4-288f-4f1a-a377-3b348c3ee13b - - - - -] device tap24191168-b2 requested by agent lb0010c6b0ae66 on network 521f09b9-791e-482f-9403-5ddac2d047b4 not bound, vif_type: binding_failed 

该问题有可能是因为内核版本低于3.13以至于不支持vxlan网络,另一个可能的原因是由于public子网的cidr与所属的物理网段不一致。

以上两个问题,尤其是最后一个问题是在部署neutron时遇到的最大关卡,其它问题,如配置文件的拼写错误,都是容易排查的。neutron的功能及角色决定了其复杂性,涉及的内容不仅仅是网络知识,还包括操作系统、虚拟化等方面,因此要想更深入的理解掌握neutron,需要在遇到不同的问题时,查阅相关资料进行深入学习,否则也仅仅是做到了部署。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。