OpenStack(Kilo版本)网络服务neutron的安装部署

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
简介:

    Openstack网络主要是和OpenStack计算交互,提供网络连接到它的实例。
一、OpenStack网络服务包含的组件

图1.1. OpenStack Nova组件

wKiom1YfDpGxy23fAAE9EeUSjhM997.jpg

二、OpenStack网络节点基本环节的搭建
1.配置主机名和网络信息
1.1配置主机名

1
2
root@network:~ # vim /etc/hostname
network

1.2 配置IP地址

1
2
3
4
5
6
7
8
9
10
11
12
13
14
root@network:~ # vim  /etc/network/interfaces
auto eth0
iface eth0 inet static
address 192.168.100.101
netmask 255.255.255.0
gateway 192.168.100.2
auto eth1
iface eth1 inet static
address 192.168.200.101
netmask 255.255.255.0
auto eth2
iface eth2 inet manual
         up ip link  set  dev $IFACE up
         down ip link  set  dev $IFACE down

1.3 配置名称解析hosts

1
2
3
4
5
6
7
root@network:~ # vim  /etc/hosts
# controller
192.168.100.100  controller
# network
192.168.100.101  network
# compute1
192.168.100.102  compute1

2.网络时间协议ntp
2.1 安装ntp服务器

1
root@network:~ #  apt-get install ntp

2.2 配置/etc/ntp.conf 服务

1
server controller iburst

2.3重启ntp服务

1
root@network:~ #  /etc/init.d/ntp restart

3.系统升级更新
3.1 更新openstack 仓库源

1
2
3
root@network:~ #  apt-get install ubuntu-cloud-keyring
root@network:~ # vim /etc/apt/sources.list.d/cloudarchive-kilo.list
deb http: //ubuntu-cloud .archive.canonical.com /ubuntu  trusty-updates /kilo  main

3.2升级软件包,如果升级过程中包含内核的升级,需要重启服务器。

1
2
root@network:~ #  apt-get update
root@network:~ #  apt-get dist-upgrade

三、安装和配置控制节点
下面介绍如何在控制节点上面安装和配置OpenStack Networking (neutron) service,下面所有的操作步骤在控制节点上面操作。在安装和配置计算服务之前,必须先创建数据库、服务证书和API。
1.数据库配置
1.1创建数据库

1
2
3
root@controller:~ # mysql -uroot -p
MariaDB [(none)]> create database neutron;
Query OK, 1 row affected (0.12 sec)

1.2给数据库授权

1
2
3
4
5
6
MariaDB [(none)]> GRANT ALL PRIVILEGES ON neutron.* TO  'neutron' @ 'localhost'  IDENTIFIED BY  'sfzhang1109' ;
Query OK, 0 rows affected (0.41 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON neutron.* TO  'neutron' @ '%'  IDENTIFIED BY  'sfzhang1109' ;
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.10 sec)

1.3退出数据库客户端

1
2
MariaDB [(none)]>  exit ;
Bye

2.导入admin身份凭证以便执行管理命令

1
root@controller:~ # source admin-openrc.sh

3.创建服务证书
3.1创建neutron用户(密码:neutron)

1
2
3
4
5
6
7
8
9
10
11
12
root@controller:~ # openstack user create --password-prompt neutron
User Password:
Repeat User Password:
+----------+----------------------------------+
| Field    | Value                            |
+----------+----------------------------------+
| email    | None                             |
| enabled  | True                             |
id        | b11104ae8be347459f83dccdc065bc32 |
| name     | neutron                          |
| username | neutron                          |
+----------+----------------------------------+

3.2添加neutron用户到admin角色

1
2
3
4
5
6
7
root@controller:~ # openstack role add --project service --user neutron admin
+-------+----------------------------------+
| Field | Value                            |
+-------+----------------------------------+
id     | 05616505a61c4aa78f43fba9e60ba7fc |
| name  | admin                            |
+-------+----------------------------------+

3.3创建neutron服务实体

1
2
3
4
5
6
7
8
9
10
11
root@controller:~ #  openstack service create --name neutron \
     --description  "OpenStack Networking"  network
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | OpenStack Networking             |
| enabled     | True                             |
id           | ac269b9d3c8c4862ac882c23f253e966 |
| name        | neutron                          |
type         | network                          |
+-------------+----------------------------------+

3.4创建Networking service的API endpoint

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
root@controller:~ #  openstack endpoint create \
     --publicurl http: //controller :9696 \
     --adminurl http: //controller :9696 \
     --internalurl http: //controller :9696 \
     --region RegionOne \
    network
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| adminurl     | http: //controller :9696           |
id            | ce52629dec38402a9ee23e88cc335225 |
| internalurl  | http: //controller :9696           |
| publicurl    | http: //controller :9696           |
| region       | RegionOne                        |
| service_id   | ac269b9d3c8c4862ac882c23f253e966 |
| service_name | neutron                          |
| service_type | network                          |
+--------------+----------------------------------+

4.安装和配置网络组建
下面所有的操作在控制节点操作,Networking 服务组件的配置包括数据库配置、身份验证认证机制配置、消息队列、拓扑变化通知和插件配置。
4.1安装软件包

1
root@controller:~ #  apt-get install neutron-server neutron-plugin-ml2 python-neutronclient

4.2编辑neutron的配置文件/etc/neutron/neutron.conf
1)在[database]部分配置数据库访问

1
2
3
[database]
connection = connection = mysql: //neutron :sfzhang1109@controller /neutron

2)在[DEFAULT]和[oslo_messaging_rabbit]部分配置RabbitMQ消息队列访问

1
2
3
4
5
6
7
8
[DEFAULT]
rpc_backend = rabbit
[oslo_messaging_rabbit]
rabbit_host = controller
rabbit_userid = openstack
rabbit_password = 2015OS ##

这里的密码为rabbitmqctl add_user命令添加openstack用户的密码
3)在[DEFAULT]和[keystone_authtoken]部分配置身份认证服务

1
2
3
4
5
6
7
8
9
10
11
12
13
[DEFAULT]
auth_strategy = keystone
[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

4)在[DEFAULT]部分启用Modular Layer2(ML2)插件、router服务和overlapping IP addresses

1
2
3
4
5
[DEFAULT]
core_plugin = ml2
service_plugins = router
allow_overlapping_ips = True

5)在[DEFAULT]和[nova]部分,配置网络拓扑变化通知

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[DEFAULT]
notify_nova_on_port_status_changes = True
notify_nova_on_port_data_changes = True
nova_url = http: //controller :8774 /v2
[nova]
auth_url = http: //controller :35357
auth_plugin = password
project_domain_id = default
user_domain_id = default
region_name = RegionOne
project_name = service
username = nova
password = nova

6)在[DEFAULT]段中开启详细日志配置,为后期的故障排除提供帮助

1
2
3
[DEFAULT]
verbose = True

4.3配置Modular Layer 2 (ML2)插件
编辑配置文件/etc/neutron/plugins/ml2/ml2_conf.ini
1)在[ml2]部分,启用flat, VLAN, generic routing encapsulation (GRE), 和 virtual extensible LAN (VXLAN) 网络类型驱动, GRE 租户网络, 和OVS 机制驱动

1
2
3
4
5
[ml2]
type_drivers = flat,vlan,gre,vxlan
tenant_network_types = gre
mechanism_drivers = openvswitch

注意:一旦配置ML2插件,如何改变type_drivers值的话,会导致数据库不一致
2)在[ml2_type_gre]部分,配置隧道标识符id的范围

1
2
3
[ml2_type_gre]
...
tunnel_id_ranges = 1:1000

3)在[securitygroup] 部分,启用security groups, 启用 ipset, 和 配置  OVS iptables firewall 驱动

1
2
3
4
5
[securitygroup]
enable_security_group = True
enable_ipset = True
firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver

5.配置Compute以使用Networking
默认情况下,发行版的包配置Compute使用传统网络,必须重新配置Compute通过Networking管理网络。下面的步骤在控制节点上面操作。
5.1修改控制节点/etc/nova/nova.conf配置文件
1)在[DEFAULT]部分,配置APIS和驱动

1
2
3
4
5
6
[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

2)在[neutron]部分,配置访问参数

1
2
3
4
5
6
7
8
[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

 
6.完成安装
6.1.初始化数据库

1
2
3
4
5
root@controller:~ #  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
INFO  [alembic.migration] Context impl MySQLImpl.
INFO  [alembic.migration] Will assume non-transactional DDL.

6.2重启Compute服务

1
root@controller:~ # service nova-api restart

6.3重启Networking服务

1
root@controller:~ # service neutron-server restart

7.验证操作
注意:验证操作在控制节点操作
7.1执行admin身份凭证

1
root@controller:~ # source admin-openrc.sh

7.2列出创建成功的neutron-server 进程

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
root@controller:~ # neutron ext-list
+-----------------------+-----------------------------------------------+
alias                  | name                                          |
+-----------------------+-----------------------------------------------+
| security-group        | security-group                                |
| l3_agent_scheduler    | L3 Agent Scheduler                            |
| net-mtu               | Network MTU                                   |
| ext-gw-mode           | Neutron L3 Configurable external gateway mode |
| binding               | Port Binding                                  |
| provider              | Provider Network                              |
| agent                 | agent                                         |
| quotas                | Quota management support                      |
| subnet_allocation     | Subnet Allocation                             |
| 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                    |
+-----------------------+-----------------------------------------------+

四、安装和配置网络节点
下面所有的操作在网络节点操作
1.在安装和配置OpenStack网络之前,必须配置内核参数。
1)编辑配置文件/etc/sysctl.conf修改下面的配置。

1
2
3
net.ipv4.ip_forward=1
net.ipv4.conf.all.rp_filter=0
net.ipv4.conf.default.rp_filter=0

2)使修改生效

1
2
3
4
root@network:~ # sysctl -p
net.ipv4.conf.default.rp_filter = 0
net.ipv4.conf.all.rp_filter = 0
net.ipv4.ip_forward = 1

2.安装网络组建

1
root@network:~ # apt-get install neutron-plugin-ml2 neutron-plugin-openvswitch-agent   neutron-l3-agent neutron-dhcp-agent neutron-metadata-agent

3.配置网络通用组建
网络通用组建包括认证机制、消息队列和插件。
编辑/etc/neutron/neutron.conf配置文件,完成下面配置。
3.1在[database]部分,注释掉connection选择,因为网络不直接使用数据库。
3.2在[DEFAULT]和[oslo_messaging_rabbit]部分,配置消息队列访问

1
2
3
4
5
6
7
8
9
[DEFAULT]
...
rpc_backend = rabbit
  
[oslo_messaging_rabbit]
...
rabbit_host = controller
rabbit_userid = openstack
rabbit_password = 2015OS ##

3.3在[DEFAULT]和[keystone_authtoken]部分配置认证访问

1
2
3
4
5
6
7
8
9
10
11
12
13
[DEFAULT]
...
auth_strategy = keystone
[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 = 2015OS ##

3.4在[m2]部分,启用Modular Layer 2 (ML2) plug-in, router service, 和 overlapping IP

1
2
3
4
5
6
addresses
[DEFAULT]
...
core_plugin = ml2
service_plugins = router
allow_overlapping_ips = True

3.5在[DEFAULT]段中开启详细日志配置,为后期的故障排除提供帮助

1
2
3
[DEFAULT]
...
verbose = True

4.配置Modular Layer 2(ML2)插件
ML2插件使用Open vSwitch (OVS) 机制构建实例的虚拟网络框架
编辑文件 /etc/neutron/plugins/ml2/ml2_conf.ini,完成下面内容
4.1 在 [ml2]部分,启用 flat, VLAN, generic routing encapsulation (GRE), 和 virtual extensible LAN (VXLAN) 网络类型驱动,GRE 租户网络, 和  OVS 机制驱动。

1
2
3
4
5
[ml2]
...
type_drivers = flat,vlan,gre,vxlan
tenant_network_types = gre
mechanism_drivers = openvswitch

4.2在[ml2_type_flat]部分,配置external flat提供的网络

1
2
3
[ml2_type_flat]
...
flat_networks = external

4.3在[ml2_type_grp]部分,配置tunnel标识符(id)范围

1
2
3
[ml2_type_gre]
...
tunnel_id_ranges = 1:1000

4.4在[securitygroup]部分,启用安全组, ipset, 和配置  OVS iptables firewall driver

1
2
3
4
5
[securitygroup]
...
enable_security_group = True
enable_ipset = True
firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver

4.5在 [ovs]部分,启用tunnels和配置本地 tunnel endpoint,和映射外部flat私有网络到br-ex外部网桥

1
2
3
4
[ovs]
...
local_ip = 192.168.200.101
bridge_mappings = external:br-ex

这里的IP为网络节点隧道网络ip地址192.168.200.101
4.6在 [agent] 部分, 启用 GRE 隧道:

1
2
3
[agent]
...
tunnel_types = gre

5.配置Layer-3(L3)代理
Layer-3 (L3) 提供路由服务为虚拟网络
编辑文件/etc/neutron/l3_agent.ini完成下面内容
5.1.在[DEFAULT]部分,配置网卡驱动,外部网桥,和启用是删除路由命名空间失效

1
2
3
4
5
[DEFAULT]
...
interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver
external_network_bridge =
router_delete_namespaces = True

5.2在[DEFAULT]部分开启详细日志配置,为后期的故障排除提供帮助

1
2
3
[DEFAULT]
...
verbose = True

6.配置DHCP代理
DHCP 代理为虚拟网络提供 DHCP 服务
编辑文件/etc/neutron/dhcp_agent.ini完成下面内容
6.1在 [DEFAULT]部分,配置接口和dhcp驱动,启用失效删除DHCP 命令空间

1
2
3
4
5
[DEFAULT]
...
interface_driver = neutron.agent.linux.interface.OVSInterfaceDriver
dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq
dhcp_delete_namespaces = True

6.2在[DEFAULT]段中开启详细日志配置,为后期的故障排除提供帮助

1
2
3
[DEFAULT]
...
verbose = True

7.配置metadata代理
Metadata代理提供配置信息,例如凭证的实例。
编辑文件/etc/neutron/metadata_agent.ini,完成下面的配置
7.1在 [DEFAULT]部分,配置访问参数

1
2
3
4
5
6
7
8
9
10
11
[DEFAULT]
...
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

7.2在[DEFAULT]部分配置metadata host

1
2
3
[DEFAULT]
...
nova_metadata_ip = controller

7.3在 [DEFAULT]部分,配置metadata代理共享密码

1
2
3
DEFAULT]
...
metadata_proxy_shared_secret = METADATAPASS

