OpenStack: Neutron 1+X 实训

来自CloudWiki
跳转至: 导航搜索

案例描述

(1)了解 Neutron服务的用处。

(2)学习Neutron服务的基础命令。

(3)使用Neutron命令完成相应运维任务。

案例实施

Neutron网络目的是灵活地划分物理网络,在多租户环境下提供给每个租户独立的网络环境。它是可以被用户创建的对象,如果要和物理环境下的概念映射的话,这个对象相当于一个巨大的交换机,可以拥有无限多个动态可创建和销毁的虛拟端口。

Neutron查询

使用Neutron相关命令查询网络服务的列表信息中的“binary”--列,代码如下所示。

source /etc/keystone/admin-openrc.sh

[root@controller ~]# neutron agent-list

+----------+------------+----------+-------------------+-------+----------------+---------------+
| id       | agent_type | host     | availability_zone | alive | admin_state_up | binary        |
+----------+------------+----------+-------------------+-------+----------------+---------------+
| 1ccc8d2d | Open       | controll |                   | :-)   | True           | neutron-      |
| -b40a-44 | vSwitch    | er       |                   |       |                | openvswitch-  |
| 06-b15b- | agent      |          |                   |       |                | agent         |
| ab4b2b8e |            |          |                   |       |                |               |
| 8398     |            |          |                   |       |                |               |
| 245ae2f9 | DHCP agent | controll | nova              | :-)   | True           | neutron-dhcp- |
| -6220-4c |            | er       |                   |       |                | agent         |
| 00-a36d- |            |          |                   |       |                |               |
| 542a746a |            |          |                   |       |                |               |
| 3f9e     |            |          |                   |       |                |               |
| 26f38d05 | L3 agent   | controll | nova              | :-)   | True           | neutron-l3-ag |
| -3553-46 |            | er       |                   |       |                | ent           |
| f6-8740- |            |          |                   |       |                |               |
| 847f9774 |            |          |                   |       |                |               |
| 1f89     |            |          |                   |       |                |               |
| 5bd0c9e2 | Metadata   | controll |                   | :-)   | True           | neutron-      |
| -a2ef-48 | agent      | er       |                   |       |                | metadata-     |
| 90-a4ac- |            |          |                   |       |                | agent         |
| a4cb6bcc |            |          |                   |       |                |               |
| f71b     |            |          |                   |       |                |               |
| f1d1fc34 | Loadbalanc | controll |                   | :-)   | True           | neutron-      |
| -6e9d-46 | er agent   | er       |                   |       |                | lbaas-agent   |
| b5-8370- |            |          |                   |       |                |               |
| 0579f3b4 |            |          |                   |       |                |               |
| 6b6f     |            |          |                   |       |                |               |
+----------+------------+----------+-------------------+-------+----------------+---------------+

[root@controller ~]# neutron agent-list -c binary

+---------------------------+
| binary                    |
+---------------------------+
| neutron-openvswitch-agent |
| neutron-dhcp-agent        |
| neutron-l3-agent          |
| neutron-metadata-agent    |
| neutron-lbaas-agent       |
+---------------------------+

查看网络详情

[root@controller ~]# neutron net-list


  +--------------------------------------+---------+-----------------------------------------------------+
| id                                   | name    | subnets                                             |
+--------------------------------------+---------+-----------------------------------------------------+
| 4bf11a18-ac60-4396-a599-1e368c898f67 | vlan115 | 75d45cae-1cff-4e06-bbd2-a5259ffed886 172.30.15.0/24 |
+--------------------------------------+---------+-----------------------------------------------------+


[root@controller ~]# neutron net-show 4bf11a18-ac60-4396-a599-1e368c898f67

  +---------------------------+--------------------------------------+
| Field                     | Value                                |
+---------------------------+--------------------------------------+
| admin_state_up            | True                                 |
| availability_zone_hints   |                                      |
| availability_zones        | nova                                 |
| created_at                | 2021-11-05T16:13:19                  |
| description               |                                      |
| id                        | 4bf11a18-ac60-4396-a599-1e368c898f67 |
| ipv4_address_scope        |                                      |
| ipv6_address_scope        |                                      |
| mtu                       | 1458                                 |
| name                      | vlan115                              |
| port_security_enabled     | True                                 |
| provider:network_type     | gre                                  |
| provider:physical_network |                                      |
| provider:segmentation_id  | 98                                   |
| router:external           | False                                |
| shared                    | False                                |
| status                    | ACTIVE                               |
| subnets                   | 75d45cae-1cff-4e06-bbd2-a5259ffed886 |
| tags                      |                                      |
| tenant_id                 | f9ff39ba9daa4e5a8fee1fc50e2d2b34     |
| updated_at                | 2021-11-05T16:13:20                  |
+---------------------------+--------------------------------------+

