我們創建的云主機,肯定不能沒有網絡吧,所以我們在創建主機之前最好創建一個網絡??蛇x擇的網絡類型有:local,flat,vlan,gre,vxlan,geneve 等等。
有5種網絡模式
Local模式:一般測試時使用,只需一臺物理機即可。
GRE模式:隧道數量沒有限制,性能有點問題。
Vlan模式:vlan數量有4096的限制
VXlan模式:vlan數量沒有限制,性能比GRE好。
Flat模式:管理員創建,租戶直接到外網,不需要NAT了
啟動前我們可以檢查一下相關配置,不一致的地方照著修改修改。網絡部分對我來說是比較難的,我在這里糾結了好多天,差點都放棄學習了。
編輯/etc/neutron/plugin.ini
# vi /etc/neutron/plugin.ini
#type_drivers = vlan,flat 這里要把所有支持的驅動都填入,不然在控制臺頁面創建網絡的時候會報錯。
tenant_network_types = local,flat
type_drivers = local,flat,vlan,gre,vxlan,geneve
mechanism_drivers = linuxbridge
extension_drivers = port_security
[ml2_type_flat]
#flat_networks = provider
flat_networks = public
編輯后,/etc/neutron/plugins/ml2/ml2_conf.ini?中的對應項也會自動跟著變,這是一個軟連接。大家可以確認一下。沒有軟連接的改一下軟連接。
再編輯/etc/neutron/plugins/ml2/linuxbridge_agent.ini中的?
#physical_interface_mappings = provider:eth0
physical_interface_mappings = public:eth0
重啟neutron 服務
[root@controller neutron]# systemctl restart neutron-server
或者
[root@controller neutron]# openstack-service restart neutron
現在可以去去控制臺dashboard上 創建flat網絡了。
dashboard 中有兩個地方可以創建 network:
- Project -> Network -> Networks這是普通用戶在自己的 tenant 中創建 network 的地方,只能創建tenant_network_types 配置的默認網絡類型,
- Admin -> Networks 這是 admin 創建 network 的地方,管理員可以挑選指定創建的網絡類型。
我們先用第二種方式創建,點擊 “Create Network” 按鈕。
在 “管理員” 條目下選擇 “網絡”,再點擊 “創建網絡” ,在里面要注意選擇 “Flat” ,物理網絡為 “public” (注意這里與/etc/neutron/plugins/ml2/ml2_conf.ini內的[ml2_type_flat]?的flat_networks對應),然后再把 “共享的” 和 “外部網絡” 勾選起來,之后點擊 “創建網絡”。
然后下一步,配置子網。注意子網的信息一定要與你真實的宿主機物理網絡一樣。
配置子網詳情,注意這里的 192.168.25.200,192.168.25.250 為真實物理網絡中的一段:
創建成功
如果創建網絡過程中,出現錯誤大家可以調查下日志,參照錯誤信息,自己找出答案??梢园俣裙雀?,不會的奇怪問題可以問我,一起分析。下面是我創建local網絡時出的錯誤,大家可以參考。因為type_drivers參數沒有支持local的網絡類型,加上類型就好了。
[root@controller neutron]# cat server.log |grep fail
2018-01-15 09:57:52.058 15482 INFO neutron.pecan_wsgi.hooks.translation [req-cdb8f07b-23b0-434d-a6df-b7658c202ff6 1472d65524bb4a7ca1243a7f4a11fd11 ffaf3f6cd7a44f5fadad62e6dbc4356f - default default] POST failed (client error): The server couldnot comply with the request since it is either malformed or otherwise incorrect.
2018-01-15 09:58:44.740 15484 INFO neutron.pecan_wsgi.hooks.translation [req-957e086d-445e-4218-b882-5bf29186ccac 1472d65524bb4a7ca1243a7f4a11fd11 ffaf3f6cd7a44f5fadad62e6dbc4356f - default default] POST failed (client error): The server couldnot comply with the request since it is either malformed or otherwise incorrect.
2018-01-15 10:01:36.896 15484 INFO neutron.pecan_wsgi.hooks.translation [req-6b58e14b-9238-4a67-a8a8-d3fb00ff50fe 1472d65524bb4a7ca1243a7f4a11fd11 ffaf3f6cd7a44f5fadad62e6dbc4356f - default default] POST failed (client error): The server couldnot comply with the request since it is either malformed or otherwise incorrect.
2018-01-15 10:24:17.922 15485 INFO neutron.pecan_wsgi.hooks.translation [req-d9471a2d-22a3-4fb0-8bf5-1c40b17df4a0 1472d65524bb4a7ca1243a7f4a11fd11 ffaf3f6cd7a44f5fadad62e6dbc4356f - default default] POST failed (client error): The server couldnot comply with the request since it is either malformed or otherwise incorrect.
[root@controller httpd]# cat error_log|grep local
[Mon Jan 15 09:57:52.116303 2018] [:error] [pid 32173] WARNING horizon.exceptions Recoverable error: Invalid input for operation: network_type value 'local' not supported.
[Mon Jan 15 09:58:44.776506 2018] [:error] [pid 32173] WARNING horizon.exceptions Recoverable error: Invalid input for operation: network_type value 'local' not supported.
[Mon Jan 15 10:01:36.933763 2018] [:error] [pid 32173] WARNING horizon.exceptions Recoverable error: Invalid input for operation: network_type value 'local' not supported.
[Mon Jan 15 10:24:17.972489 2018] [:error] [pid 32173] WARNING horizon.exceptions Recoverable error: Invalid input for operation: network_type value 'local' not supported.