OpenStack安裝流程(juno版)- 添加網絡服務(neutron)

在controller節點上安裝和配置

建立nova的數據庫,服務證書和API端點

  1. 建立數據庫:
    使用root身份進入數據庫:
    $ mysql -u root -p

    建立nova數據庫:
    <pre>CREATE DATABASE neutron;</pre>python

    把neutron數據庫的訪問權限賦予名爲neutron,來自任何主機地址的用戶,並設定訪問密碼爲NEUTRON_DBPASS(替換爲合適的密碼):
    <pre>GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'localhost' IDENTIFIED BY 'NEUTRON_DBPASS';mysql

GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'%' IDENTIFIED BY 'NEUTRON_DBPASS';</pre>linux

退出數據庫。sql

  1. 啓動admin證書:
    $ source admin-openrc.sh
  2. 建立服務證書:
    建立neutron用戶:
    <pre>$ keystone user-create --name neutron --pass NEUTRON_PASS
Property Value
email
enabled True
id 03fdaa93a85b4879a898d031947b81af
name neutron
username neutron

+----------+----------------------------------+</pre>
用合適的密碼代替NEUTRON_PASS。數據庫

admin角色賦予給neutron用戶:
$ keystone user-role-add --user neutron --tenant service --role admin
這條命令不產生輸出顯示。api

建立neutron服務實體:
<pre>$ keystone service-create --name neutron --type network \網絡

--description "OpenStack Networking"
Property Value
description OpenStack Networking
enabled True
id d3cf8211db414c069701f39e778d9765
name neutron
type network

+-------------+----------------------------------+</pre>app

  1. 建立網絡服務的API端點:
    <pre>$ keystone endpoint-create \

--service-id $(keystone service-list | awk '/ network / {print $2}') \
--publicurl http://controller:9696 \
--adminurl http://controller:9696 \
--internalurl http://controller:9696 \框架

--region regionOne
Property Value
adminurl http://controller:9696
id eb7fd6b67e4d4479886d164486a3fb71
internalurl http://controller:9696
publicurl http://controller:9696
region regionOne
service_id d3cf8211db414c069701f39e778d9765

+-------------+----------------------------------+</pre>curl

安裝neutron組件

# apt-get install neutron-server neutron-plugin-ml2 python-neutronclient

配置網絡服務組件

編輯# vi /etc/neutron/neutron.conf文件:
[database]部分,設定數據庫的訪問選項,需把原始設定註釋掉:
<pre>[database]
...
connection = mysql://neutron:NEUTRON_DBPASS@controller/neutron
</pre>
NEUTRON_DBPASS爲建立neutron數據庫時設立的密碼。

[DEFAULT]部分,設定RabbitMQ的訪問選項:
<pre>[DEFAULT]
...
rpc_backend = rabbit
rabbit_host = controller
rabbit_password = RABBIT_PASS
</pre>
RABBIT_PASS爲RabbitMQ guest帳戶的密碼。

[DEFAULT][keystone_authtoken]部分,設定認證服務的訪問選項:
<pre>[DEFAULT]
...
auth_strategy = keystone
</pre>
<pre>[keystone_authtoken]
...
auth_uri = http://controller:5000/v2.0
identity_uri = http://controller:35357
admin_tenant_name = service
admin_user = neutron
admin_password = NEUTRON_PASS
</pre>
NEUTRON_PASS爲建立neutron用戶時使用的密碼。在[keystone_authtoken]部分,註釋掉 auth_host,auth_port,和auth_protocol的選項,由於identity_uri選項是直接代替它們的。

[DEFAULT]部分,開啓Modular Layer 2(ML2)plug-in選項,設定router service和overlapping IP addresses選項:
<pre>[DEFAULT]
...
core_plugin = ml2
service_plugins = router
allow_overlapping_ips = True
</pre>

[DEFAULT]部分,設定網絡服務能夠通知計算服務網絡拓撲的變化:
<pre>[DEFAULT]
...
notify_nova_on_port_status_changes = True
notify_nova_on_port_data_changes = True
nova_url = http://controller:8774/v2
nova_admin_auth_url = http://controller:35357/v2.0
nova_region_name = regionOne
nova_admin_username = nova
nova_admin_tenant_id = SERVICE_TENANT_ID
nova_admin_password = NOVA_PASS
</pre>
NEUTRON_PASS爲建立neutron用戶時使用的密碼。SERVICE_TENANT_ID爲認證服務中service租戶的ID,能夠經過如下命令取得:
<pre>$ source admin-openrc.sh