</nowiki>

查询neutron相关组件服务

查询网络服务DHCP agent的详细信息(id 为查询到DHCP agent服务对应id)

[root@controller ~]# neutron agent-list

+--------------------------------------+--------------------+------------+-------------------+-------+----------------+---------------------------+
| id                                   | agent_type         | host       | availability_zone | alive | admin_state_up | binary                    |
+--------------------------------------+--------------------+------------+-------------------+-------+----------------+---------------------------+
| 1ccc8d2d-b40a-4406-b15b-ab4b2b8e8398 | Open vSwitch agent | controller |                   | :-)   | True           | neutron-openvswitch-agent |
| 245ae2f9-6220-4c00-a36d-542a746a3f9e | DHCP agent         | controller | nova              | :-)   | True           | neutron-dhcp-agent        |
| 26f38d05-3553-46f6-8740-847f97741f89 | L3 agent           | controller | nova              | :-)   | True           | neutron-l3-agent          |
| 5bd0c9e2-a2ef-4890-a4ac-a4cb6bccf71b | Metadata agent     | controller |                   | :-)   | True           | neutron-metadata-agent    |
| f1d1fc34-6e9d-46b5-8370-0579f3b46b6f | Loadbalancer agent | controller |                   | :-)   | True           | neutron-lbaas-agent       |
+--------------------------------------+--------------------+------------+-------------------+-------+----------------+---------------------------+

[root@controller ~]# neutron agent-show f1d1fc34-6e9d-46b5-8370-0579f3b46b6f


+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| admin_state_up      | True                                 |
| agent_type          | Loadbalancer agent                   |
| alive               | True                                 |
| availability_zone   |                                      |
| binary              | neutron-lbaas-agent                  |
| configurations      | {                                    |
|                     |      "device_drivers": [             |
|                     |           "haproxy_ns"               |
|                     |      ],                              |
|                     |      "instances": 0                  |
|                     | }                                    |
| created_at          | 2019-12-03 17:43:13                  |
| description         |                                      |
| heartbeat_timestamp | 2021-11-27 17:19:06                  |
| host                | controller                           |
| id                  | f1d1fc34-6e9d-46b5-8370-0579f3b46b6f |
| started_at          | 2019-12-03 17:43:13                  |
| topic               | n-lbaas_agent                        |
+---------------------+--------------------------------------+


创建一个新的网络(FLAT型)

查看租户信息

openstack project list

+----------------------------------+---------+
| ID                               | Name    |
+----------------------------------+---------+
| 5d4c854550c749b99d318ed040d0c6c5 | demo    |
| b9d68ac4b36a40dd996a298afd1ab47e | admin   |
| e1415d6ec88e4152a1c938234a2f80ec | service |
+----------------------------------+---------+


创建网络

neutron net-create --tenant-id [project-id] sharednet1 --shared --provider:network_type flat --provider:physical_network physnet1

+---------------------------+--------------------------------------+
| Field                     | Value                                |
+---------------------------+--------------------------------------+
| admin_state_up            | True                                 |
| id                        | cf6e1ccf-1ac7-4928-93d0-0ef8487c47af |
| name                      | sharednet1                           |
| provider:network_type     | flat                                 |
| provider:physical_network | physnet1                             |
| provider:segmentation_id  |                                      |
| shared                    | True                                 |
| status                    | ACTIVE                               |
| subnets                   |                                      |
| tenant_id                 | a0a60387c08e402f9790b05310245cd8     |
+---------------------------+--------------------------------------+

创建子网

neutron subnet-create sharednet1 192.168.100.0/24 --name subnet001 --enable_dhcp=True --allocation-pool start=192.168.100.100,end=192.168.100.150 --gateway=192.168.100.2

Created a new subnet:
+------------------+--------------------------------------------------------+
| Field            | Value                                                  |
+------------------+--------------------------------------------------------+
| allocation_pools | {"start": "192.168.100.100", "end": "192.168.100.150"} |
| cidr             | 192.168.100.0/24                                       |
| dns_nameservers  |                                                        |
| enable_dhcp      | True                                                  |
| gateway_ip       | 192.168.100.2                                          |
| host_routes      |                                                        |
| id               | 4073e2b2-ac4e-4256-b6fb-828912b48492                   |
| ip_version       | 4                                                      |
| name             | subnet001                                              |
| network_id       | cf6e1ccf-1ac7-4928-93d0-0ef8487c47af                   |
| tenant_id        | 00d9dcd033d542b68614c88d19fa0544                       |
+------------------+--------------------------------------------------------+

此步如果有困难,可到图形界面中完成: