天天看點

openstack學習三-虛拟機上手工最小化安裝stein(7)neutron控制、計算節點

Neutron元件管理OpenStack環境中虛拟網絡基礎架構(VNI)的所有網絡以及實體網絡基礎架構(PNI)的通路層。OpenStack Networking使項目能夠建立進階虛拟網絡拓撲,其中包括防火牆,負載均衡器和虛拟專用網絡(VPN)等服務。

OpenStack通過Neutron提供網絡,子網和路由器作為對象執行個體。每個執行個體都具有模仿實體對象的功能:VPC包含子網,VPC路由器可以在不同子網之間路由流量。網絡設定中至少有一個外部網絡。外部網絡不僅是一個虛拟定義的網絡。它代表在OpenStack安裝之外可通路的實體外部網絡。VM通過OpenStack外部網絡可以通路實際實體網絡上的IP位址。除了外部網絡,任何網絡設定都有一個或多個内部網絡。這些SDN網絡直接連接配接到VM。隻有内部網絡上的VM才能直接通路連接配接到該網絡的其它VM。

對于外部網絡通路VM,需要外部與内部網絡之間的虛拟路由器實作。每個虛拟路由器都有一個連接配接到外部網絡的網關和一個連接配接到内部網絡的一個或多個接口。與實體路由器一樣,子網可以通路連接配接到同一路由器的其他子網上的計算機,并且計算機可以通過虛拟路由器的網關通路外部網絡。

VPC網絡還支援安全組。安全組使管理者能夠在組中定義防火牆規則。VM可以屬于一個或多個安全組,并且Networking應用這些安全組中的規則來阻止或取消阻止該VM的端口,端口範圍或流量類型,比如在安全組中阻止ICMP流量通信,允許外部網絡通路内部80端口等政策都可以設定在安全組中。

Neutron使用的每個插件都有自己的概念。雖然對操作VNI和OpenStack環境并不重要,但了解這些概念可以幫助您設定網絡。所有網絡安裝都使用核心插件和安全組插件(或僅使用No-Op安全組插件)。此外,還提供防火牆即服務(FWaaS)和負載平衡器即服務(LBaaS)插件,這些插件都需要單獨安裝配置。

總結一下、neutron功能非常強大,提供fwaas、lbaas、安全組、dhcp等非常多的功能,這些功能需要單獨安裝插件實作,neutron需要通過rabbitmq元件與nova進行互動,需要與keystone元件進行互動,需要在控制節點與計算節點節點上均安裝不同類型的neutron軟體。

您可以使用TYPEI和TYPEII兩種體系結構之一來安裝部署neutron網絡服務。

TYPEI部署采用最簡單架構,僅支援将執行個體附加到(外部)網絡。沒有VPC網絡,路由器或浮動IP位址。隻有該

admin

特權使用者或其他特權使用者才能管理提供商網絡。

TYPEII部署支援将執行個體附加到自助服務網絡的第3層服務來增強TYPEI。該選項下支援非特權使用者可以管理自助服務網絡,包括提供自助服務和提供商網絡之間連接配接的路由器。此外,浮動IP位址提供與使用來自外部網絡(如Internet)的自助服務網絡的執行個體的連接配接。

自助服務網絡通常使用VXLAN網絡。覆寫網絡協定包括額外的報頭,這些報頭增加了開銷并減少了有效載荷或使用者資料的可用空間。在不了解虛拟網絡基礎結構的情況下,執行個體嘗試使用1500位元組的預設以太網最大傳輸單元(MTU)來發送分組。Networking服務自動通過DHCP為執行個體提供正确的MTU值。但是,某些雲映像不使用DHCP或忽略DHCP MTU選項,并且需要使用中繼資料或腳本進行配置。

一、注冊使用者、服務、endpoint

openstack user create --domain default --password-prompt neutron

openstack學習三-虛拟機上手工最小化安裝stein(7)neutron控制、計算節點

将neutron使用者添加admin角色通路service項目

openstack role add --project service --user neutron admin

在openstack上建立neutron服務

openstack service create --name neutron --description "OpenStack Networking" network

openstack學習三-虛拟機上手工最小化安裝stein(7)neutron控制、計算節點

在neutron服務下注冊internal、public、admin三項endpoint

openstack endpoint create --region RegionOne network public http://controller:9696

openstack endpoint create --region RegionOne network internal http://controller:9696

openstack endpoint create --region RegionOne network admin http://controller:9696

openstack學習三-虛拟機上手工最小化安裝stein(7)neutron控制、計算節點

二、添加防火牆允許端口

firewall-cmd --add-port=9696/tcp --permanent && firewall-cmd --reload

三、修改neutron配置檔案

vi /etc/neutron/neutron.conf

# create new

[DEFAULT]

core_plugin = ml2

service_plugins = router

auth_strategy = keystone