$ keystone tenant-get service
Property Value
description Service Tenant
enabled True
id 5ab4d5c513f543cfbf8e3be97f5df5fb
name service

+-------------+----------------------------------+</pre>

[DEFAULT]部分,開啓「詳細輸出日誌」選項:
<pre>[DEFAULT]
...
verbose = True
</pre>

配置 Modular Layer 2(ML2)plug-in

ML2 plug-in使用Open vSwitch(OVS)機制(agent)來建立虛擬網絡框架。因爲controller節點不處理實例之間的網絡通訊,故不須要OVS組件。

編輯# vi /etc/neutron/plugins/ml2/ml2_conf.ini文件:

[ml2]部分,啓用flat和generic routing encapsulation(GRE)網絡類型的驅動( network type drivers),GRE 租戶網絡和OVS機制的驅動:
<pre>[ml2]
...
type_drivers = flat,gre
tenant_network_types = gre
mechanism_drivers = openvswitch
</pre>

[ml2_type_gre]部分,配置tunnel ID的範圍:
<pre>[ml2_type_gre]
...
tunnel_id_ranges = 1:1000
</pre>

[securitygroup]部分,啓用security groups,ipset, and configure,設定OVS iptables firewall driver:
<pre>[securitygroup]
...
enable_security_group = True
enable_ipset = True
firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver
</pre>

配置計算服務使之使用網絡服務

編輯# vi /etc/nova/nova.conf文件:
[DEFAULT]部分,設定API和驅動:
<pre>[DEFAULT]
...
network_api_class = nova.network.neutronv2.api.API
security_group_api = neutron
linuxnet_interface_driver = nova.network.linux_net.LinuxOVSInterfaceDriver
firewall_driver = nova.virt.firewall.NoopFirewallDriver
</pre>

[neutron]部分,設定訪問參數:
<pre>[neutron]
...
url = http://controller:9696
auth_strategy = keystone
admin_auth_url = http://controller:35357/v2.0
admin_tenant_name = service
admin_username = neutron
admin_password = NEUTRON_PASS
</pre>
NEUTRON_PASS爲建立neutron用戶時使用的密碼。

完成安裝

  1. 同步數據庫:
    # neutron-db-manage --config-file /etc/neutron/neutron.conf --config-file /etc/neutron/plugins/ml2/ml2_conf.ini upgrade juno
  2. 重啓計算服務:
    # service nova-api restart
    # service nova-scheduler restart
    # service nova-conductor restart
  3. 重啓網絡服務:
    # service neutron-server restart

驗證操做

  1. 啓動admin證書:
    $ source admin-openrc.sh
  2. 顯示裝載的擴展列表,驗證neutron-server進程已成功啓動:
    <pre>$ neutron ext-list
alias name
security-group security-group
l3_agent_scheduler L3 Agent Scheduler
ext-gw-mode Neutron L3 Configurable external gateway mode
binding Port Binding
provider Provider Network
agent agent
quotas Quota management support
dhcp_agent_scheduler DHCP Agent Scheduler
l3-ha HA Router extension
multi-provider Multi Provider Network
external-net Neutron external network
router Neutron L3 Router
allowed-address-pairs Allowed Address Pairs
extraroute Neutron Extra Route
extra_dhcp_opt Neutron Extra DHCP opts
dvr Distributed Virtual Router

+-----------------------+-----------------------------------------------+</pre>

在network節點上安裝和配置

設定kernel networking參數:

  1. 編輯# vi /etc/sysctl.conf文件:

<pre>net.ipv4.ip_forward=1
net.ipv4.conf.all.rp_filter=0
net.ipv4.conf.default.rp_filter=0
</pre>

  1. 使上述變化生效:

# sysctl -p

安裝網絡服務組件

# apt-get install neutron-plugin-ml2 neutron-plugin-openvswitch-agent \
neutron-l3-agent neutron-dhcp-agent

配置網絡服務的通用組件

編輯# vi /etc/neutron/neutron.conf文件:

[database]部分,註釋掉connection選項,由於network節點不須要直接訪問數據庫。

[DEFAULT]部分,設定RabbitMQ的訪問選項:
<pre>[DEFAULT]
...
rpc_backend = rabbit
rabbit_host = controller
rabbit_password = RABBIT_PASS
</pre>
RABBIT_PASS爲RabbitMQ guest帳戶的密碼。

[DEFAULT][keystone_authtoken]部分,設定認證服務的訪問選項:
<pre>[DEFAULT]
...
auth_strategy = keystone
</pre>
<pre>[keystone_authtoken]
...
auth_uri = http://controller:5000/v2.0
identity_uri = http://controller:35357
admin_tenant_name = service
admin_user = neutron
admin_password = NEUTRON_PASS
</pre>
NEUTRON_PASS爲建立neutron用戶時使用的密碼。在[keystone_authtoken]部分,註釋掉 auth_host,auth_port,和auth_protocol的選項,由於identity_uri選項是直接代替它們的。

[DEFAULT]部分,開啓Modular Layer 2(ML2)plug-in選項,設定router service和overlapping IP addresses選項:
<pre>[DEFAULT]
...
core_plugin = ml2
service_plugins = router
allow_overlapping_ips = True
</pre>

[DEFAULT]部分,開啓「詳細輸出日誌」選項:
<pre>[DEFAULT]
...
verbose = True
</pre>

設定Modular Layer 2(ML2)plug-in

編輯# vi /etc/neutron/plugins/ml2/ml2_conf.ini文件:

[ml2]部分,啓用flat和generic routing encapsulation(GRE)網絡類型的驅動( network type drivers),GRE 租戶網絡和OVS機制的驅動:
<pre>[ml2]
...
type_drivers = flat,gre
tenant_network_types = gre
mechanism_drivers = openvswitch
</pre>

[ml2_type_flat]部分,設定external flat provider network:
<pre>[ml2_type_flat]
...
flat_networks = external
</pre>

[ml2_type_gre]部分,設定tunnel ID範圍:
<pre>[ml2_type_gre]
...
tunnel_id_ranges = 1:1000
</pre>

[securitygroup]部分,啓用security groups,ipset, and configure,設定OVS iptables firewall driver:
<pre>[securitygroup]
...
enable_security_group = True
enable_ipset = True
firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver
</pre>

[ovs]部分,啓用tunnel,設定local tunnel endpoint,把external flat provider network和br-ex external network brigde綁定起來:
<pre>[ovs]
...
local_ip = INSTANCE_TUNNELS_INTERFACE_IP_ADDRESS
enable_tunneling = True
bridge_mappings = external:br-ex
</pre>
INSTANCE_TUNNELS_INTERFACE_IP_ADDRESS爲network節點在tunnel network中的IP地址。

[agent]部分,啓用GRE tunnels:
<pre>[agent]
...
tunnel_types = gre
</pre>

設定Layer-3(L3)agent

Layer-3(L3)agent爲虛擬網絡提供了routing service。

編輯# vi /etc/neutron/l3_agent.ini文件:

[DEFAULT]部分,設定驅動,啓用network namespace,設定external network bridge,啓用deletion of defunct router namespaces:
<pre>[DEFAULT]
...
interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver
use_namespaces = True
external_network_bridge = br-ex
router_delete_namespaces = True
</pre>

[DEFAULT]部分,開啓「詳細輸出日誌」選項:
<pre>[DEFAULT]
...
verbose = True
</pre>

設定DHCP agent

DHCP agent爲虛擬網絡提供了DHCP服務。

編輯# vi /etc/neutron/dhcp_agent.ini 文件:

[DEFAULT]部分,設定驅動,啓用namespaces,啓用deletion of defunct DHCP namespaces:
<pre>[DEFAULT]
...
interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver
dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq
use_namespaces = True
dhcp_delete_namespaces = True
</pre>

[DEFAULT]部分,開啓「詳細輸出日誌」選項:
<pre>[DEFAULT]
...
verbose = True
</pre>

設定metadata agent

metadata agent提供了配置信息,好比實例的證書。

  1. 編輯# vi /etc/neutron/metadata_agent.ini文件:

    [DEFAULT]部分,設定訪問參數:
    <pre>[DEFAULT]

...
auth_url = http://controller:5000/v2.0
auth_region = regionOne
admin_tenant_name = service
admin_user = neutron
admin_password = NEUTRON_PASS</pre>
NEUTRON_PASS爲建立neutron用戶時使用的密碼。

[DEFAULT]部分,設定metadata host:
<pre>[DEFAULT]
...
nova_metadata_ip = controller
</pre>

[DEFAULT]部分,設定metadata proxy shared secret:
<pre>[DEFAULT]
...
metadata_proxy_shared_secret = METADATA_SECRET
</pre>
把METADATA_SECRET替換爲合適的密碼。

[DEFAULT]部分,開啓「詳細輸出日誌」選項:
<pre>[DEFAULT]
...
verbose = True
</pre>

  1. 在controller節點,編輯# vi /etc/nova/nova.conf文件:
    [neutron]部分,啓用metadata proxy,設定密碼選項:
    <pre>[neutron]

...
service_metadata_proxy = True
metadata_proxy_shared_secret = METADATA_SECRET</pre>
把METADATA_SECRET替換爲metadata proxy中設定的密碼。

  1. 在controller節點,重啓計算的API服務:
    # service nova-api restart

設定Open vSwitch(OVS)服務:

OVS服務爲實例提供虛擬網絡框架。integration bridge br-int處理內網通訊,external bridge br-ex處理外網通訊。external bridge須要物理外網提供一個訪問端口,來鏈接物理網絡和虛擬網絡。

  1. 重啓OVS服務:

# service openvswitch-switch restart

  1. 添加external bridge:

# ovs-vsctl add-br br-ex

  1. 把端口添加到external bridge中,來鏈接物理外網:

# ovs-vsctl add-port br-ex INTERFACE_NAME
INTERFACE_NAME替換爲實際的interface name,本文的網絡配置方案下爲eth2

完成安裝

重啓網絡服務:
# service neutron-plugin-openvswitch-agent restart
# service neutron-l3-agent restart
# service neutron-dhcp-agent restart
# service neutron-metadata-agent restart

驗證操做

在controller節點上進行以下操做。

  1. 啓動admin證書:
    $ source admin-openrc.sh
  2. 顯示agent列表,驗證neutron agent已成功啓動:
    <pre>$ neutron agent-list
id agent_type host alive admin_state_up binary
2be5bff5-2d4b-4308-9d8e-218f86f0884e DHCP agent network :-) True neutron-dhcp-agent
35e5874c-0e45-44b1-95e5-f5ac94a1b9d5 L3 agent network :-) True neutron-l3-agent
7debcbec-b316-490e-baa1-1a6bb74fcbbb Open vSwitch agent network :-) True neutron-openvswitch-agent
c35af91b-9f6b-4632-bc10-aa67c8a75ae1 Metadata agent network :-) True neutron-metadata-agent

+--------------------------------------+--------------------+---------+-------+----------------+---------------------------+</pre>

在compute節點上安裝和配置

設定kernel networking參數:

  1. 編輯# vi /etc/sysctl.conf文件:
    <pre>net.ipv4.conf.all.rp_filter=0

net.ipv4.conf.default.rp_filter=0</pre>

  1. 使上述變化生效:

# sysctl -p

安裝網絡服務組件

# apt-get install neutron-plugin-ml2 neutron-plugin-openvswitch-agent

配置網絡服務的通用組件

編輯# vi /etc/neutron/neutron.conf文件:

[database]部分,註釋掉connection選項,由於compute節點不須要直接訪問數據庫。

[DEFAULT]部分,設定RabbitMQ的訪問選項:
<pre>[DEFAULT]
...
rpc_backend = rabbit
rabbit_host = controller
rabbit_password = RABBIT_PASS
</pre>
RABBIT_PASS爲RabbitMQ guest帳戶的密碼。