7.4在[DEFAULT]段中开启详细日志配置,为后期的故障排除提供帮助

1
2
3
[DEFAULT]
...
verbose = True

8.在控制节点,编辑文件etc/nova/nova.conf,完成下面配置
8.1在 [neutron] 部分,启用 metadata 代理并配置 secret,其中secret是上面配置的

1
2
3
4
[neutron]
...
service_metadata_proxy = True
metadata_proxy_shared_secret = METADATAPASS

8.2在控制节点,重启Compute API服务

1
root@controller:~ # service nova-api restart

9.配置Open vSwitch(OVS)服务
9.1重启OVS服务

1
root@network:~ # service openvswitch-switch restart

9.2添加外部网桥

1
root@network:~ # ovs-vsctl add-br br-ex

9.3添加混杂模式网卡到br-ex

1
root@network:~ # ovs-vsctl add-port br-ex eth2

这里eth2为真实的网卡,为External network,即网络节点的第三块网卡。
注意:根据不同的网卡驱动,你可以需要禁用 generic receive offload (GRO),暂时禁用GRO在外部网卡。

1
root@network:~ # ethtool -K eth2 gro off

10.完成安装,重启网络服务

1
2
3
4
root@network:~ # service neutron-plugin-openvswitch-agent restart
root@network:~ # service neutron-l3-agent restart
root@network:~ # service neutron-dhcp-agent restart
root@network:~ # service neutron-metadata-agent restart

11.验证安装操作
下面操作在控制节点操作
11.1执行admin身份凭证

1
root@controller:~ # source admin-openrc.sh

11.2列出创建成功的neutron代理

1
2
3
4
5
6
7
8
9
root@controller:~ # neutron agent-list
+--------------------------------------+--------------------+---------+-------+----------------+---------------------------+
id                                    | agent_type         | host    | alive | admin_state_up | binary                    |
+--------------------------------------+--------------------+---------+-------+----------------+---------------------------+
| 4b204e1d-096d-4466-9364-7ca7a9d2dc36 | Metadata agent     | network | :-)   | True           | neutron-metadata-agent    |
| 55da2579-f0a7-4f3b-8971-6d19197cedd4 | Open vSwitch agent | network | :-)   | True           | neutron-openvswitch-agent |
| c5b16aad-5d0a-4528-a4ac-afa6b353b4c6 | DHCP agent         | network | :-)   | True           | neutron-dhcp-agent        |
| ccc147b2-85f5-465e-8170-33ca84aae6a1 | L3 agent           | network | :-)   | True           | neutron-l3-agent          |
+--------------------------------------+--------------------+---------+-------+----------------+---------------------------+

五、安装和配置计算节点
1.安装前的准备
在安装配置openstack网络之前,必须修改内核参数。
1.1编辑文件 /etc/sysctl.conf,修改下面参数

1
2
net.ipv4.conf.default.rp_filter=0
net.ipv4.conf.all.rp_filter=0

1.2配置文件生效

1
root@compute1:~ # sysctl -p

2.安装网络组建

1
root@compute1:~ # apt-get install neutron-plugin-ml2 neutron-plugin-openvswitch-agent

3.配置网络通用组建
编辑文件/etc/neutron/neutron.conf,完成下面的配置
3.1在 [database]部分,注释掉connection 选项,因为计算节点不直接访问数据库
3.2在[DEFAULT] 和[oslo_messaging_rabbit]部分,配置RabbitMQ 消息队列访问

1
2
3
4
5
6
7
8
[DEFAULT]
...
rpc_backend = rabbit
[oslo_messaging_rabbit]
...
rabbit_host = controller
rabbit_userid = openstack
rabbit_password = 2015OS ##

3.3在[DEFAULT]和[keystone_authtoken]部分,配置认证服务

1
2
3
4
5
6
7
8
9
10
11
12
13
[DEFAULT]
...
auth_strategy = keystone
[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

3.4在[DEFAULT]部分,启用Modular Layer 2 (ML2)插件,router 服务, 和 overlapping IP addresses

1
2
3
4
5
[DEFAULT]
...
core_plugin = ml2
service_plugins = router
allow_overlapping_ips = True

4. 配置 Modular Layer 2 (ML2) 插件
编辑文件/etc/neutron/plugins/ml2/ml2_conf.ini,完成下面配置

4.1在 [ml2] 部分, 启用 flat, VLAN, generic routing encapsulation (GRE), 和 virtual extensible LAN (VXLAN) 网络类型驱动, GRE 租户网络, 和OVS 机制驱动

1
2
3
4
5
[ml2]
...
type_drivers = flat,vlan,gre,vxlan
tenant_network_types = gre
mechanism_drivers = openvswitch

4.2在[ml2_type_grp]部分,配置tunnel标识符(id)范围

1
2
3
[ml2_type_gre]
...
tunnel_id_ranges = 1:1000

4.3在[securitygroup]部分,启用安全组, ipset, 和配置  OVS iptables firewall driver

1
2
3
4
5
[securitygroup]
...
enable_security_group = True
enable_ipset = True
firewall_driver = neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver

4.4在 [ovs]部分,启用tunnels和配置本地 tunnel endpoint

1
2
3
[ovs]
...
local_ip = 192.168.200.101

这里的IP为网络节点隧道网络ip地址192.168.200.101
4.5在 [agent] 部分, 启用 GRE 隧道

1
2
3
[agent]
...
tunnel_types = gre

5.配置 Open vSwitch (OVS)服务
OVS服务为实例提供了底层的虚拟网络架构。
重启OVS 服务

1
root@compute1:~ # service openvswitch-switch restart

6.配置计算节点使用网络
默认情况下,发行版的包会配置 Compute 使用传统网络。必需重新配置 Compute 来通过
Networking 来管理网络
编辑文件/etc/nova/nova.conf ,完成下面内容
6.1在 [DEFAULT]部分, 配置 APIs 和 驱动

1
2
3
4
5
6
[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

6.2在[neutron] 部分,配置访问参数

1
2
3
4
5
6
7
8
[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

7.完成安装
7.1重启计算服务

1
root@compute1:~ # service nova-compute restart

7.2重启Open vSwitch (OVS) 代理

1
root@compute1:~ # service neutron-plugin-openvswitch-agent restart

8.验证安装
8.1执行admin身份凭证

1
root@controller:~ # source admin-openrc.sh

8.2列出创建成功的neutron 代理

1
2
3
4
5
6
7
8
9
10
root@controller:~ # neutron agent-list
+--------------------------------------+--------------------+----------+-------+----------------+---------------------------+
id                                    | agent_type         | host     | alive | admin_state_up | binary                    |
+--------------------------------------+--------------------+----------+-------+----------------+---------------------------+
| 4b204e1d-096d-4466-9364-7ca7a9d2dc36 | Metadata agent     | network  | :-)   | True           | neutron-metadata-agent    |
| 55da2579-f0a7-4f3b-8971-6d19197cedd4 | Open vSwitch agent | network  | :-)   | True           | neutron-openvswitch-agent |
| b6a4a5a5-ec15-4669-a899-ea3773a9fe89 | Open vSwitch agent | compute1 | :-)   | True           | neutron-openvswitch-agent |
| c5b16aad-5d0a-4528-a4ac-afa6b353b4c6 | DHCP agent         | network  | :-)   | True           | neutron-dhcp-agent        |
| ccc147b2-85f5-465e-8170-33ca84aae6a1 | L3 agent           | network  | :-)   | True           | neutron-l3-agent          |
+--------------------------------------+--------------------+----------+-------+----------------+---------------------------+

六、初始化网络
1.外部网络
外部网络为实例分配网络连接,该网络通过使用网络地址转换(NAT)访问Internet。可以通过一个floating IP和合适的安全组规则来启用Internet的访问到个别实例。admin 租户拥有这个网络,因为它为多个租户提供了外部网络的访问。
1.1创建外部网络
1)执行admin身份凭证

1
root@controller:~ # source admin-openrc.sh

2)创建网络

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
root@controller:~ # neutron net-create ext-net --router:external \
   --provider:physical_network external --provider:network_type flat
Created a new network:
+---------------------------+--------------------------------------+
| Field                     | Value                                |
+---------------------------+--------------------------------------+
| admin_state_up            | True                                 |
id                         | 0ec2aa26-1c49-48c0-80f8-f87cb896283d |
| mtu                       | 0                                    |
| name                      | ext-net                              |
| provider:network_type     | flat                                 |
| provider:physical_network | external                             |
| provider:segmentation_id  |                                      |
| router:external           | True                                 |
| shared                    | False                                |
| status                    | ACTIVE                               |
| subnets                   |                                      |
| tenant_id                 | d04d4985d62f42e2af2ddc35f442ffd9     |
+---------------------------+--------------------------------------+

