1. 程式人生 > >Ubuntu搭建Openstack平臺(kilo)(五.neutron(二)網路節點與計算節點)

Ubuntu搭建Openstack平臺(kilo)(五.neutron(二)網路節點與計算節點)

網路節點

一.配置引數

  • 環境配置
vim /etc/sysctl.conf

net.ipv4.ip_forward=1
net.ipv4.conf.all.rp_filter=0
net.ipv4.conf.default.rp_filter=0
  • 使配置生效
sysctl -p

二.安裝neutron元件

1.安裝

apt-get install neutron-plugin-ml2 neutron-plugin-openvswitch-agent neutron-l3-agent neutron-dhcp-agent neutron-metadata-agent
-y

2.修改配置

vim /etc/neutron/neutron.conf

[DEFAULT]
verbose = True
rpc_backend = rabbit
#配置認證訪問
auth_strategy = keystone

#啟用 Modular Layer 2 (ML2) plug-in,路由服務, 和 overlapping IP addresses:
core_plugin = ml2
service_plugins = router
allow_overlapping_ips = True

#在[database]模組註釋掉connection,因為網路節點不需要連線資料庫
[oslo_messaging_rabbit] #配置RabbitMQ 訊息佇列服務 rabbit_host = controller rabbit_userid = openstack rabbit_password = RABBIT_PASS(密碼為建立的訊息中介軟體密碼,我的為123) [keystone_authtoken] #配置認證訪問 auth_uri = http://controller:5000 auth_url = http://controller:35357 auth_plugin = password project_domain_id = default user_domain_id
= default project_name = service username = neutron password = NEUTRON_PASS(我的密碼為neutron)

3.修改Modular Layer 2 (ML2) plug-in

vim /etc/neutron/plugins/ml2/ml2_conf.ini

[ml2]
#啟用flat,VLAN,GRE和VXLAN網路型別驅動,GRE租戶網路,和OVS機制驅動:
type_drivers = flat,vlan,gre,vxlan
tenant_network_types = gre
mechanism_drivers = openvswitch

[ml2_type_gre]
#配置隧道標識的id範圍
tunnel_id_ranges = 1:1000

[ml2_type_flat]
#配置external flat 提供的網路
flat_networks = external

[securitygroup]
#啟用security groups, 啟用 ipset, 和 配置  OVS iptables firewall 驅動
enable_security_group = True
enable_ipset = True
firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver

[ovs]
#啟用隧道,配置本地隧道服務,和對映外部 flat 私有網路到 br-ex 外部網橋
#INSTANCE_TUNNELS_INTERFACE_IP_ADDRESS是網路節點例項隧道網路介面的IP 我的是10.0.1.21
local_ip = INSTANCE_TUNNELS_INTERFACE_IP_ADDRESS(10.0.1.21)
bridge_mappings = external:br-ex

[agent]
#啟用GRE隧道
tunnel_types = gre

4.配置Layer-3 (L3) agent

vim /etc/neutron/l3_agent.ini

[DEFAULT]
verbose = True
#配置網絡卡驅動,外部網橋,和啟用是刪除路由名稱空間失效,external_network_bridge 是沒有值的
interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver
external_network_bridge =
router_delete_namespaces = True

5.配置DHCP

vim /etc/neutron/dhcp_agent.ini 

[DEFAULT]
verbose = True
#配置介面和 dhcp 驅動,啟用失效刪除 DHCP 命令空間
interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver
dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq
dhcp_delete_namespaces = True

6.配置 metadata

vim  /etc/neutron/metadata_agent.ini

[DEFAULT]
verbose = True
#配置訪問引數
auth_uri = http://controller:5000
auth_url = http://controller:35357
auth_region = RegionOne
auth_plugin = password
project_domain_id = default
user_domain_id = default
project_name = service
username = neutron
password = NEUTRON_PASS(我的neutron)

#配置metadata的主機
nova_metadata_ip = controller

#配置metadata共享代理密碼(我設定的是123,與控制節點的要一致)
metadata_proxy_shared_secret = METADATA_SECRET(123)
  • 控制節點新增上面的密碼配置
vim /etc/nova/nova.conf

[neutron]
service_metadata_proxy = True
metadata_proxy_shared_secret = METADATA_SECRET(123)

退出後,重啟nova-api服務
service nova-api restart

7.配置 Open vSwitch (OVS)服務

  • 重啟OVS服務
ervice openvswitch-switch restart
  • 新增外部網橋
ovs-vsctl add-br br-ex
  • 新增混雜模式網絡卡到 br-ex(INTERFACE_NAME是自己上外網的網絡卡,我的為eth2)
ovs-vsctl add-port br-ex INTERFACE_NAME(eth2)
  • 注意,根據不同的網絡卡驅動,你可以需要禁用 generic receive offload (GRO),暫時禁用 GRO 在外部網絡卡
ethtool -K INTERFACE_NAME gro off

8.重啟網路服務

service neutron-plugin-openvswitch-agent restart
service neutron-l3-agent restart
service neutron-dhcp-agent restart
service neutron-metadata-agent restart

9.驗證(控制節點)

  • 載入環境
source admin-openrc.sh
  • 列出建立成功的neutron代理
neutron agent-list
+------------------------------------+------------------+--------+-----+-------------+-------------------------+
|id                                  |agent_type        |host   |alive|admin_state_up| binary                  |
+-------------------------------------+-----------------+--------+-----+-------------+-------------------------+
|30275801-e17a-41e4-8f53-9db63544f689|Metadata agent    |network| :-) |True          |neutron-metadata-agent   |
|4bd8c50e-7bad-4f3b-955d-67658a491a15|Open vSwitch agent|network| :-) |True          |neutron-openvswitch-agent|
|756e5bba-b70f-4715-b80e-e37f59803d20|L3 agent          |network| :-) |True          |neutron-l3-agent         |
|9c45473c-6d6d-4f94-8df1-ebd0b6838d5f|DHCP agent        |network| :-) |True          |neutron-dhcp-agent       |
+------------------------------------+------------------+-------+-----+--------------+-------------------------+

計算節點

1.配置一定的核心網路引數

  • 配置
vim  /etc/sysctl.conf 

net.ipv4.conf.all.rp_filter=0
net.ipv4.conf.default.rp_filter=0
net.bridge.bridge-nf-call-iptables=1
net.bridge.bridge-nf-call-ip6tables=1
  • 生效
sysctl -p

2.安裝neutron元件

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

3.修改配置

vim /etc/neutron/neutron.conf

[DEFAULT]
verbose = True
rpc_backend = rabbit
#配置認證訪問
auth_strategy = keystone

#啟用 Modular Layer 2 (ML2) plug-in,路由服務, 和 overlapping IP addresses:
core_plugin = ml2
service_plugins = router
allow_overlapping_ips = True

#在[database]模組註釋掉connection,因為網路節點不需要連線資料庫

[oslo_messaging_rabbit]
#配置RabbitMQ 訊息佇列服務
rabbit_host = controller
rabbit_userid = openstack
rabbit_password = RABBIT_PASS(密碼為建立的訊息中介軟體密碼,我的為123)

[keystone_authtoken]
#配置認證訪問
auth_uri = http://controller:5000
auth_url = http://controller:35357
auth_plugin = password
project_domain_id = default
user_domain_id = default
project_name = service
username = neutron
password = NEUTRON_PASS(我的密碼為neutron)

4.修改Modular Layer 2 (ML2) plug-in

vim /etc/neutron/plugins/ml2/ml2_conf.ini

[ml2]
#啟用flat,VLAN,GRE和VXLAN網路型別驅動,GRE租戶網路,和OVS機制驅動:
type_drivers = flat,vlan,gre,vxlan
tenant_network_types = gre
mechanism_drivers = openvswitch

[ml2_type_gre]
#配置隧道標識的id範圍
tunnel_id_ranges = 1:1000

[securitygroup]
#啟用security groups, 啟用 ipset, 和 配置  OVS iptables firewall 驅動
enable_security_group = True
enable_ipset = True
firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver

[ovs]
#啟用隧道,配置本地隧道服務
#INSTANCE_TUNNELS_INTERFACE_IP_ADDRESS是計算節點例項隧道網路介面的IP 我的是10.0.1.31
local_ip = INSTANCE_TUNNELS_INTERFACE_IP_ADDRESS(10.0.1.31)

[agent]
#啟用GRE隧道
tunnel_types = gre

5.配置 Open vSwitch (OVS)服務

  • 重啟OVS 服務

service openvswitch-switch restart
  • 配置計算節點nova.conf(新增如下內容)
vim /etc/nova/nova.conf

[DEFAULT]
#配置Apis與驅動
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

[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(我的密碼為neutron)
  • 重啟計算服務與OVS代理
service nova-compute restart
service neutron-plugin-openvswitch-agent restart

6.控制節點驗證

  • 載入環境
source admin-openrc.sh
  • 列出建立的neutron代理
neutron agent-list
+------------------------------------+------------------+-------+-----+--------------+--------------------------+
| id                                 | agent_type       | host  |alive|admin_state_up| binary                   |
+------------------------------------+------------------+-------+-----+--------------+--------------------------+
|30275801-e17a-41e4-8f53-9db63544f689|Metadata agent    |network| :-) | True         |neutron-metadata-agent    |
|4bd8c50e-7bad-4f3b-955d-67658a491a15|Open vSwitch agent|network| :-) | True         |neutron-openvswitch-agent |
|756e5bba-b70f-4715-b80e-e37f59803d20|L3 agent          |network| :-) | True         |neutron-l3-agent          |
|9c45473c-6d6d-4f94-8df1-ebd0b6838d5f|DHCP agent        |network| :-) | True         |neutron-dhcp-agent        |
|a5a49051-05eb-4b4f-bfc7-d36235fe9131|Open vSwitch agent|compute| :-) | True         |neutron-openvswitch-agent |
+--------------------------------------+--------------------+----------+-------+----------------+---------------+