多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
[TOC] ## 新增网络说明 我们的openstack当前环境只有一个基于eth0网卡桥接的,它能使用的ip范围有限,就决定着它能创建的实例数量有限,无法超过可用ip的数量 当我们的openstack私有云规模比较大的时候,这时候只有一个网络,就不能满足我们的需求了,所以这里我们来学习如何增加一个网络 我们使用的环境是VMware workstation,无法模拟vlan的场景,所以这里我们继续使用flat,网络类型 需要先在虚拟机中添加好一个网卡 ## 实操步骤 | 主机名 | eth0(默认) | eth1(flat测试) | | --- | --- | --- | | controller | 10.0.0.11 | 172.16.0.11 | | compute01 | 10.0.0.31 | 172.16.0.31 | | compute02 | 10.0.0.32 | 172.16.0.32 | ### 1:控制节点修改配置 **a:修改ml2/ml2_conf.ini文件** 先查看`ml2_type_flat`模块`flat_networks`项的原值 ```sh cat /etc/neutron/plugins/ml2/ml2_conf.ini|grep -A1 ml2_type_flat ``` > [ml2_type_flat] flat_networks = provider 在原值的基础上增加性新网络net172_16并查看结果 ```sh abc=$(openstack-config --get /etc/neutron/plugins/ml2/ml2_conf.ini ml2_type_flat flat_networks) openstack-config --set /etc/neutron/plugins/ml2/ml2_conf.ini ml2_type_flat flat_networks $abc,net172_16 cat /etc/neutron/plugins/ml2/ml2_conf.ini|grep -A1 ml2_type_flat ``` > [ml2_type_flat] flat_networks = provider,net172_16 **b:修改linuxbridge_agent.ini文件** 先查看`linux_bridge`模块`physical_interface_mappings`的值 ```sh cat /etc/neutron/plugins/ml2/linuxbridge_agent.ini|grep -A1 linux_bridge ``` > [linux_bridge] physical_interface_mappings = provider:eth0 添加新值并验证 ```sh abc=$(openstack-config --get /etc/neutron/plugins/ml2/linuxbridge_agent.ini linux_bridge physical_interface_mappings) openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini linux_bridge physical_interface_mappings $abc,net172_16:eth1 cat /etc/neutron/plugins/ml2/linuxbridge_agent.ini|grep -A1 linux_bridge ``` > [linux_bridge] physical_interface_mappings = provider:eth0,net172_16:eth1 **c:重启服务** ```sh systemctl restart neutron-server.service neutron-linuxbridge-agent.service ``` ### 2:计算节点修改配置 **a:修改ml2/linuxbridge_agent.ini文件** 修改方法同上,就不先查看而直接修改 ```sh abc=$(openstack-config --get /etc/neutron/plugins/ml2/linuxbridge_agent.ini linux_bridge physical_interface_mappings) openstack-config --set /etc/neutron/plugins/ml2/linuxbridge_agent.ini linux_bridge physical_interface_mappings $abc,net172_16:eth1 cat /etc/neutron/plugins/ml2/linuxbridge_agent.ini|grep -A1 linux_bridge ``` > [linux_bridge] physical_interface_mappings = provider:eth0,net172_16:eth1 **b:重启服务** ```sh systemctl restart neutron-linuxbridge-agent.service ``` ### 3:命令行创建网络-控制节点: ```sh neutron net-create --shared --provider:physical_network net172_16 --provider:network_type flat net172_16 neutron subnet-create --name net172_16_01 \ --allocation-pool start=172.16.0.1,end=172.16.0.250 \ --dns-nameserver 223.5.5.5 --gateway 172.16.0.254 \ net172_16 172.16.0.0/24 ``` ### 4:设置内核转发-控制节点 基于net172_16网络上网,路由器服务器需要配置: 编辑内核配置文件,开启转发 ```sh echo "net.ipv4.ip_forward = 1" >>/etc/sysctl.conf sysctl -p #清空防火墙的filter表并添加转发规则 iptables -F iptables -t nat -A POSTROUTING -s 172.16.0.0/24 -j MASQUERADE ``` ## web界面操作 新网络类型已经配置完成,可以通过web界面使用了