[DEFAULT][keystone_authtoken]部分,設定認證服務的訪問選項:
<pre>[DEFAULT]
...
auth_strategy = keystone
</pre>
<pre>[keystone_authtoken]
...
auth_uri = http://controller:5000/v2.0
identity_uri = http://controller:35357
admin_tenant_name = service
admin_user = neutron
admin_password = NEUTRON_PASS
</pre>
NEUTRON_PASS爲建立neutron用戶時使用的密碼。在[keystone_authtoken]部分,註釋掉 auth_host,auth_port,和auth_protocol的選項,由於identity_uri選項是直接代替它們的。

[DEFAULT]部分,開啓Modular Layer 2(ML2)plug-in選項,設定router service和overlapping IP addresses選項:
<pre>[DEFAULT]
...
core_plugin = ml2
service_plugins = router
allow_overlapping_ips = True
</pre>

[DEFAULT]部分,開啓「詳細輸出日誌」選項:
<pre>[DEFAULT]
...
verbose = True
</pre>

設定Modular Layer 2(ML2)plug-in

編輯# vi /etc/neutron/plugins/ml2/ml2_conf.ini文件:

[ml2]部分,啓用flat和generic routing encapsulation(GRE)網絡類型的驅動( network type drivers),GRE 租戶網絡和OVS機制的驅動:
<pre>[ml2]
...
type_drivers = flat,gre
tenant_network_types = gre
mechanism_drivers = openvswitch
</pre>

[ml2_type_gre]部分,設定tunnel ID範圍:
<pre>[ml2_type_gre]
...
tunnel_id_ranges = 1:1000
</pre>

[securitygroup]部分,啓用security groups,ipset, and configure,設定OVS iptables firewall driver:
<pre>[securitygroup]
...
enable_security_group = True
enable_ipset = True
firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver
</pre>

[ovs]部分,啓用tunnel,設定local tunnel endpoint,把external flat provider network和br-ex external network brigde綁定起來:
<pre>[ovs]
...
local_ip = INSTANCE_TUNNELS_INTERFACE_IP_ADDRESS
enable_tunneling = True
bridge_mappings = external:br-ex
</pre>
INSTANCE_TUNNELS_INTERFACE_IP_ADDRESS爲network節點在tunnel network中的IP地址。

[agent]部分,啓用GRE tunnels:
<pre>[agent]
...
tunnel_types = gre
</pre>

配置Open vSwitch(OVS)服務

重啓OVS服務:
# service openvswitch-switch restart

配置計算服務使之使用網絡服務

編輯# vi /etc/nova/nova.conf文件:
[DEFAULT]部分,設定API和驅動:
<pre>[DEFAULT]
...
network_api_class = nova.network.neutronv2.api.API
security_group_api = neutron
linuxnet_interface_driver = nova.network.linux_net.LinuxOVSInterfaceDriver
firewall_driver = nova.virt.firewall.NoopFirewallDriver
</pre>

[neutron]部分,設定訪問參數:
<pre>[neutron]
...
url = http://controller:9696
auth_strategy = keystone
admin_auth_url = http://controller:35357/v2.0
admin_tenant_name = service
admin_username = neutron
admin_password = NEUTRON_PASS
</pre>
NEUTRON_PASS爲建立neutron用戶時使用的密碼。

完成安裝

  1. 重啓計算服務:

# service nova-compute restart

  1. 重啓OVS agent:

# service neutron-plugin-openvswitch-agent restart

驗證操做

在controller節點上執行以下操做:

  1. 啓動admin證書:
    $ source admin-openrc.sh
  2. 顯示agent列表,驗證neutron agent已成功啓動:
    <pre>$ neutron agent-list
id agent_type host alive admin_state_up binary
03586491-fbf0-495f-93d9-77704ffdba61 Open vSwitch agent compute :-) True neutron-openvswitch-agent
2be5bff5-2d4b-4308-9d8e-218f86f0884e DHCP agent network xxx True neutron-dhcp-agent
35e5874c-0e45-44b1-95e5-f5ac94a1b9d5 L3 agent network xxx True neutron-l3-agent
7debcbec-b316-490e-baa1-1a6bb74fcbbb Open vSwitch agent network xxx True neutron-openvswitch-agent
c35af91b-9f6b-4632-bc10-aa67c8a75ae1 Metadata agent network xxx True neutron-metadata-agent

+--------------------------------------+--------------------+---------+-------+----------------+---------------------------+</pre>

相關文章
相關標籤/搜索