1.概述
網絡配置有兩種方式:provider網絡或者self-service網絡,具體情況參考官方文檔
provider網絡參考和self-service網絡參考。更多關于網絡服務(包括虛拟網絡元件、分層、流量)等資訊,請參考Mitaka網絡指南。
Neutron包含如下元件:
-
neutron-server
接收并路由API請求到合适的openstack網絡插件。
-
OpenStack Networking plug-ins and agents
建立網絡或子網,提供IP位址。這些插件和代理依靠特定雲中使用的供應商和技術,插件可以使用Cisco虛拟和實體交換機,NEC openFlow products,open vSwitch,linux briding 和VMwareNSX。正常的代理有Layer3,DHCP等。
-
Messaging queue
大多數openstack網絡使用它連接配接neutron-server和各種不同代理間資訊互動。此外,也作為一個存儲網絡狀态的資料庫。
Openstack網絡主要為openstack compute執行個體提供網絡和連通性。
2.控制節點上部署(10.10.80.180)
2.1安裝前提
2.1.1 建立資料庫
- 1.以root使用者登入資料庫
mysql -u root -p
- 2.建立“neutron”資料庫
MariaDB > CREATE DATABASE neutron;
-
3.賦予“neutron”權限
用123456替代NEUTRON_DBPASS,在openstack安裝部署1中規劃openstack部署——前言&規劃
>GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'localhost' \
>IDENTIFIED BY 'NEUTRON_DBPASS';
>GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'%' \
>IDENTIFIED BY 'NEUTRON_DBPASS';
- 4.退出資料庫
> exit
2.1.2 source環境配置
. admin-openrc
2.1.3 建立服務憑據
- 1.建立“neutron”使用者,密碼為123456,規劃見openstack部署——前言&規劃
openstack user create --domain default --password-prompt neutron
- 2.将“admin”role賦予“neturon”user
openstack role add --project service --user neutron admin
- 3.建立“neturon”服務執行個體
openstack service create --name neutron --description "OpenStack Networking" network
2.1.4建立網絡服務API endpoint
- public
openstack endpoint create --region RegionOne network public http://controller:9696
- internal
openstack endpoint create --region RegionOne network internal http://controller:9696
- admin
openstack endpoint create --region RegionOne network admin http://controller:9696
2.2安裝&配置
本次實驗選擇安裝provide網絡架構。
2.2.1安裝元件
apt-get install neutron-server neutron-plugin-ml2 neutron-linuxbridge-agent neutron-dhcp-agent neutron-metadata-agent
2.2.2配置服務元件
網絡元件的配置包括:資料庫、認證機制、消息隊列、拓撲變化通知、插件。
編輯/etc/neutron/neutron.conf檔案
-
1.在[database]部配置設定置資料庫接口
用建立資料庫時的實際密碼123456替代NEUTRON_DBPASS
[database]
connection = mysql+pymysql://neutron:[email protected]/neutron
- 2.在[DEFAULT]部配置設定置modular Layer2(ML2)插件,并禁用其他插件
[DEFAULT]
···
core_plugin = ml2
service_plugins =
-
3.在[DEFAULT]部分和[oslo_messaging_rabbit]部分
配置RabbitMQ,用123456替換RABBIT_PASS
[DEFAULT]
···
rpc_backend = rabbit
[oslo_messaging_rabbit]
rabbit_host = controller
rabbit_userid = openstack
rabbit_password = RABBIT_PASS
-
4.在[DEFAULT]部分和[keystone_authtoken]部配置設定置認證服務接口
NEUTRON_PASS用“neutron”user的密碼123456替換。
[DEFAULT]
...
auth_strategy = keystone
[keystone_authtoken]
auth_uri = http://controller:
auth_url = http://controller:
memcached_servers = controller:
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = neutron
password = NEUTRON_PASS
-
5.在[DEFAULT]部分和[nova]部配置設定置網絡來公告拓撲改變
NOVA_PASS用nova使用者密碼123456替換
[DEFAULT]
...
notify_nova_on_port_status_changes = True
notify_nova_on_port_data_changes = True
[nova]
auth_url = http://controller:
auth_type = password
project_domain_name = default
user_domain_name = default
region_name = RegionOne
project_name = service
username = nova
password = NOVA_PASS
2.2.3 配置Modular Layer 2(ML2)插件
ML2 插件通過Linux網橋機制為執行個體建立二層(bridging and switching) 虛拟網絡設施。編輯/etc/neutron/plugins/ml2/ml2_conf.ini檔案:
- 1.在[ml2]部分,激活flat和VLAN網絡
[ml2]
...
type_drivers = flat,vlan
- 2.在[ml2]部分,禁用self-service 網絡
[ml2]
...
tenant_network_types =
- 3.在[ml2]部分,激活linux bridge機制
[ml2]
...
mechanism_drivers = linuxbridge
【備注:在配置ML2插件後,移除type_drivers選項中的值會導緻資料庫的不一緻性,注釋掉該行代碼
】
- 4.在[ml2]部分,激活端口安全的擴充驅動
[ml2]
...
extension_drivers = port_security
- 5.在[ml2_type_flat]部分,配置provider 虛拟網絡作為一個flat網絡
[ml2_type_flat]
...
flat_networks = provider
- 6.在[securitygroup] 部分,激活ipset 來提高安全組規則的效率
[securitygroup]
...
enable_ipset = true
2.2.4配置linux 網橋代理
Linux網橋代理為執行個體建立二層(網橋和交換)虛拟網絡設施,并管理安全組。修改配置檔案/etc/neutron/plugins/ml2/linuxbridge_agent.ini。
-
1.在[linux_bridge]部分
将provider 虛拟網絡和provider實體網絡接口映射,将PROVIDER_INTERFACE_NAME替換為底層實體網絡接口名稱,具體請參考官方文檔
physical_interface_mappings = provider:PROVIDER_INTERFACE_NAME
- 2.在[vxlan]部分,禁用VXLAN
[vxlan]
enable_vxlan = False
-
3.在[securitygroup]部分
激活安全組并配置linux網橋防火牆
[securitygroup]
...
enable_security_group = True
firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
2.2.5 配置DHCP代理
編輯 /etc/neutron/dhcp_agent.ini 檔案:
在[DEFAULT]部分,配置如下内容:
[DEFAULT]
...
interface_driver = neutron.agent.linux.interface.BridgeInterfaceDriver
dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq
enable_isolated_metadata = True
2.3配置中繼資料代理
供了執行個體的各種配置資訊,例如執行個體的認證資訊。
編輯檔案/etc/neutron/metadata_agent.ini,在在[DEFAULT] 部配置設定置metadata host 和shared secret,用合适的密碼123456替代METADATA_SECRET
[DEFAULT]
...
nova_metadata_ip = controller
metadata_proxy_shared_secret = METADATA_SECRET
2.4配置compute,使用networking
編輯/etc/nova/nova.conf,在 [neutron] 部配置設定置參數接口,激活中繼資料proxy和配置secret,用密碼123456替代NEUTRON_PASS,用123456替代METADATA_SECRET。
[neutron]
url = http://controller:
auth_url = http://controller:
auth_type = password
project_domain_name = default
user_domain_name = default
region_name = RegionOne
project_name = service
username = neutron
password = NEUTRON_PASS
service_metadata_proxy = True
metadata_proxy_shared_secret = METADATA_SECRET
2.5完成安裝
2.5.1 Populate the database:
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
2.5.2重新開機計算API服務
service nova-api restart
2.5.3 重新開機網絡服務
service neutron-server restart
service neutron-linuxbridge-agent restart
service neutron-dhcp-agent restart
service neutron-metadata-agent restart
3.計算節點部署(10.10.80.181)
3.1安裝元件
apt-get install neutron-linuxbridge-agent
3.2配置通用元件
編輯配置檔案/etc/neutron/neutron.conf
-
1.在[database]部分
注釋掉所有“connection”選項,因為計算節點不直接通路資料庫。
-
2.在[DEFAULT]和 [oslo_messaging_rabbit]部分
配置RabbitMQ 消息隊列接口,RABBIT_PASS用rabbit使用者的密碼123456替代
[DEFAULT]
...
rpc_backend = rabbit
[oslo_messaging_rabbit]
...
rabbit_host = controller
rabbit_userid = openstack
rabbit_password = RABBIT_PASS
-
3.在[DEFAULT] 和[keystone_authtoken]的部配置設定置身份認證
NEUTRON_PASS用123456替代。需要移除keystone_authtoken中除了下列參數以外的選項。
[DEFAULT]
...
auth_strategy = keystone
[keystone_authtoken]
...
auth_uri = http://controller:
auth_url = http://controller:
memcached_servers = controller:
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = neutron
password = NEUTRON_PASS
3.3配置網絡選項
配置/etc/neutron/plugins/ml2/linuxbridge_agent.ini
-
1.在[linux_bridge]配置實體網絡接口
PROVIDER_INTERFACE_NAME用實體網絡接口eth0替代
[linux_bridge]
physical_interface_mappings = provider:PROVIDER_INTERFACE_NAME
- 2.在[vxlan]部分,禁用vxlan
[vxlan]
enable_vxlan = False
- 3.在[securitygroup]部配置設定置防火牆
[securitygroup]
...
enable_security_group = True
firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
3.4配置計算服務來使用網絡
編輯檔案/etc/nova/nova.conf
-
1.在[neutron]中配置參數
NEUTRON_PASS用neutron密碼123456替代。
[neutron]
url = http://controller:
auth_url = http://controller:
auth_type = password
project_domain_name = default
user_domain_name = default
region_name = RegionOne
project_name = service
username = neutron
password = NEUTRON_PASS
3.5重新開機服務
- 1.重新開機計算服務
service nova-compute restart
- 2.重新開機網絡代理
service neutron-linuxbridge-agent restart
4.驗證操作
source環境變量,在/root目錄下執行 (該腳本在openstack部署3——keystone安裝中第六部分建立openstack安裝部署3——keystone安裝(僅部署在控制節點)
. admin-openrc
4.1 驗證neutron-server
neutron ext-list
4.2 驗證neturon代理正确性
neutron agent-list
輸出節點應該包含在控制節點上有三個代理,在每一個計算節點上有一個代理: