Openstack架构构建及详解(5)--Neutron组件

简介: Openstack架构构建及详解(5)--Neutron组件

文章总目录


Neutron详解与安装


1、组件说明及沟通方式


image.png

image.png

image.png

image.png

image.png

在这种网络模式下,每个租户都有自己的路由器,而且有多个私有网络,vm可以分别在不同网段下,通过私网连接路由器在连接到浮动IP,最后到外部路由器实现去外部沟通

image.png


2、构建实验


1、基础配置
[root@neutron ~]# hostnamectl set-hostname network.nice.com
[root@neutron ~]# cat /etc/hosts
127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
192.168.222.5 controller.nice.com
192.168.222.6 network.nice.com
192.168.222.10 compute1.nice.com
192.168.222.20 block1.nice.com
[root@neutron ~]# yum install -y ntpdate
[root@neutron ~]# ntpdate -u 192.168.222.5
24 Jul 11:02:02 ntpdate[4142]: step time server 192.168.222.5 offset 16395.238622 sec
[root@neutron ~]# systemctl restart crond
[root@neutron ~]# systemctl enable crond


1、配置controller节点

1、创建数据库,完成下列步骤:
a.使用root用户连接mysql数据库
#mysql-u root -p
b.创建neutron数据库
CREATE DATABASE neutron;
c.创建数据库用户neutron,并授予neutron用户对neutron数据库完全控制权限
GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'localhost' IDENTIFIED BY 'NEUTRON_DBPASS';
GRANT ALL PRIVILEGES ON neutron.* TO 'neutron'@'%' IDENTIFIED BY 'NEUTRON_DBPASS';
2、执行admin环境变量脚本
# source admin-openrc.sh
3、在认证服务中创建网络服务的认证信息,完成下列步骤:
a.创建neutron用户
[root@controller ~]#  keystone user-create --name neutron --pass NEUTRON_PASS
+----------+----------------------------------+
| Property |              Value               |
+----------+----------------------------------+
|  email   |                                  |
| enabled  |               True               |
|    id    | a7e4e7944d2f4223bd724fcc32678cae |
|   name   |             neutron              |
| username |             neutron              |
+----------+----------------------------------+
b.连接neutron用户到serivce租户和admin角色
[root@controller ~]#  keystone user-role-add --user neutron --tenant service --role admin
c.创建neutron服务
[root@controller ~]# keystone service-create --name neutron --type network --description "Openstack Networking"
+-------------+----------------------------------+
|   Property  |              Value               |
+-------------+----------------------------------+
| description |       Openstack Networking       |
|   enabled   |               True               |
|      id     | 66e916b7b3264a48b0e4420ecd81423f |
|     name    |             neutron              |
|     type    |             network              |
+-------------+----------------------------------+
d.创建neutron服务端点
[root@controller ~]# keystone endpoint-create --service-id $(keystone service-list |awk '/network/ {print $2}') --publicurl http://controller.nice.com:9696 --adminurl http://controller.nice.com:9696 --internalurl http://controller.nice.com:9696 --region regionOne
+-------------+----------------------------------+
|   Property  |              Value               |
+-------------+----------------------------------+
|   adminurl  | http://controller.nice.com:9696  |
|      id     | e9fe74bbedd743458feba34cd64c8ef1 |
| internalurl | http://controller.nice.com:9696  |
|  publicurl  | http://controller.nice.com:9696  |
|    region   |            regionOne             |
|  service_id | 66e916b7b3264a48b0e4420ecd81423f |
+-------------+----------------------------------+
安装网络服务组件
[root@controller ~]#  yum install openstack-neutron openstack-neutron-ml2 python-neutronclient which
[root@controller ~]# vim /etc/neutron/neutron.conf 
[root@controller ~]# vim /etc/neutron/plugins/ml2/ml2_conf.ini 
[root@controller ~]# vim /etc/nova/nova.conf 
[root@controller ~]# ln -s /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.ini
[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 juno" neutron
INFO  [alembic.migration] Context impl MySQLImpl.
INFO  [alembic.migration] Will assume non-transactional DDL.
INFO  [alembic.migration] Running upgrade None -> havana, havana_initial
...
...
...
完成配置
1、为ML2插件配置文件创建连接文件。
# 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 juno" neutron
3、重新启动计算服务
# systemctl restart openstack-nova-api.service openstack-nova-scheduler.service openstack-nova-conductor.service
4、启动网络服务并配置开机自动启动# systemctlenable neutron-server.service# systemctlstart neutron-server.service
5、验证
[root@controller ~]# source admin-openrc.sh
列出加载的扩展模块,确认成功启动neutron-server进程。
[root@controller ~]# 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                    |
+-----------------------+-----------------------------------------------+
2、配置neutron节点


1、编辑/etc/sysctl.conf文件,包含下列参数:
net.ipv4.ip_forward=1
net.ipv4.conf.all.rp_filter=0
net.ipv4.conf.default.rp_filter=0
[root@network ~]# sysctl -p
net.ipv4.ip_forward = 1
net.ipv4.conf.all.rp_filter = 0
net.ipv4.conf.default.rp_filter = 0
安装网络组件
# yum install openstack-neutron openstack-neutron-ml2 openstack-neutron-openvswitch
编辑/etc/neutron/neutron.conf文件并完成下列操作:
a.编辑[database]小节,注释任何connection选项。因为network节点不能直接连接数据库。
b.编辑[DEFAULT]小节,配置RabbitMQ消息队列访问
[DEFAULT]
...
rpc_backend=rabbit
rabbit_host= controller.nice.com
rabbit_password= RABBIT_PASS
c.编辑[DEFAULT]和[keystone_authtoken]小节,配置认证服务访问:
[DEFAULT]
...
auth_strategy= keystone
[keystone_authtoken]
...
auth_uri= http://controller.nice.com:5000/v2.0
identity_uri= http://controller.nice.com:35357admin_tenant_name= service
admin_user= neutron
admin_password= NEUTRON_PASS
d.编辑[DEFAULT]小节,启用Modular Layer2(ML2)插件,路由服务和重叠IP地址功能:
[DEFAULT]
...
core_plugin= ml2
service_plugins= router
allow_overlapping_ips= True
e.(可选)在[DEFAULT]小节中配置详细日志输出。方便排错。
[DEFAULT]
...
verbose = True
ML2插件使用Open vSwitch(OVS)机制为虚拟机实例提供网络框架。编辑/etc/neutron/plugins/ml2/ml2_conf.ini文件并完成下列操作:
a.编辑[ml2]小节,启用flat和generic routing encapsulation (GRE)网络类型驱动,配置GRE租户网络和OVS驱动机制。
[ml2]
...
type_drivers= flat,gre
tenant_network_types= gre
mechanism_drivers= openvswitch
b.编辑[ml2_type_flat]小节,配置外部网络:[ml2_type_flat]
...
flat_networks= external
c.编辑[ml2_type_gre]小节,配置隧道标识范围:
[ml2_type_gre]
...
tunnel_id_ranges= 1:1000
d.编辑[securitygroup]小节,启用安全组,启用ipset并配置OVS防火墙驱动:
[securitygroup]
...
enable_security_group= True
enable_ipset= True
firewall_driver= neutron.agent.linux.iptables_firewall.OVSHybridIptablesFirewallDriver
e.编辑[ovs]小节,配置Open vSwitch(OVS) 代理
[ovs]
...
local_ip= INSTANCE_TUNNELS_INTERFACE_IP_ADDRESS
tunnel_type= gre
enable_tunneling= True
bridge_mappings= external:br-ex

image.png

image.png

image.png

image.png


image.png


[root@network ~]# systemctl enable openvswitch.service
ln -s '/usr/lib/systemd/system/openvswitch.service' '/etc/systemd/system/multi-user.target.wants/openvswitch.service'
[root@network ~]# systemctl start openvswitch.service
[root@network ~]# ovs-vsctl add-br br-ex
[root@network ~]# ovs-vsctl add-port br-ex eno50332184
[root@network ~]# ln -s /etc/neutron/plugins/ml2/ml2_conf.ini /etc/neutron/plugin.ini
[root@network ~]# cp/usr/lib/systemd/system/neutron-openvswitch-agent.service/usr/lib/systemd/system/neutron-openvswitch-agent.service.orig
-bash: cp/usr/lib/systemd/system/neutron-openvswitch-agent.service/usr/lib/systemd/system/neutron-openvswitch-agent.service.orig: No such file or directory
[root@network ~]# cp /usr/lib/systemd/system/neutron-openvswitch-agent.service /usr/lib/systemd/system/neutron-openvswitch-agent.service.orig
[root@network ~]# sed -i 's,plugins/openvswitch/ovs_neutron_plugin.ini,plugin.ini,g' /usr/lib/systemd/system/neutron-openvswitch-agent.service
[root@network ~]# systemctl enable neutron-openvswitch-agent.service neutron-l3-agent.service neutron-dhcp-agent.service neutron-metadata-agent.service neutron-ovs-cleanup.service
ln -s '/usr/lib/systemd/system/neutron-openvswitch-agent.service' '/etc/systemd/system/multi-user.target.wants/neutron-openvswitch-agent.service'
ln -s '/usr/lib/systemd/system/neutron-l3-agent.service' '/etc/systemd/system/multi-user.target.wants/neutron-l3-agent.service'
ln -s '/usr/lib/systemd/system/neutron-dhcp-agent.service' '/etc/systemd/system/multi-user.target.wants/neutron-dhcp-agent.service'
ln -s '/usr/lib/systemd/system/neutron-metadata-agent.service' '/etc/systemd/system/multi-user.target.wants/neutron-metadata-agent.service'
ln -s '/usr/lib/systemd/system/neutron-ovs-cleanup.service' '/etc/systemd/system/multi-user.target.wants/neutron-ovs-cleanup.service'
[root@network ~]# systemctl start neutron-openvswitch-agent.service neutron-l3-agent.service neutron-dhcp-agent.service neutron-metadata-agent.service
3、配置compute节点


image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png



4、验证安装


 [root@controller ~]# neutron net-create ext-net --shared --router:external True --provider:physical_network external --provider:network_type flat
Created a new network:
+---------------------------+--------------------------------------+
| Field                     | Value                                |
+---------------------------+--------------------------------------+
| admin_state_up            | True                                 |
| id                        | f4314f21-5fc1-423b-b011-e5ad14de1767 |
| name                      | ext-net                              |
| provider:network_type     | flat                                 |
| provider:physical_network | external                             |
| provider:segmentation_id  |                                      |
| router:external           | True                                 |
| shared                    | True                                 |
| status                    | ACTIVE                               |
| subnets                   |                                      |
| tenant_id                 | dc4de4d7ecda4ed898b5e0d82809d2ad     |
+---------------------------+--------------------------------------+
 创建外部网络子网
[root@controller ~]# neutron subnet-create ext-net --name ext-subnet --allocation-pool start=100.100.100.12,end=100.100.100.240 --disable-dhcp --gateway 100.100.100.11 100.100.100.0/24
Created a new subnet:
+-------------------+-------------------------------------------------------+
| Field             | Value                                                 |
+-------------------+-------------------------------------------------------+
| allocation_pools  | {"start": "100.100.100.12", "end": "100.100.100.240"} |
| cidr              | 100.100.100.0/24                                      |
| dns_nameservers   |                                                       |
| enable_dhcp       | False                                                 |
| gateway_ip        | 100.100.100.11                                        |
| host_routes       |                                                       |
| id                | 1b9c8211-ab2d-4e61-8839-7fc780d201c4                  |
| ip_version        | 4                                                     |
| ipv6_address_mode |                                                       |
| ipv6_ra_mode      |                                                       |
| name              | ext-subnet                                            |
| network_id        | f4314f21-5fc1-423b-b011-e5ad14de1767                  |
| tenant_id         | dc4de4d7ecda4ed898b5e0d82809d2ad                      |
+-------------------+-------------------------------------------------------+

创建租户网络
[root@controller ~]# source demo-openrc.sh 
[root@controller ~]# neutron net-create demo-net
Created a new network:
+-----------------+--------------------------------------+
| Field           | Value                                |
+-----------------+--------------------------------------+
| admin_state_up  | True                                 |
| id              | c882ea04-dde5-4df0-a407-01a2a8dd7743 |
| name            | demo-net                             |
| router:external | False                                |
| shared          | False                                |
| status          | ACTIVE                               |
| subnets         |                                      |
| tenant_id       | ab56bdec367e478cbdfbd1769f9c1649     |
+-----------------+--------------------------------------+

image.png


测试

[root@controller ~]# neutron router-list
+--------------------------------------+-------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------+-------+
| id                                   | name        | external_gateway_info                                                                                                                                                                      | distributed | ha    |
+--------------------------------------+-------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------+-------+
| 5b51cc40-0b8f-45f8-958a-66887d38d6ec | demo-router | {"network_id": "f4314f21-5fc1-423b-b011-e5ad14de1767", "enable_snat": true, "external_fixed_ips": [{"subnet_id": "1b9c8211-ab2d-4e61-8839-7fc780d201c4", "ip_address": "100.100.100.12"}]} | False       | False |
+--------------------------------------+-------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-------------+-------+
C:\Users\Jack>ping 100.100.100.12
正在 Ping 100.100.100.12 具有 32 字节的数据:
来自 100.100.100.12 的回复: 字节=32 时间<1ms TTL=64
来自 100.100.100.12 的回复: 字节=32 时间<1ms TTL=64
来自 100.100.100.12 的回复: 字节=32 时间<1ms TTL=64
来自 100.100.100.12 的回复: 字节=32 时间<1ms TTL=64
100.100.100.12 的 Ping 统计信息:
    数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失),
往返行程的估计时间(以毫秒为单位):
    最短 = 0ms,最长 = 0ms,平均 = 0ms

相关文章
|
1月前
|
SQL 监控 关系型数据库
MySQL主从复制:构建高可用架构
本文深入解析MySQL主从复制原理与实战配置,涵盖复制架构、监控管理、高可用设计及性能优化,助你构建企业级数据库高可用方案。
|
25天前
|
数据采集 运维 监控
构建企业级Selenium爬虫:基于隧道代理的IP管理架构
构建企业级Selenium爬虫:基于隧道代理的IP管理架构
|
2月前
|
监控 Java API
Spring Boot 3.2 结合 Spring Cloud 微服务架构实操指南 现代分布式应用系统构建实战教程
Spring Boot 3.2 + Spring Cloud 2023.0 微服务架构实践摘要 本文基于Spring Boot 3.2.5和Spring Cloud 2023.0.1最新稳定版本,演示现代微服务架构的构建过程。主要内容包括: 技术栈选择:采用Spring Cloud Netflix Eureka 4.1.0作为服务注册中心,Resilience4j 2.1.0替代Hystrix实现熔断机制,配合OpenFeign和Gateway等组件。 核心实操步骤: 搭建Eureka注册中心服务 构建商品
375 3
|
6天前
|
机器学习/深度学习 人工智能 搜索推荐
从零构建短视频推荐系统:双塔算法架构解析与代码实现
短视频推荐看似“读心”,实则依赖双塔推荐系统:用户塔与物品塔分别将行为与内容编码为向量,通过相似度匹配实现精准推送。本文解析其架构原理、技术实现与工程挑战,揭秘抖音等平台如何用AI抓住你的注意力。
128 6
从零构建短视频推荐系统:双塔算法架构解析与代码实现
|
7天前
|
人工智能 监控 测试技术
告别只会写提示词:构建生产级LLM系统的完整架构图​
本文系统梳理了从提示词到生产级LLM产品的八大核心能力:提示词工程、上下文工程、微调、RAG、智能体开发、部署、优化与可观测性,助你构建可落地、可迭代的AI产品体系。
76 2
|
17天前
|
消息中间件 缓存 监控
中间件架构设计与实践:构建高性能分布式系统的核心基石
摘要 本文系统探讨了中间件技术及其在分布式系统中的核心价值。作者首先定义了中间件作为连接系统组件的&quot;神经网络&quot;,强调其在数据传输、系统稳定性和扩展性中的关键作用。随后详细分类了中间件体系,包括通信中间件(如RabbitMQ/Kafka)、数据中间件(如Redis/MyCAT)等类型。文章重点剖析了消息中间件的实现机制,通过Spring Boot代码示例展示了消息生产者的完整实现,涵盖消息ID生成、持久化、批量发送及重试机制等关键技术点。最后,作者指出中间件架构设计对系统性能的决定性影响,
|
27天前
|
传感器 人工智能 算法
分层架构解耦——如何构建不依赖硬件的具身智能系统
硬件与软件的彻底解耦,并通过模块化、分层的架构进行重构,是突破这一瓶颈、构建通用型具身智能系统的核心基石。这种架构将具身智能系统解耦为三个核心层级:HAL、感知决策层和任务执行层。这一模式使得企业能够利用预置的技能库和低代码工具快速配置新任务,在不更换昂贵硬件的前提下,实现从清洁机器人到物流机器人的快速功能切换。本文将通过对HAL技术原理、VLA大模型和行为树等核心技术的深度剖析,并结合Google RT-X、RobotecAI RAI和NVIDIA Isaac Sim等主流框架的案例,论证这一新范式的可行性与巨大潜力,探讨硬件解耦如何将机器人从一个“工具”升级为“软件定义”的“多面手”,从而
182 3
|
2月前
|
存储 自然语言处理 前端开发
百亿级知识库解决方案:从零带你构建高并发RAG架构(附实践代码)
本文详解构建高效RAG系统的关键技术,涵盖基础架构、高级查询转换、智能路由、索引优化、噪声控制与端到端评估,助你打造稳定、精准的检索增强生成系统。
287 2
|
17天前
|
SQL 弹性计算 关系型数据库
如何用读写分离构建高效稳定的数据库架构?
在少写多读业务场景中,主实例读请求压力大,影响性能。通过创建只读实例并使用数据库代理实现读写分离,可有效降低主实例负载,提升系统性能与可用性。本文详解配置步骤,助你构建高效稳定的数据库架构。
|
2月前
|
存储 数据挖掘 调度
像架构拼乐高一样构建采集系统
本教程教你如何构建一个模块化、可扩展的某博热搜采集系统,涵盖代理配置、多线程加速与数据提取,助你高效掌握网络舆情分析技巧。
像架构拼乐高一样构建采集系统

热门文章

最新文章