state_path = /var/lib/neutron

dhcp_agent_notification = True

allow_overlapping_ips = True

notify_nova_on_port_status_changes = True

# create new

[DEFAULT]

core_plugin = ml2

service_plugins = router

auth_strategy = keystone

state_path = /var/lib/neutron

dhcp_agent_notification = True

allow_overlapping_ips = True

notify_nova_on_port_status_changes = True

notify_nova_on_port_data_changes = True

# RabbitMQ connection info

transport_url = rabbit://openstack:[email protected]

# Keystone auth info

[keystone_authtoken]

www_authenticate_uri = http://controller:5000

auth_url = http://controller:5000

memcached_servers = controller:11211

auth_type = password

project_domain_name = default

user_domain_name = default

project_name = service

username = neutron

password = neutron

# MariaDB connection info

[database]

connection = mysql+pymysql://neutron:[email protected]/neutron

# Nova connection info

[nova]

auth_url = http://controller:5000

auth_type = password

project_domain_name = default

user_domain_name = default

region_name = RegionOne

project_name = service

username = nova

password = nova

[oslo_concurrency]

lock_path = $state_path/tmp

四、配置Layer 2 (ML2) plug-in子產品

ML2插件使用Linux橋接機制為執行個體建構第2層(橋接和交換)虛拟網絡基礎架構。

vi 

/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]

    部分中,啟用Linux橋和第2層填充機制:
    [ml2]
    mechanism_drivers = linuxbridge,l2population
               
  • 在該

    [ml2]

    部分中,啟用端口安全性擴充驅動程式:
    [ml2]
    extension_drivers = port_security
               
  • 在該

    [ml2_type_flat]

    部分中,将提供商虛拟網絡配置為扁平網絡:
    [ml2_type_flat]
    flat_networks = provider
               
  • 在該

    [ml2_type_vxlan]

    部分中,為自助服務網絡配置VXLAN網絡辨別符範圍:
    [ml2_type_vxlan]
    vni_ranges = 1:1000
               
  • 在該

    [securitygroup]

    部分中,啟用ipset以提高安全組規則的效率:
    [securitygroup]
    enable_ipset = true
               
openstack學習三-虛拟機上手工最小化安裝stein(7)neutron控制、計算節點

五、配置linux橋代理

Linux網橋代理為執行個體建構第2層(橋接和交換)虛拟網絡基礎架構并處理安全組。

  • 編輯

    /etc/neutron/plugins/ml2/linuxbridge_agent.ini

    檔案并完成以下操作:
    • 在該

      [linux_bridge]

      部分中,将提供者虛拟網絡映射到提供者實體網絡接口:
      [linux_bridge]
      physical_interface_mappings = provider:PROVIDER_INTERFACE_NAME
                 
openstack學習三-虛拟機上手工最小化安裝stein(7)neutron控制、計算節點

替換

PROVIDER_INTERFACE_NAME

為基礎提供程式實體網絡接口ens192

[linux_bridge]

               physical_interface_mappings = provider:ens192

  • 在該

    [vxlan]

    部分中,啟用VXLAN重疊網絡,配置處理覆寫網絡的實體網絡接口的IP位址,并啟用第2層填充:
    [vxlan]
    enable_vxlan = true
    local_ip = 10.37.6.23
    l2_population = true
               
    在該

    [securitygroup]

    部分中,啟用安全組并配置Linux網橋iptables防火牆驅動程式:
  • [securitygroup]
    enable_security_group = true
    firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
               
  • 通過驗證以下所有

    sysctl

    值都設定為

    1

    :確定您的Linux作業系統核心支援網橋過濾器:
    net.bridge.bridge-nf-call-iptables
    net.bridge.bridge-nf-call-ip6tables
               
  • 彙總配置資訊如下

[linux_bridge]

physical_interface_mappings = provider:ens192

[vxlan]

enable_vxlan = true

local_ip = 10.37.6.23

l2_population = true

[securitygroup]

enable_security_group = true

firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver

六、配置三層服務代理

第3層(L3)代理為自助服務虛拟網絡提供路由和NAT服務。

  • 編輯

    /etc/neutron/l3_agent.ini

    檔案并完成以下操作:
    • 在本

      [DEFAULT]

      節中,配置Linux橋接接口驅動程式和外部網橋:
      [DEFAULT]
      interface_driver = linuxbridge
                 

七、配置DHCP代理

DHCP代理為虛拟網絡提供DHCP服務。

  • 編輯

    /etc/neutron/dhcp_agent.ini

    檔案并完成以下操作:
    • 在本

      [DEFAULT]

      節中,配置Linux橋接接口驅動程式,Dnsmasq 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_host = controller
      metadata_proxy_shared_secret = metadatapassword
                 

九、配置Nova服務以使用Neutron服務

編輯

/etc/nova/nova.conf

檔案并執行以下操作:

  • 在該

    [neutron]

    部分中,配置通路參數,啟用中繼資料代理并配置密碼:
    [neutron]
    url = http://controller:9696
    auth_url = http://controller:5000
    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 = metadatapassword
               

十、建立軟連接配接同步資料庫

  1. 網絡服務初始化腳本需要一個

    /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
               
  2. 填充資料庫:
    # 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
               
openstack學習三-虛拟機上手工最小化安裝stein(7)neutron控制、計算節點
openstack學習三-虛拟機上手工最小化安裝stein(7)neutron控制、計算節點

驗證資料庫是否同步成功

openstack學習三-虛拟機上手工最小化安裝stein(7)neutron控制、計算節點

十一、重新啟動Compute API服務:

systemctl restart openstack-nova-api.service
           

十二、啟動網絡服務并将其配置為在系統引導時啟動

# systemctl enable neutron-server.service \
  neutron-linuxbridge-agent.service neutron-dhcp-agent.service \
  neutron-metadata-agent.service
# systemctl start neutron-server.service \
  neutron-linuxbridge-agent.service neutron-dhcp-agent.service \
  neutron-metadata-agent.service
# systemctl enable neutron-l3-agent.service
# systemctl start neutron-l3-agent.service
           

第二部分

計算節點處理VM執行個體的連接配接和安全組。

一、安裝計算節點neutron元件

yum install openstack-neutron-linuxbridge ebtables ipset -y
           

二、配置neutron配置檔案

  • 編輯

    /etc/neutron/neutron.conf

    檔案并完成以下操作:
    • 在該

      [database]

      部分中,注釋掉任何

      connection

      選項,因為計算節點不直接通路資料庫。
    • 在該

      [DEFAULT]

      部分中,配置

      RabbitMQ

       消息隊列通路:
      [DEFAULT]
      transport_url = rabbit://openstack:[email protected]
                 
      替換

      RABBIT_PASS

      為您

      openstack

       在RabbitMQ中為帳戶選擇的密碼。
    • [DEFAULT]

      [keystone_authtoken]

      部分中,配置身份服務通路:
      [DEFAULT]
      auth_strategy = keystone
      
      [keystone_authtoken]
      www_authenticate_uri = http://controller:5000
      auth_url = http://controller:5000
      memcached_servers = controller:11211
      auth_type = password
      project_domain_name = default
      user_domain_name = default
      project_name = service
      username = neutron
      password = neutron
                 
      在該

      [oslo_concurrency]

      部分中,配置鎖定路徑:
  • [oslo_concurrency]
    lock_path = /var/lib/neutron/tmp
               

三、配置TYPEII網絡選項服務

Linux網橋代理為執行個體建構第2層(橋接和交換)虛拟網絡基礎架構并處理安全組。

  • 編輯

    /etc/neutron/plugins/ml2/linuxbridge_agent.ini

    檔案并完成以下操作:
    • 在該

      [linux_bridge]

      部分中,将提供者虛拟網絡映射到提供者實體網絡接口:
      [linux_bridge]
      physical_interface_mappings = provider:PROVIDER_INTERFACE_NAME
      
      替換         PROVIDER_INTERFACE_NAME為基礎提供程式實體網絡接口的名稱ens192
                 
    • [linux_bridge]
    • physical_interface_mappings = provider:ens192
    • 在該

      [vxlan]

      部分中,啟用VXLAN重疊網絡,配置處理覆寫網絡的實體網絡接口的IP位址,并啟用第2層填充:
      [vxlan]
      enable_vxlan = true
      local_ip = 10.37.6.24
      l2_population = true
                 
      在該

      [securitygroup]

      部分中,啟用安全組并配置Linux網橋iptables防火牆驅動程式:
    • [securitygroup]
      enable_security_group = true
      firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
                 
    • 通過驗證以下所有

      sysctl

      值都設定為

      1

      :確定您的Linux作業系統核心支援網橋過濾器:
      net.bridge.bridge-nf-call-iptables
      net.bridge.bridge-nf-call-ip6tables
                 

四、配置Nova服務以使用neutron服務

編輯

/etc/nova/nova.conf

檔案并完成以下操作:

  • 在該

    [neutron]

    部分中,配置通路參數:
    [neutron]
    url = http://controller:9696
    auth_url = http://controller:5000
    auth_type = password
    project_domain_name = default
    user_domain_name = default
    region_name = RegionOne
    project_name = service
    username = neutron
    password = neutron
    
               

五、完成安裝啟動服務

  1. 重新啟動Compute服務:
    # systemctl restart openstack-nova-compute.service
               
  2. 啟動Linux網橋代理并将其配置為在系統引導時啟動:
    # systemctl enable neutron-linuxbridge-agent.service
    # systemctl start neutron-linuxbridge-agent.service
               

繼續閱讀