1.2创建外部网络的子网
创建外部网络子网的命令如下:

1
2
3
neutron subnet-create ext-net EXTERNAL_NETWORK_CIDR --name ext-subnet \
   --allocation-pool start=FLOATING_IP_START,end=FLOATING_IP_END \
   --disable-dhcp --gateway EXTERNAL_NETWORK_GATEWAY

替换掉FLOATING_IP_START,FLOATING_IP_END,分别是floating ip地址的开始地址和结束地址。替换掉EXTERNAL_NETWORK_CIDR子网关联的物理网络。替换 EXTERNAL_NETWORK_GATEWAY 与物理网络的网关。通常是".1"的 ip地址。禁用子网ip地址,因为实例不直接连接外网,floating ip需要手工分配。
举例:使用 203.0.202.0/24 带有浮动IP地址 203.0.202.100 到 203.0.202.200:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
root@controller:~ # neutron subnet-create ext-net 203.0.202.0/24 --name ext-subnet \
    --allocation-pool start=203.0.202.100,end=203.0.202.200 \
    --disable-dhcp --gateway 203.0.202.1
Created a new subnet:
+-------------------+----------------------------------------------------+
| Field             | Value                                              |
+-------------------+----------------------------------------------------+
| allocation_pools  | { "start" "203.0.202.100" "end" "203.0.202.200" } |
| cidr              | 203.0.202.0 /24                                      |
| dns_nameservers   |                                                    |
| enable_dhcp       | False                                              |
| gateway_ip        | 203.0.202.1                                        |
| host_routes       |                                                    |
id                 | 518a1b11-59ff-4a0b-8b1a-cb524d552818               |
| ip_version        | 4                                                  |
| ipv6_address_mode |                                                    |
| ipv6_ra_mode      |                                                    |
| name              | ext-subnet                                         |
| network_id        | 0ec2aa26-1c49-48c0-80f8-f87cb896283d               |
| subnetpool_id     |                                                    |
| tenant_id         | d04d4985d62f42e2af2ddc35f442ffd9                   |
+-------------------+----------------------------------------------------+

2.租户网络
租户网络为实例提供内部网络连接。确保这种网络在不同租户间分离。demo 租户拥有这个网络因为其仅仅为其内的实例提供网络连接。
2.1执行demo身份凭证

1
root@controller:~ # source demo-openrc.sh

2.2创建租户网络

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
root@controller:~ # neutron net-create demo-net
Created a new network:
+-----------------+--------------------------------------+
| Field           | Value                                |
+-----------------+--------------------------------------+
| admin_state_up  | True                                 |
id               | 1b6e6a47-97a1-4e1a-8a04-fd1272a53412 |
| mtu             | 0                                    |
| name            | demo-net                             |
| router:external | False                                |
| shared          | False                                |
| status          | ACTIVE                               |
| subnets         |                                      |
| tenant_id       | 61014ce01ca7474da5a2cce53aa28ade     |
+-----------------+--------------------------------------+

2.3创建租户网络子网
创建租户网络子网的命令如下:

1
2
neutron subnet-create demo-net TENANT_NETWORK_CIDR \
   --name demo-subnet --gateway TENANT_NETWORK_GATEWAY

将其中的TENANT_NETWORK_CIDR 替换为想关联到租户网络的子网并替换TENANT_NETWORK_GATEWAY 为想关联的子网的网关,一般是 ".1" IP 地址。
举例:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
root@controller:~ # neutron subnet-create demo-net 172.20.0/24   --name demo-subnet --gateway 172.20.0.1
Created a new subnet:
+-------------------+------------------------------------------------+
| Field             | Value                                          |
+-------------------+------------------------------------------------+
| allocation_pools  | { "start" "172.20.0.2" "end" "172.20.0.254" } |
| cidr              | 172.20.0.0 /24                                   |
| dns_nameservers   |                                                |
| enable_dhcp       | True                                           |
| gateway_ip        | 172.20.0.1                                     |
| host_routes       |                                                |
id                 | 4ba6a581-1286-4d78-a084-d9812dca945d           |
| ip_version        | 4                                              |
| ipv6_address_mode |                                                |
| ipv6_ra_mode      |                                                |
| name              | demo-subnet                                    |
| network_id        | 1b6e6a47-97a1-4e1a-8a04-fd1272a53412           |
| subnetpool_id     |                                                |
| tenant_id         | 61014ce01ca7474da5a2cce53aa28ade               |
+-------------------+------------------------------------------------+

3.创建租户路由,并附加外网和租户网络到路由
3.1创建路由

