CREATE DATABASE neutron;
GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'%' IDENTIFIED BY 'neutronpass';
建立neutron
用戶:html
openstack user create --domain default --password-prompt neutron
添加admin
角色到neutron
用戶:mysql
openstack role add --project service --user neutron admin
建立neutron
服務linux
openstack service create --name neutron --description "OpenStack Networking" network
建立網絡服務API端點sql
openstack endpoint create --region RegionOne \ network public http://192.168.10.233:9696 openstack endpoint create --region RegionOne \ network internal http://192.168.10.233:9696 openstack endpoint create --region RegionOne \ network admin http://192.168.10.233:9696
您能夠部署網絡服務使用選項1和選項2兩種架構中的一種來部署網絡服務。數據庫
選項1採用儘量簡單的架構進行部署,只支持實例鏈接到公有網絡(外部網絡)。沒有私有網絡(我的網絡),路由器以及浮動IP地址。只有admin
或者其餘特權用戶才能夠管理公有網絡api
選項2在選項1的基礎上多了layer-3服務,支持實例鏈接到私有網絡。demo
或者其餘沒有特權的用戶能夠管理本身的私有網絡,包含鏈接公網和私網的路由器。另外,浮動IP地址可讓實例使用私有網絡鏈接到外部網絡,例如互聯網安全
典型的私有網絡通常使用覆蓋網絡。覆蓋網絡,例如VXLAN包含了額外的數據頭,這些數據頭增長了開銷,減小了有效內容和用戶數據的可用空間。在不瞭解虛擬網絡架構的狀況下,實例嘗試用以太網 最大傳輸單元 (MTU) 1500字節發送數據包。網絡服務會自動給實例提供正確的MTU的值經過DHCP的方式。可是,一些雲鏡像並無使用DHCP或者忽視了DHCP MTU選項,要求使用元數據或者腳原本進行配置bash
安裝組件網絡
yum install openstack-neutron openstack-neutron-ml2 \ openstack-neutron-linuxbridge ebtables
配置服務組件
編輯/etc/neutron/neutron.conf
文件並完成以下操做:
在 [database] 部分,配置數據庫訪問:架構
[database] connection = mysql+pymysql://neutron:neutronpass@192.168.10.233/neutron
在[DEFAULT]
部分,啓用Modular Layer 2 (ML2)插件,路由服務和重疊的IP地址:
[DEFAULT]
core_plugin = ml2
service_plugins = router
allow_overlapping_ips = true
在[DEFAULT]
部分,配置RabbitMQ
消息隊列訪問權限:
[DEFAULT] transport_url = rabbit://openstack:openstackpass@192.168.10.233
用你在RabbitMQ中爲openstack
選擇的密碼替換 「RABBIT_PASS」。
對於網絡選項2,一樣啓用layer-3服務並設置其隨系統自啓動
systemctl enable neutron-l3-agent.service
systemctl start neutron-l3-agent.service
在 「[DEFAULT]」 和 「[keystone_authtoken]」 部分,配置認證服務訪問:
[DEFAULT] auth_strategy = keystone [keystone_authtoken] auth_uri = http://192.168.10.233:5000 auth_url = http://192.168.10.233:35357 memcached_servers = 192.168.10.233:11211 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = neutron password = neutron
在[DEFAULT]
和[nova]
部分,配置網絡服務來通知計算節點的網絡拓撲變化:
[DEFAULT]
notify_nova_on_port_status_changes = true
notify_nova_on_port_data_changes = true
[nova]
auth_url = http://192.168.10.233:35357
auth_type = password
project_domain_name = default
user_domain_name = default
region_name = RegionOne
project_name = service
username = nova
password = nova
在 [oslo_concurrency] 部分,配置鎖路徑:
[oslo_concurrency] lock_path = /var/lib/neutron/tmp
配置 Modular Layer 2 (ML2) 插件
ML2插件使用Linuxbridge機制來爲實例建立layer-2虛擬網絡基礎設施
編輯/etc/neutron/plugins/ml2/ml2_conf.ini
文件並完成如下操做:
在[ml2]
部分,啓用flat,VLAN以及VXLAN網絡:
[ml2] type_drivers = flat,vlan,vxlan
在[ml2]
部分,啓用VXLAN私有網絡:
[ml2] tenant_network_types = vxlan
在[ml2]
部分,啓用Linuxbridge和l2機制:
[ml2] mechanism_drivers = linuxbridge,l2population
在你配置完ML2插件以後,刪除可能致使數據庫不一致的type_drivers
項的值。
Linuxbridge代理只支持VXLAN覆蓋網絡。
在[ml2]
部分,啓用端口安全擴展驅動:
[ml2] extension_drivers = port_security
在[ml2_type_flat]
部分,配置公共虛擬網絡爲flat網絡:
[ml2_type_flat] flat_networks = external,internal
在[ml2_type_vxlan]
部分,爲私有網絡配置VXLAN網絡識別的網絡範圍:
[ml2_type_vxlan] vni_ranges = 1:1000
在 [securitygroup]
部分,啓用 ipset 增長安全組的方便性:
[securitygroup]
enable_ipset = true
配置Linuxbridge代理
Linuxbridge代理爲實例創建layer-2虛擬網絡而且處理安全組規則。
編輯/etc/neutron/plugins/ml2/linuxbridge_agent.ini
文件而且完成如下操做:
在[linux_bridge]
部分,將公共虛擬網絡和公共物理網絡接口對應起來:
[linux_bridge] physical_interface_mappings = external:eth0,internal:eth1
在[vxlan]
部分,啓用VXLAN覆蓋網絡,配置覆蓋網絡的物理網絡接口的IP地址,啓用layer-2 population:
[vxlan]
enable_vxlan = true
local_ip = 192.168.10.201
l2_population = true
local_ip 將OVERLAY_INTERFACE_IP_ADDRESS
替換爲處理覆蓋網絡的底層物理網絡接口的IP地址。這個示例架構中使用管理網絡接口與其餘節點創建流量隧道。所以,將OVERLAY_INTERFACE_IP_ADDRESS
替換爲計算節點的管理網絡的IP地址。請查看:ref:environment-networking for more information。
在 [securitygroup]
部分,啓用安全組並配置 Linux 橋接 iptables 防火牆驅動:
[securitygroup]
enable_security_group = true
firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
配置layer-3代理
The Layer-3 (L3) agent provides routing and NAT services for self-service virtual networks.
編輯/etc/neutron/l3_agent.ini
文件並完成如下操做:
在[DEFAULT]
部分,配置Linuxbridge接口驅動和外部網絡網橋:
[DEFAULT] interface_driver = linuxbridge
配置DHCP代理
The DHCP agent provides DHCP services for virtual networks.
編輯/etc/neutron/dhcp_agent.ini
文件並完成下面的操做:
在[DEFAULT]
部分,配置Linuxbridge驅動接口,DHCP驅動並啓用隔離元數據,這樣在公共網絡上的實例就能夠經過網絡來訪問元數據
[DEFAULT]
interface_driver = linuxbridge
dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq
enable_isolated_metadata = true
元數據代理提供配置信息
編輯/etc/neutron/metadata_agent.ini
文件並完成如下操做:
在[DEFAULT]
部分,配置元數據主機以及共享密碼:
[DEFAULT] nova_metadata_ip = 192.168.10.233 metadata_proxy_shared_secret = 20190911
控制節點
元數據代理提供配置信息
編輯/etc/neutron/metadata_agent.ini
文件並完成如下操做:
在[DEFAULT]
部分,配置元數據主機以及共享密碼:
[DEFAULT] nova_metadata_ip = 192.168.10.233 metadata_proxy_shared_secret = 20190911
配置計算服務來使用網絡服務
編輯/etc/nova/nova.conf
文件並完成如下操做:
在[neutron]
部分,配置訪問參數,啓用元數據代理並設置密碼:
[neutron]
url = http://192.168.10.233:9696
auth_url = http://192.168.10.233: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 = 20190911
網絡服務初始化腳本須要一個超連接 /etc/neutron/plugin.ini指向ML2插件配置文件/etc/neutron/plugins/ml2/ml2_conf.ini
。若是超連接不存在,使用下面的命令建立它:
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
重啓計算API 服務:
systemctl restart openstack-nova-api.service
當系統啓動時,啓動 Networking 服務並配置它啓動。
對於兩種網絡選項:
systemctl enable neutron-server.service \
neutron-linuxbridge-agent.service neutron-dhcp-agent.service \
neutron-metadata-agent.service
systemctl restart neutron-server.service \
neutron-linuxbridge-agent.service neutron-dhcp-agent.service \
neutron-metadata-agent.service
systemctl enable neutron-l3-agent.service
systemctl restart neutron-l3-agent.service
驗證控制端
[root@controller1 ~]# neutron agent-list
neutron CLI is deprecated and will be removed in the future. Use openstack CLI instead.
+--------------------------------------+--------------------+-------------+-------------------+-------+----------------+---------------------------+
| id | agent_type | host | availability_zone | alive | admin_state_up | binary |
+--------------------------------------+--------------------+-------------+-------------------+-------+----------------+---------------------------+
| 4752fdf6-33c3-407b-a8ae-42f283076aa5 | L3 agent | controller1 | nova | :-) | True | neutron-l3-agent |
| 494a1bc1-06de-468b-8418-4e3c96e0b254 | Linux bridge agent | controller1 | | :-) | True | neutron-linuxbridge-agent |
| 65fb1c88-8c4a-4f12-a241-749dc3a5f2e0 | DHCP agent | controller1 | nova | :-) | True | neutron-dhcp-agent |
| 8f8666e7-cefd-4b32-9fe9-ebe24ae3bc8a | Linux bridge agent | computer1 | | :-) | True | neutron-linuxbridge-agent |
| d822f2c0-3b18-4bde-9547-fda0d67291d4 | Metadata agent | controller1 | | :-) | True | neutron-metadata-agent |
+--------------------------------------+--------------------+-------------+-------------------+-------+----------------+---------------------------+
安裝組件
yum install openstack-neutron-linuxbridge ebtables ipset
配置通用組件
Networking 通用組件的配置包括認證機制、消息隊列和插件
編輯/etc/neutron/neutron.conf
文件並完成以下操做:
在[database]
部分,註釋全部connection
項,由於計算節點不直接訪問數據庫。
在[DEFAULT]
部分,配置RabbitMQ
消息隊列訪問權限:
[DEFAULT] transport_url = rabbit://openstack:openstackpass@192.168.10.233
用你在RabbitMQ中爲openstack
選擇的密碼替換 「RABBIT_PASS」。
在 「[DEFAULT]」 和 「[keystone_authtoken]」 部分,配置認證服務訪問:
[DEFAULT] auth_strategy = keystone [keystone_authtoken] auth_uri = http://192.168.10.233:5000 auth_url = http://192.168.10.233:35357 memcached_servers = 192.168.10.233:11211 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = neutron password = neutron
將 NEUTRON_PASS 替換爲你在認證服務中爲 neutron 用戶選擇的密碼。
在 [oslo_concurrency] 部分,配置鎖路徑:
[oslo_concurrency] lock_path = /var/lib/neutron/tmp
配置網絡選項
選擇與您以前在控制節點上選擇的相同的網絡選項。以後,回到這裏並進行下一步:配置計算服務來使用網絡服務。
Linuxbridge代理爲實例創建layer-2虛擬網絡而且處理安全組規則。
編輯/etc/neutron/plugins/ml2/linuxbridge_agent.ini
文件而且完成如下操做:
在[linux_bridge]
部分,將公共虛擬網絡和公共物理網絡接口對應起來:
[linux_bridge] physical_interface_mappings = external:eth0,internal:eth1
將PUBLIC_INTERFACE_NAME
替換爲底層的物理公共網絡接口。請查看:ref:environment-networking for more information。
在[vxlan]
部分,啓用VXLAN覆蓋網絡,配置覆蓋網絡的物理網絡接口的IP地址,啓用layer-2
population:
[vxlan]
enable_vxlan = true
local_ip = 192.168.10.203
l2_population = true
將OVERLAY_INTERFACE_IP_ADDRESS
替換爲處理覆蓋網絡的底層物理網絡接口的IP地址。這個示例架構中使用管理網絡接口與其餘節點創建流量隧道。所以,將OVERLAY_INTERFACE_IP_ADDRESS
替換爲計算節點的管理網絡的IP地址。請查看:ref:environment-networking for more information。
在 [securitygroup]
部分,啓用安全組並配置 Linux 橋接 iptables 防火牆驅動:
[securitygroup]
enable_security_group = true
firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
配置計算服務來使用網絡服務
編輯/etc/nova/nova.conf
文件並完成下面的操做:
在[neutron]
部分,配置訪問參數:
[neutron] url = http://192.168.10.233:9696 auth_url = http://192.168.10.233:35357 auth_type = password project_domain_name = default user_domain_name = default region_name = RegionOne project_name = service username = neutron password = neutron
將 NEUTRON_PASS 替換爲你在認證服務中爲 neutron 用戶選擇的密碼。
完成安裝
重啓計算服務:
systemctl restart openstack-nova-compute.service
啓動Linuxbridge代理並配置它開機自啓動:
systemctl enable neutron-linuxbridge-agent.service
systemctl restart neutron-linuxbridge-agent.service
分配浮動IP
[root@controller1 ~]# ssh cirros@192.168.10.98
$ ifconfig eth0
eth0 Link encap:Ethernet HWaddr FA:16:3E:BE:40:B5
inet addr:192.168.30.158 Bcast:192.168.30.255 Mask:255.255.255.0
inet6 addr: fe80::f816:3eff:febe:40b5/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1450 Metric:1
RX packets:295 errors:0 dropped:0 overruns:0 frame:0
TX packets:296 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:37418 (36.5 KiB) TX bytes:33885 (33.0 KiB)