目录
一、实验
1.环境
(1) 主机
表1 主机
|------------|-------|-----------------|-----|
| 主机 | 架构 | IP | 备注 |
| controller | 控制节点 | 192.168.204.210 | 已部署 |
| compute01 | 计算节点1 | 192.168.204.211 | 已部署 |
| compute02 | 计算节点2 | 192.168.204.212 | 已部署 |
| storage01 | 存储节点1 | 192.168.204.221 | 已部署 |
| storage02 | 存储节点2 | 192.168.204.222 | 已部署 |
| nas | nfs节点 | 192.168.204.229 | 已部署 |
(2)官网
OpenStack Docs: OpenStack Installation Guide for Red Hat Enterprise Linux and CentOS
2.各节点新增网卡准备VXLAN网络
(1)控制节点修改eth1网卡

(2)计算节点1修改eth1网卡

(3)计算节点2修改eth1网卡

(4)控制节点新增网络 ping 计算节点新增网络


3.控制节点配置私有网络
(1)编辑/etc/neutron/neutron.conf 文件
① 在[DEFAULT]部分,启用Modular Layer 2 (ML2)插件,路由服务和重叠的IP地址
bash
[DEFAULT]
...
service_plugins = router
allow_overlapping_ips = True
②备份修改
(2)配置 Modular Layer 2 (ML2) 插件,编辑/etc/neutron/plugins/ml2/ml2_conf.ini文件
① 在[ml2]部分,启用flat,VLAN以及VXLAN网络:
bash
[ml2]
...
type_drivers = flat,vlan,vxlan
② 在[ml2]部分,启用VXLAN私有网络
bash
[ml2]
...
tenant_network_types = vxlan
③ 在[ml2]部分,启用Linuxbridge和layer-2机制
bash
[ml2]
...
mechanism_drivers = linuxbridge,l2population
④ 在[ml2]部分,启用端口安全扩展驱动:
bash
[ml2]
...
extension_drivers = port_security
⑤ 在[ml2_type_vxlan]部分,为私有网络配置VXLAN网络识别的网络范围:
bash
[ml2_type_vxlan]
...
vni_ranges = 20000:30000
⑥备份修改
(3)配置Linuxbridge代理,编辑/etc/neutron/plugins/ml2/linuxbridge_agent.ini文件
① 在[vxlan]部分,启用VXLAN覆盖网络,配置覆盖网络的物理网络接口的IP地址,启用layer-2 population:
bash
[vxlan]
enable_vxlan = True
local_ip = 192.168.199.210
l2_population = True
② 直接修改
(4)配置layer-3代理,编辑/etc/neutron/l3_agent.ini文件
① 在[DEFAULT]部分,配置Linuxbridge接口驱动和外部网络网桥:
bash
[DEFAULT]
...
interface_driver = neutron.agent.linux.interface.BridgeInterfaceDriver
external_network_bridge =
② 直接修改


4.计算节点1配置私有网络
(1)配置Linuxbridge代理,编辑/etc/neutron/plugins/ml2/linuxbridge_agent.ini文件
①在[vxlan]部分,启用VXLAN覆盖网络,配置覆盖网络的物理网络接口的IP地址,启用layer-2 population:
bash
[vxlan]
enable_vxlan = True
local_ip = 192.168.199.211
l2_population = True
② 直接修改


5.计算节点2配置私有网络
(1)配置Linuxbridge代理,编辑/etc/neutron/plugins/ml2/linuxbridge_agent.ini文件
① 在[vxlan]部分,启用VXLAN覆盖网络,配置覆盖网络的物理网络接口的IP地址,启用layer-2 population:
bash
[vxlan]
enable_vxlan = True
local_ip = 192.168.199.212
l2_population = True
② 直接修改


6.重启服务
(1)控制节点重启服务
bash
[root@controller network-scripts]# systemctl restart neutron-server.service \
> neutron-linuxbridge-agent.service neutron-dhcp-agent.service \
> neutron-metadata-agent.service
[root@controller network-scripts]# systemctl enable neutron-l3-agent.service
Created symlink from /etc/systemd/system/multi-user.target.wants/neutron-l3-agent.service to /usr/lib/systemd/system/neutron-l3-agent.service.
[root@controller network-scripts]# systemctl start neutron-l3-agent.service

(2)计算节点1重启服务
bash
[root@compute01 network-scripts]# systemctl restart neutron-linuxbridge-agent.service

(3)计算节点2重启服务
bash
[root@compute02 network-scripts]# systemctl restart neutron-linuxbridge-agent.service

(4)新增L3代理
bash
[root@controller network-scripts]# neutron agent-list

7.修改Dashboard
(1)查看系统网络功能,目前暂无路由功能

(2)控制节点编辑文件 /etc/openstack-dashboard/local_settings
bash
[root@controller ~]# vim /etc/openstack-dashboard/local_settings
① 修改前

②修改后

(3)重启服务
bash
[root@controller ~]# systemctl restart httpd.service memcached.service

(4)重新登录

(5)网络新增路由器功能


8.新建项目(租户)及用户
(1)新建项目
bash
[root@controller ~]# openstack project create --domain default devops03

(2)新建用户
bash
[root@controller ~]# openstack user create --domain default --password Admin@123 --project devops03 user01

(3)修改配置文件
bash
[root@controller ~]# vim keystone_user01
(4)创建角色并关联
bash
[root@controller ~]# openstack role create user
[root@controller ~]# openstack role add --project devops03 --user user01 user

(5)浏览器新建Private窗口

(6)用户user01登录

(7)登录成功

9.新建网络与子网
(1)查看网络

(2)查看网络拓扑

(3)创建测试网络

(4)完成创建

(5)控制节点查看网络
bash
[root@controller ~]# neutron net-show test_user_network | grep provider

(6)修改网络名称

(7)完成更新

(8)新建子网(切换user01用户所在项目环境)
bash
[root@controller ~]# source keystone_user01
[root@controller ~]# neutron subnet-create --name vxlan_subnet_01 \
> --allocation-pool start=172.16.100.50,end=172.16.100.59 \
> --dns-nameserver 8.8.8.8 \
> --gateway 172.16.100.254 \
> Vxlan_user_network01 172.16.100.0/24

(9)查看

10.新建实例
(1)控制节点新建实例cloud-server-vxlan01-01
bash
[root@controller ~]# nova boot --flavor m2.micro --image cirros --nic net-name=Vxlan_user_network01 --security-group default cloud-server-vxlan01-01
(2)新建实例cloud-server-vxlan01-03
bash
[root@controller ~]# nova boot --flavor m2.micro --image cirros --nic net-name=Vxlan_user_network01 --security-group default cloud-server-vxlan01-03

(3) 查看云主机列表
bash
[root@controller ~]# nova list

(4)查看

11.新建路由
(1)查看当前网络

(2)查看当前网络拓扑

(3)admin管理员修改flat网络为外部网络

(4)再次查看网络拓扑

(5)新建路由
bash
[root@controller ~]# neutron router-create router01

(6)查看路由器

(7)查看网络拓扑

(8)查看网络列表
bash
[root@controller ~]# neutron net-list

(9)路由器添加外部网关
bash
[root@controller ~]# neutron router-gateway-set router01 flat_network_01

(10)查看网络拓扑

(11)查看子网信息
bash
[root@controller ~]# neutron subnet-list

(12)路由器添加内部网关
bash
[root@controller ~]# neutron router-interface-add router01 vxlan_subnet_01

(13)查看网络拓扑

(14)查看路由列表
bash
[root@controller ~]# neutron router-list

(15)查看路由器

(16)user01查看接口(devops03项目下用户只能看到内部接口)

(17)admin查看接口(管理员用户能看到内外部接口)

(18)查看交换机

12.新增浮动IP关联云主机实例
(1)新增浮动IP
bash
[root@controller ~]# neutron floatingip-create flat_network_01

(2)查看
bash
[root@controller ~]# neutron floatingip-list

(3)查看云主机列表
bash
[root@controller ~]# nova list

(4)查看端口列表
bash
[root@controller ~]# neutron port-list

(5)浮动IP关联云主机实例cloud-server-vxlan01-01(通过id绑定)
bash
[root@controller ~]# neutron floatingip-associate b4289c34-6cf4-4f16-abb4-303ed987ed0e 362c9a97-9ded-46bc-b16b-1b32f5da8e9b

(6)查看
bash
[root@controller ~]# neutron floatingip-list

(7)可视化界面查看实例(1台云主机都绑定浮动IP)

(8)查看当前安全组


(9)新增安全组入口规则
bash
[root@controller ~]# openstack security group rule create --proto icmp default
[root@controller ~]# openstack security group rule create --proto tcp --dst-port 22 default

(10)查看安全组规则

(11)新增浮动IP
bash
[root@controller ~]# neutron floatingip-create flat_network_01

(12)查看
bash
[root@controller ~]# neutron floatingip-list

(13)浮动IP关联云主机实例cloud-server-vxlan01-03(通过id绑定)
bash
[root@controller ~]# neutron floatingip-associate f9b14337-02c8-48d6-af95-1f36760c5742 fa224427-aa68-451b-bd12-708d6ac1ec84

(14)查看
bash
[root@controller ~]# neutron floatingip-list

(15)可视化界面查看实例(2台云主机都已绑定浮动IP)

二、问题
1.私有网络主要组件相互关系
(1) Modular Layer 2 (ML2) 插件
bash
ML2插件使用Linuxbridge机制来为实例创建layer-2虚拟网络基础设施。
(2)Linuxbridge代理
bash
Linuxbridge代理为实例建立layer-2虚拟网络并且处理安全组规则。
(3)layer-3代理
bash
Layer-3代理为私有虚拟网络提供路由和NAT服务。
(4)DHCP代理
bash
DHCP代理为虚拟网络提供DHCP服务。
2.VXLAN底层如何实现
(1)查看实例cloud-server-vxlan01-01详细信息
bash
[root@controller ~]# nova show cloud-server-vxlan01-01
(2)查看实例cloud-server-vxlan01-03详细信息
bash
[root@controller ~]# nova show cloud-server-vxlan01-03
(3)查看各计算节点实例


(4)获取2个云主机实例信息

(5)查看交换机

(6)计算节点2查看交换机

(7)查看实例cloud-server-vxlan01-01配置文件

关键信息

(8)查看实例cloud-server-vxlan01-03配置文件
关键信息