1
2
3
4
5
6
7
8
9
10
11
12
13
root@controller:~ # neutron router-create demo-router
Created a new router:
+-----------------------+--------------------------------------+
| Field                 | Value                                |
+-----------------------+--------------------------------------+
| admin_state_up        | True                                 |
| external_gateway_info |                                      |
id                     | 4cb4e5ac-e8bb-4a8e-a2b4-1c848b15ba67 |
| name                  | demo-router                          |
| routes                |                                      |
| status                | ACTIVE                               |
| tenant_id             | 61014ce01ca7474da5a2cce53aa28ade     |
+-----------------------+--------------------------------------+

3.2连接路由到租户网络

1
2
root@controller:~ # neutron router-interface-add demo-router demo-subnet
Added interface d675efb5-df70-48b4-b268-3d5d2db44016 to router demo-router.

3.3连接路由器到外部网络通过设置为网关

1
2
root@controller:~ # neutron router-gateway-set demo-router ext-net
Set gateway  for  router demo-router

4.联通型验证
在任意一台主机ping外网网关和floating ip最小的那个IP地址,都可以ping通。
如果在虚拟机上配置的OpenStac节点,必须配置管理程序以允许外部网络上的混杂模式。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
root@controller:~ # ping 203.0.202.1 -c 4
PING 203.0.202.1 (203.0.202.1) 56(84) bytes of data.
64 bytes from 203.0.202.1: icmp_seq=1 ttl=128  time =0.647 ms
64 bytes from 203.0.202.1: icmp_seq=2 ttl=128  time =0.400 ms
64 bytes from 203.0.202.1: icmp_seq=3 ttl=128  time =0.707 ms
64 bytes from 203.0.202.1: icmp_seq=4 ttl=128  time =0.646 ms
--- 203.0.202.1  ping  statistics ---
4 packets transmitted, 4 received, 0% packet loss,  time  3003ms
rtt min /avg/max/mdev  = 0.400 /0 .600 /0 .707 /0 .118 ms
root@controller:~ # ping 203.0.202.100 -c 4
PING 203.0.202.100 (203.0.202.100) 56(84) bytes of data.
64 bytes from 203.0.202.100: icmp_seq=1 ttl=128  time =1.82 ms
64 bytes from 203.0.202.100: icmp_seq=2 ttl=128  time =1.49 ms
64 bytes from 203.0.202.100: icmp_seq=3 ttl=128  time =1.43 ms
64 bytes from 203.0.202.100: icmp_seq=4 ttl=128  time =1.40 ms
--- 203.0.202.100  ping  statistics ---
4 packets transmitted, 4 received, 0% packet loss,  time  3006ms
rtt min /avg/max/mdev  = 1.402 /1 .539 /1 .826 /0 .173 ms

总结:
1)OpenStack网络节点总共有三个网卡

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
root@network:~ # ifconfig 
eth0      Link encap:以太网  硬件地址 00:0c:29:2e:68:25  
           inet 地址:192.168.100.101  广播:192.168.100.255  掩码:255.255.255.0
           inet6 地址: fe80::20c:29ff:fe2e:6825 /64  Scope:Link
           UP BROADCAST RUNNING MULTICAST  MTU:1500  跃点数:1
           接收数据包:4346 错误:0 丢弃:0 过载:0 帧数:0
           发送数据包:6074 错误:0 丢弃:0 过载:0 载波:0
           碰撞:0 发送队列长度:1000 
           接收字节:381605 (381.6 KB)  发送字节:1109191 (1.1 MB)
           中断:19 基本地址:0x2000 
eth1      Link encap:以太网  硬件地址 00:0c:29:2e:68:2f  
           inet 地址:192.168.200.101  广播:192.168.200.255  掩码:255.255.255.0
           inet6 地址: fe80::20c:29ff:fe2e:682f /64  Scope:Link
           UP BROADCAST RUNNING MULTICAST  MTU:1500  跃点数:1
           接收数据包:80 错误:0 丢弃:0 过载:0 帧数:0
           发送数据包:8 错误:0 丢弃:0 过载:0 载波:0
           碰撞:0 发送队列长度:1000 
           接收字节:8612 (8.6 KB)  发送字节:648 (648.0 B)
           中断:19 基本地址:0x2080 
eth2      Link encap:以太网  硬件地址 00:0c:29:2e:68:39  
           inet6 地址: fe80::20c:29ff:fe2e:6839 /64  Scope:Link
           UP BROADCAST RUNNING MULTICAST  MTU:1500  跃点数:1
           接收数据包:4067 错误:0 丢弃:0 过载:0 帧数:0
           发送数据包:3921 错误:0 丢弃:0 过载:0 载波:0
           碰撞:0 发送队列长度:1000 
           接收字节:395049 (395.0 KB)  发送字节:371402 (371.4 KB)

