一.openstack網絡服務neutron
1.1neutron介紹
neutron是openstack重要組件之一,在以前是時候沒有neutron項目,早期的時候是沒有neutron,早期所使用的網絡的nova-network,經過版本改變才有neutron。
OpenStack的網絡(Neutron),可以創建和附加其他的OpenStack服務,網絡管理接口設備。插件可以被實現,以適應不同的網絡設備和軟件,提供靈活性,以開棧架構和部署。
OpenStack的網絡(Neutron)管理虛擬網絡基礎架構(VNI),並在您的OpenStack的環境中的物理網絡基礎架構(PNI)的接入層方面的所有網絡方面。開棧網絡允許租戶創建高級的虛擬網絡拓撲可包括服務,例如防火牆,負載均衡器,和虛擬專用網(VPN)。
1.1.1Openstack Networking
- 網絡:在實際的物理環境下,我們使用交換機或者集線器把多個計算機連接起來形成了網絡。在neutron的世界里,網絡也是將多個不同的雲主機連起來。
- 子網:在十幾的物理環境下,在一個網絡中,我們可以講網絡划分成多位邏輯子網。在neutron世界里,子網也是隸屬於網絡下的。
- 端口:是十幾的物理環境下,每個子網或者每個網絡,都有很多的端口,比如交換機端口來供計算機連接。在neutron的世界里,端口也是隸屬於自往下,雲主機的網卡會對應到一個端口上。
- 路由器:在實際的網絡羅環境下,不同網絡或者不同邏輯子網之間如果需要進行通信,需要通過路由器進行路由。在neutron的世界里實際路由也是這個作用,用來連接不同的網絡或者子網。
1.2neutron環境准備(控制節點)
1.2.1安裝neutron包
1 #安裝neutron,openstack的網絡服務 2 [root@linux-node1 ~]# yum install -y \ 3 openstack-neutron \ 4 openstack-neutron-ml2 \ 5 openstack-neutron-linuxbridge \ 6 ebtables
1.2.2創建庫及用戶
1 #創建neutron庫 2 MariaDB [(none)]> create database neutron; 3 Query OK, 1 row affected (0.01 sec) 4 #創建neutron用戶並授權 5 MariaDB [(none)]> grant all privileges on neutron.* to 'neutron'@'%' identified by 'neutron'; 6 Query OK, 0 rows affected (0.00 sec) 7 MariaDB [(none)]> grant all privileges on neutron.* to 'neutron'@'localhost' identified by 'neutron'; 8 Query OK, 0 rows affected (0.00 sec)
1.2.3編輯neutron控制節點配置文件
1 #編輯配置文件 2 [root@linux-node1 ~]# vim /etc/neutron/neutron.conf 3 #neutron連接數據庫配置 4 connection = mysql+pymysql://neutron:neutron@192.168.56.11/neutron 5 #開啟keystone認證,打開注釋 6 auth_strategy = keystone 7 #使用ml2插件 8 core_plugin = ml2 9 #禁用其它插件 10 service_plugins = 11 #配置neutron連接keystone 12 auth_uri = http://192.168.56.11:5000 13 auth_url = http://192.168.56.11:35357 14 memcached_servers = 192.168.56.11:11211 15 auth_type = password 16 project_domain_name = default 17 user_domain_name = default 18 project_name = service 19 username = neutron 20 password = neutron 21 #neutron連接消息隊列 22 transport_url = rabbit://openstack:openstack@192.168.56.11 23 #配置網絡服務來通知計算節點的網絡拓撲變化 24 notify_nova_on_port_status_changes = true 25 notify_nova_on_port_data_changes = true 26 #配置[nova]部分 27 auth_url = http://192.168.56.11:35357 28 auth_type = password 29 project_domain_name = default 30 user_domain_name = default 31 region_name = RegionOne 32 project_name = service 33 username = nova 34 password = nova 35 #鎖文件路徑 36 lock_path = /var/lib/neutron/tmp
1.2.4配置網絡選項
您可以部署網絡服務使用選項1和選項2兩種架構中的一種來部署網絡服務。
選項1:采用盡可能簡單的架構進行部署,只支持實例連接到公有網絡(外部網絡)。沒有私有網絡(個人網絡),路由器以及浮動IP地址。只有``admin``或者其他特權用戶才可以管理公有網絡
選項2:在選項1的基礎上多了layer-3服務,支持實例連接到私有網絡。``demo``或者其他沒有特權的用戶可以管理自己的私有網絡,包含連接公網和私網的路由器。另外,浮動IP地址可以讓實例使用私有網絡連接到外部網絡,例如互聯網
典型的私有網絡一般使用覆蓋網絡。覆蓋網絡,例如VXLAN包含了額外的數據頭,這些數據頭增加了開銷,減少了有效內容和用戶數據的可用空間。在不了解虛擬網絡架構的情況下,實例嘗試用以太網 最大傳輸單元 (MTU) 1500字節發送數據包。網絡服務會自動給實例提供正確的MTU的值通過DHCP的方式。但是,一些雲鏡像並沒有使用DHCP或者忽視了DHCP MTU選項,要求使用元數據或者腳本來進行配置
網絡選項2:自服務網絡(vxlan浮動IP模式)
-
配置 Modular Layer 2 (ML2) 插件
ML2插件使用Linuxbridge機制來為實例創建layer-2虛擬網絡基礎設施
1 #編輯ml2配置文件 2 [root@linux-node1 ~]# vim /etc/neutron/plugins/ml2/ml2_conf.ini 3 #在ml2下添加內容 4 [ml2] 5 #啟用flat和VLAN網絡 6 type_drivers = flat,vlan,gre,vxlan,geneve 7 #禁用私有網絡 8 tenant_network_types = flat,vlan,gre,vxlan,geneve 9 #啟用linuxbridge 10 mechanism_drivers = linuxbridge 11 #啟用端口安全擴展 12 extension_drivers = port_security 13 #在ml2_type_flat配置 14 [ml2_type_flat] 15 #配置公共虛擬網絡名字 16 flat_networks = public 17 #在securitygroup配置 18 [securitygroup] 19 #啟用ipset 20 enable_ipset = true
-
配置Linuxbridge代理
1 #編輯linuxbridge配置文件 2 [root@linux-node1 ~]# vim /etc/neutron/plugins/ml2/linuxbridge_agent.ini 3 #在linux_bridge下配置 4 [linux_bridge] 5 #映射虛擬網絡接口和物理接口 6 physical_interface_mappings = public:eth0 7 #在vxlan下配置 8 [vxlan] 9 #禁止vxlan覆蓋網絡 10 enable_vxlan = false 11 #在securitygroup下配置 12 [securitygroup] 13 #啟用安全組 14 enable_security_group = true 15 #配置linux橋接防火牆驅動 16 firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
-
配置DHCP代理
1 #編輯dhcp配置文件 2 [root@linux-node1 ~]# vim /etc/neutron/dhcp_agent.ini 3 #配置linuxbridge接口驅動 4 interface_driver = neutron.agent.linux.interface.BridgeInterfaceDriver 5 #DHCP驅動 6 dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq 7 #啟用隔離元數據 8 enable_isolated_metadata = True
-
配置元數據代理
1 #修改metadata配置文件 2 [root@linux-node1 ~]# vim /etc/neutron/metadata_agent.ini 3 #元數據主機IP 4 nova_metadata_ip = 192.168.56.11 5 #配置共享密碼 6 metadata_proxy_shared_secret = metadata
-
在nova配置文件里配置nuetron
1 #修改nova配置文件 2 [root@linux-node1 ~]# vim /etc/nova/nova.conf 3 #在neutron標簽下配置 4 [neutron] 5 url = http://192.168.56.11:9696 6 auth_url = http://192.168.56.11:35357 7 auth_type = password 8 project_domain_name = default 9 user_domain_name = default 10 region_name = RegionOne 11 project_name = service 12 username = neutron 13 password = neutron 14 service_metadata_proxy = True 15 #上文配置的共享密碼 16 metadata_proxy_shared_secret = metadata
注:網絡服務初始化腳本需要一個超鏈接 /etc/neutron/plugin.ini``指向ML2插件配置文件/etc/neutron/plugins/ml2
1 [root@linux-node1 ~]# ln -s /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.ini
1.2.5將數據導入數據庫
1 [root@linux-node1 ~]# su -s /bin/sh -c "neutron-db-manage --config-file /etc/neutron/neutron.conf \ 2 --config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade head" neutron
1.2.6創建端點及實體服務
1 #創建neutron實體服務 2 [root@linux-node1 ~]# openstack service create --name neutron \ 3 --description "OpenStack Networking" network 4 #創建neutron端點 5 [root@linux-node1 ~]# openstack endpoint create --region RegionOne \ 6 network public http://192.168.56.11:9696 7 [root@linux-node1 ~]# openstack endpoint create --region RegionOne \ 8 network internal http://192.168.56.11:9696 9 [root@linux-node1 ~]# openstack endpoint create --region RegionOne \ 10 network admin http://192.168.56.11:9696
1.2.7啟動neutron服務
1 #重啟nova-api服務 2 [root@linux-node1 ~]# systemctl restart openstack-nova-api.service 3 #允許開機自啟 4 [root@linux-node1 ~]# systemctl enable neutron-server.service \ 5 neutron-linuxbridge-agent.service neutron-dhcp-agent.service \ 6 neutron-metadata-agent.service 7 #啟動neutron及其插件服務 8 [root@linux-node1 ~]# systemctl start neutron-server.service \ 9 neutron-linuxbridge-agent.service neutron-dhcp-agent.service \ 10 neutron-metadata-agent.service
1.2.8檢查服務
1 [root@linux-node1 ~]# neutron agent-list
+--------------------------------------+--------------------+-------------------------+-------------------+-------+----------------+---------------------------+
| id | agent_type | host | availability_zone | alive | admin_state_up | binary |
+--------------------------------------+--------------------+-------------------------+-------------------+-------+----------------+---------------------------+
| 09179e20-de5a-46c8-8653-892d8c4e6ffb | Linux bridge agent | linux-node1.example.com | | :-) | True | neutron-linuxbridge-agent |
| 62658264-8d5e-42ba-ac9c-95dc52e102ec | DHCP agent | linux-node1.example.com | nova | :-) | True | neutron-dhcp-agent |
| c63619f7-0ed9-4833-88f4-4ae0422a9214 | Metadata agent | linux-node1.example.com | | :-) | True | neutron-metadata-agent |
+--------------------------------------+--------------------+-------------------------+-------------------+-------+----------------+---------------------------+
看到標紅的三個笑臉,則證明neutron控制節點的服務啟動正常
二.neutron計算節點配置
2.1計算節點neutron環境准備
2.1.1安裝neutron包
1 [root@linux-node2 ~]# yum install openstack-neutron-linuxbridge ebtables ipset -y
2.1.2修改neutron配置文件
1 #編輯計算節點neutron配置文件 2 [root@linux-node2 ~]# vim /etc/neutron/neutron.conf 3 #連接消息隊列配置 4 transport_url = rabbit://openstack:openstack@192.168.56.11 5 #開啟keystone認證,打開注釋 6 auth_strategy = keystone 7 #在keystone_authtoken標簽下添加連接keystone配置 8 [keystone_authtoken] 9 auth_uri = http://192.168.56.11:5000 10 auth_url = http://192.168.56.11:35357 11 memcached_servers = 192.168.56.11:11211 12 auth_type = password 13 project_domain_name = default 14 user_domain_name = default 15 project_name = service 16 username = neutron 17 password = neutron 18 #鎖路徑 19 lock_path = /var/lib/neutron/tmp
2.1.3配置網絡選項
注:如果控制節點選的是,網絡選項1,則此處也選擇網絡選項1.
網絡選項2:自服務網絡
-
配置 Modular Layer 2 (ML2) 插件
1 #因為計算節點此文件和控制節點相同只需要拷貝即可 2 [root@linux-node1 ~]# scp /etc/neutron/plugins/ml2/linuxbridge_agent.ini 192.168.56.12:/etc/neutron/plugins/ml2/
-
在nova配置文件中配置neutron
1 #修改nova配置文件 2 [root@linux-node2 ~]# vim /etc/nova/nova.conf 3 #在neutron標簽下添加內容 4 [neutron] 5 url = http://192.168.56.11:9696 6 auth_url = http://192.168.56.11:35357 7 auth_type = password 8 project_domain_name = default 9 user_domain_name = default 10 region_name = RegionOne 11 project_name = service 12 username = neutron 13 password = neutron
2.1.4啟動neutron服務
1 #重啟nova服務 2 [root@linux-node2 ~]# systemctl restart openstack-nova-compute.service 3 #允許neutron開機自啟 4 [root@linux-node2 ~]# systemctl enable neutron-linuxbridge-agent.service 5 #啟動neutron服務 6 [root@linux-node2 ~]# systemctl start neutron-linuxbridge-agent.service
2.1.5檢查服務
1 #檢查網絡服務 2 [root@linux-node1 ~]# neutron agent-list
+--------------------------------------+--------------------+-------------------------+-------------------+-------+----------------+---------------------------+
| id | agent_type | host | availability_zone | alive | admin_state_up | binary |
+--------------------------------------+--------------------+-------------------------+-------------------+-------+----------------+---------------------------+
| 09179e20-de5a-46c8-8653-892d8c4e6ffb | Linux bridge agent | linux-node1.example.com | | :-) | True | neutron-linuxbridge-agent |
| 62658264-8d5e-42ba-ac9c-95dc52e102ec | DHCP agent | linux-node1.example.com | nova | :-) | True | neutron-dhcp-agent |
| 9600eb37-fce4-476f-bc31-fe7031309f04 | Linux bridge agent | linux-node2.example.com | | :-) | True | neutron-linuxbridge-agent |
| c63619f7-0ed9-4833-88f4-4ae0422a9214 | Metadata agent | linux-node1.example.com | | :-) | True | neutron-metadata-agent |
+--------------------------------------+--------------------+-------------------------+-------------------+-------+----------------+---------------------------+ 3 #檢查計算服務 4 [root@linux-node1 ~]# nova service-list
+----+------------------+-------------------------+----------+---------+-------+----------------------------+-----------------+
| Id | Binary | Host | Zone | Status | State | Updated_at | Disabled Reason |
+----+------------------+-------------------------+----------+---------+-------+----------------------------+-----------------+
| 1 | nova-consoleauth | linux-node1.example.com | internal | enabled | up | 2017-02-27T06:33:10.000000 | - |
| 2 | nova-conductor | linux-node1.example.com | internal | enabled | up | 2017-02-27T06:33:17.000000 | - |
| 3 | nova-scheduler | linux-node1.example.com | internal | enabled | up | 2017-02-27T06:33:10.000000 | - |
| 6 | nova-compute | linux-node2.example.com | nova | enabled | up | 2017-02-27T06:33:16.000000 | - |
+----+------------------+-------------------------+----------+---------+-------+----------------------------+-----------------+
【開源是一種精神,分享是一種美德】
— By GoodCook
— 筆者QQ:253097001
— 歡迎大家隨時來交流
—原創作品,允許轉載,轉載時請務必以超鏈接形式標明文章 原始出處 、作者信息和本聲明。否則將追究法律責任。