eth0 192.168.100.101用于管理网络,用于OpenStack组件以及MySQL DB Server, RabbitMQ
messaging server之间的通信。
eth1 192.168.200.101用于和计算节点建立隧道连接。
eth2用于通过floating ip访问实例,IP地址范围为203.0.202.100 到 203.0.202.200。
2)租户网络的ip为172.20.0/24网络,用于租户与租户之间的通信。










本文转自 sfzhang 51CTO博客,原文链接:http://blog.51cto.com/sfzhang88/1703080,如需转载请自行联系原作者

相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助     相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
目录
相关文章
|
29天前
|
数据采集 监控 安全
快速部署:基于Kotlin的公司网络流量控制方案
本文介绍了使用Kotlin构建网络流量控制系统的方案,该系统包括数据采集、分析和自动提交到网站的功能。`TrafficMonitor`类负责监控网络流量,收集流量数据并进行分析,然后通过HTTP POST请求将数据安全提交到指定网站,以实现对公司网络流量的有效管理和安全优化。此方案有助于提升网络安全性和性能,支持数字化业务发展。
75 5
|
30天前
|
存储 安全 网络安全
云端防御策略:融合云服务与网络安全的未来之路
在数字化浪潮的推动下,企业纷纷转向云计算以获取灵活性、可扩展性和成本效益。然而,随之而来的是日益复杂的网络威胁,它们挑战着传统的安全边界。本文将探讨如何通过创新的云服务模型和先进的网络安全措施来构建一个既可靠又灵活的安全框架。我们将分析云计算环境中的关键安全挑战,并提出一系列针对性的策略来加强数据保护,确保业务连续性,并满足合规要求。
28 2
|
3天前
|
存储 安全 网络安全
云端防御策略:融合云服务与网络安全的未来之路
【4月更文挑战第20天】 随着企业数字化转型的加速,云计算已成为支撑现代业务架构的关键。然而,伴随其发展的网络安全威胁也不断演变,对信息安全提出更高要求。本文将深入探讨在动态云环境中实现网络安全防护的策略和技术,包括最新的加密技术、身份验证机制以及入侵检测系统等。通过分析当前云服务中的安全挑战,并结合前沿的网络安全技术,旨在为读者提供一个关于如何在享受云计算便利的同时保障数据安全的全面视角。
|
6天前
|
运维 安全 Cloud Native
安全访问服务边缘(SASE):网络新时代的安全与连接解决方案
SASE(安全访问服务边缘)是一种云基安全模型,结合了网络功能和安全策略,由Gartner在2019年提出。它强调身份驱动的私有网络、云原生架构和全面边缘支持,旨在解决传统WAN和安全方案的局限性,如高延迟和分散管理。SASE通过降低IT成本、提升安全响应和网络性能,应对数据分散、风险控制和访问速度等问题,适用于移动办公、多分支办公等场景。随着网络安全挑战的增加,SASE将在企业的数字化转型中扮演关键角色。
|
13天前
|
JavaScript Java 测试技术
基于Java的网络类课程思政学习系统的设计与实现(源码+lw+部署文档+讲解等)
基于Java的网络类课程思政学习系统的设计与实现(源码+lw+部署文档+讲解等)
30 0
基于Java的网络类课程思政学习系统的设计与实现(源码+lw+部署文档+讲解等)
|
25天前
|
缓存 网络协议 数据库连接
【底层服务/编程功底系列】「网络通信体系」深入探索和分析TCP协议的运输连接管理的核心原理和技术要点
【底层服务/编程功底系列】「网络通信体系」深入探索和分析TCP协议的运输连接管理的核心原理和技术要点
22 0
|
1月前
|
存储 运维 安全
SDN 网络编排与服务
【2月更文挑战第30天】网络编排是基于业务需求,对逻辑网络服务进行有序组织和安排,通过控制器构建满足需求的网络服务。
|
1月前
|
安全 网络安全 API
云端防御:融合云服务与网络安全的未来之路
【2月更文挑战第29天】 随着企业数字化转型的深入,云计算已成为支撑现代业务架构的关键。然而,伴随其便捷性和灵活性的是对安全性的全新挑战。本文将深入探讨在动态和复杂的云环境中,如何构建一个既高效又安全的网络防护体系。我们将讨论云计算服务模型、安全威胁类型以及应对策略,并重点分析如何利用最新的技术进展来强化信息安全管理。
|
1月前
|
Kubernetes 应用服务中间件 nginx
Kubernetes服务网络Ingress网络模型分析、安装和高级用法
Kubernetes服务网络Ingress网络模型分析、安装和高级用法
36 5
|
1月前
|
负载均衡 算法 应用服务中间件
Docker Swarm总结+service创建和部署、overlay网络以及Raft算法(2/5)
Docker Swarm总结+service创建和部署、overlay网络以及Raft算法(2/5)
108 0