一、添加私有网络
1. 在controller节点上配置网络组件
1) 配置服务组件
[root@controller ~]# source admin-openrc
[root@controller ~]# openstack-status
[root@controller ~]# vim /etc/neutron/neutron.conf
service_plugins = router
allow_overlapping_ips = True
编辑``/etc/neutron/neutron.conf`` 文件,其他配置在之前已经操作过:
在 [database] 部分,配置数据库访问:
[database]
...
connection = mysql+pymysql://neutron:NEUTRON_DBPASS@controller/neutron
使用你设置的数据库密码替换 NEUTRON_DBPASS 。
在``[DEFAULT]``部分,启用Modular Layer 2 (ML2)插件,路由服务和重叠的IP地址:
[DEFAULT]
...
core_plugin = ml2
service_plugins = router
allow_overlapping_ips = True
在 “[DEFAULT]” 和 “[oslo_messaging_rabbit]”部分,配置 “RabbitMQ” 消息队列的连接:
[DEFAULT]
...
rpc_backend = rabbit
[oslo_messaging_rabbit]
...
rabbit_host = controller
rabbit_userid = openstack
rabbit_password = RABBIT_PASS
用你在RabbitMQ中为``openstack``选择的密码替换 “RABBIT_PASS”。
在 “[DEFAULT]” 和 “[keystone_authtoken]” 部分,配置认证服务访问:
[DEFAULT]
...
auth_strategy = keystone
[keystone_authtoken]
...
auth_uri = http://controller:5000
auth_url = http://controller:35357
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = neutron
password = NEUTRON_PASS
将 NEUTRON_PASS 替换为你在认证服务中为 neutron 用户选择的密码。
在``[DEFAULT]``和``[nova]``部分,配置网络服务来通知计算节点的网络拓扑变化:
[DEFAULT]
...
notify_nova_on_port_status_changes = True
notify_nova_on_port_data_changes = True
[nova]
...
auth_url = http://controller:35357
auth_type = password
project_domain_name = default
user_domain_name = default
region_name = RegionOne
project_name = service
username = nova
password = NOVA_PASS
使用你在身份认证服务中设置的``nova`` 用户的密码替换``NOVA_PASS``。
在 [oslo_concurrency] 部分,配置锁路径:
[oslo_concurrency]
...
lock_path = /var/lib/neutron/tmp
2) 配置 Modular Layer 2 (ML2) 插件
[root@controller ~]# vim /etc/neutron/plugins/ml2/ml2_conf.ini
[ml2]
type_drivers = flat,vlan,vxlan
tenant_network_types = vxlan
mechanism_drivers = linuxbridge,l2population
extension_drivers = port_security
[ml2_type_vxlan]
vni_ranges = 1:1000
ML2插件使用Linuxbridge机制来为实例创建layer-2虚拟网络基础设施
编辑``/etc/neutron/plugins/ml2/ml2_conf.ini``文件,其他配置在在之前已经操作过。
在``[ml2]``部分,启用flat,VLAN以及VXLAN网络:
[ml2]
...
type_drivers = flat,vlan,vxlan
在``[ml2]``部分,启用VXLAN私有网络:
[ml2]
...
tenant_network_types = vxlan
在``[ml2]``部分,启用Linuxbridge和layer-2机制:
[ml2]
...
mechanism_drivers = linuxbridge,l2population
在``[ml2]`` 部分,启用端口安全扩展驱动:
[ml2]
...
extension_drivers = port_security
在``[ml2_type_flat]``部分,配置公共虚拟网络为flat网络
[ml2_type_flat]
...
flat_networks = provider
在``[ml2_type_vxlan]``部分,为私有网络配置VXLAN网络识别的网络范围:
[ml2_type_vxlan]
...
vni_ranges = 1:1000
在 ``[securitygroup]``部分,启用 ipset 增加安全组规则的高效性:
[securitygroup]
...
enable_ipset = True
3)配置Linuxbridge代理
Linuxbridge代理为实例建立layer-2虚拟网络并且处理安全组规则。
编辑``/etc/neutron/plugins/ml2/linuxbridge_agent.ini``文件并且完成以下操作:
在``[linux_bridge]``部分,将公共虚拟网络和公共物理网络接口对应起来:
[linux_bridge]
physical_interface_mappings = provider:PROVIDER_INTERFACE_NAME
将``PUBLIC_INTERFACE_NAME`` 替换为底层的物理公共网络接口(新添加的网卡名字)
在``[vxlan]``部分,启用VXLAN覆盖网络,配置覆盖网络的物理网络接口的IP地址,启用layer-2 population:
[vxlan]
enable_vxlan = True
local_ip = OVERLAY_INTERFACE_IP_ADDRESS
l2_population = True
将``OVERLAY_INTERFACE_IP_ADDRESS`` 替换为处理覆盖网络的底层物理网络接口的IP地址。这个示例架构中使用管理网络接口与其他节点建立流量隧道。因此,将``OVERLAY_INTERFACE_IP_ADDRESS``替换为控制节点的管理网络的IP地址。
在 ``[securitygroup]``部分,启用安全组并配置 Linuxbridge iptables firewall driver:
[securitygroup]
...
enable_security_group = True
firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
[root@controller ~]# vim /etc/neutron/plugins/ml2/linuxbridge_agent.ini
[vxlan]
enable_vxlan = True
local_ip = 192.168.0.1
l2_population = True
4) 配置layer-3代理
##Layer-3代理为私有虚拟网络提供路由和NAT服务
[root@controller ~]# vim /etc/neutron/l3_agent.ini
## 配置Linuxbridge接口驱动和外部网络网桥:
[DEFAULT]
interface_driver = neutron.agent.linux.interface.BridgeInterfaceDriver
external_network_bridge =
##注意:``external_network_bridge``选项特意设置成缺省值,这样就可以在一个代理上允许多种外部网络
5)配置DHCP代理
##编辑``/etc/neutron/dhcp_agent.ini``文件并完成下面的操作:
## 在``[DEFAULT]``部分,配置Linuxbridge驱动接口,DHCP驱动并启用隔离元数据,这样在公共网络上的实例就可以通过网络来访问元数据
[DEFAULT]
...
interface_driver = neutron.agent.linux.interface.BridgeInterfaceDriver
dhcp_driver = neutron.agent.linux.dhcp.Dnsmasq
enable_isolated_metadata = True
6)启动相关服务
## 启用layer-3服务并设置其随系统自启动:
[root@controller ~]# systemctl restart neutron-server.service neutron-linuxbridge-agent.service
[root@controller ~]# systemctl enable --now neutron-l3-agent.service
[root@controller ~]# neutron agent-list
2. 在计算节点上配置网络组件
1) 配置Linuxbridge代理
编辑``/etc/neutron/plugins/ml2/linuxbridge_agent.ini``文件并且完成以下操作:
在``[linux_bridge]``部分,将公共虚拟网络和公共物理网络接口对应起来:
[linux_bridge]
physical_interface_mappings = provider:PROVIDER_INTERFACE_NAME
将``PUBLIC_INTERFACE_NAME`` 替换为底层的物理公共网络接口。
在``[vxlan]``部分,启用VXLAN覆盖网络,配置覆盖网络的物理网络接口的IP地址,启用layer-2 population:
[vxlan]
enable_vxlan = True
local_ip = OVERLAY_INTERFACE_IP_ADDRESS
l2_population = True
将``OVERLAY_INTERFACE_IP_ADDRESS`` 替换为处理覆盖网络的底层物理网络接口的IP地址。这个示例架构中使用管理网络接口与其他节点建立流量隧道。因此,将``OVERLAY_INTERFACE_IP_ADDRESS``替换为控制节点的管理网络的IP地址。
在 ``[securitygroup]``部分,启用安全组并配置 Linuxbridge iptables firewall driver:
[securitygroup]
...
enable_security_group = True
firewall_driver = neutron.agent.linux.iptables_firewall.IptablesFirewallDriver
[root@compute1 ~]# vim /etc/neutron/plugins/ml2/linuxbridge_agent.ini ##其他模块在之前已经配置过
[vxlan]
enable_vxlan = True
local_ip = 192.168.0.2
l2_population = True
2) 启动相关服务
[root@compute1 ~]# systemctl restart neutron-linuxbridge-agent.service
二、Dashboard启用3层网络服务
在控制节点配置
[root@controller ~]# vim /etc/openstack-dashboard/local_settings
OPENSTACK_NEUTRON_NETWORK = {
'enable_router': True,
'enable_quotas': True,
'enable_ipv6': True,
'enable_distributed_router': True,
'enable_ha_router': True,
'enable_lb': True,
'enable_firewall': True,
'enable_vpn': True,
'enable_fip_topology_check': True,
[root@controller ~]# systemctl restart httpd memcached
三、web图形管理界面创建外部网络与私有网络
1.admin用户设置网络为外部网络
2.demo用户查看网络拓扑
3.demo用户创建私有网络
4.选择私有网络创建云主机
##计算节点以命令的方式查看创建的云主机
[root@compute1 ~]# yum install -y libvirt-client
[root@compute1 ~]# virsh list
5. 新建路由使内部网络可以访问外部网络
6.具有私有网络地址的虚拟主机申请公网ip,来使外网可以访问内网
四、封装镜像并上传,创建虚拟主机
官方文档:https://docs.openstack.org/liberty/zh_CN/install-guide-rdo/glance-install.html
1.封装redhat7.6版本镜像
- 物理内存5G,内存1G,双核
- 防火墙、selinux禁掉
- 禁掉kdump,不设置swap和boot分区,直接挂载根
- 添加ip
- 编写软件仓库文件
![在这里插入图片描述](https://img-blog.csdnimg.cn/20210527103450115.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80NTc3NzY2OQ==,size_16,color_FFFFFF,t_70#pic_center)
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# vi dvd.repo
[dvd]
name=rhel7.6
baseurl=http://192.168.0.100/rhel7.6
gpgcheck=0
[root@localhost yum.repos.d]# yum install acpid -y
[root@localhost yum.repos.d]# systemctl enable acpid
2. 做进一步完善
[root@localhost yum.repos.d]# vi cloud.repo
[cloud-init]
name=cloud-init
baseurl=http://192.168.0.100/cloud-init/rhel7
gpgcheck=0
[root@localhost yum.repos.d]# yum repolis
[root@localhost yum.repos.d]# yum install cloud-init cloud-utils-growpart -y
[root@localhost yum.repos.d]# cd /etc/cloud/
[root@localhost cloud]# vi cloud.cfg ##默认不做更改
##对于要访问元数据服务的实例必须要禁用0配置网络:
[root@localhost cloud]# echo "NOZEROCONF=yes" >> /etc/sysconfig/network
[root@localhost cloud]# vi /boot/grub2/grub.cfg ##在内核引导文件中添加以下参数:quietconsole=tty0 console=ttyS0,115200n8
[root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0
BOOTPROTO=dhcp
DEVICE=eth0
ONBOOT=yes
[root@foundation ~]# poweroff
3. 清理压缩镜像
清理虚拟机原本自带信息(把一个镜像文件启动为虚拟机以后,它会生成许多私有信息,比如网卡的mac地址,ip地址,磁盘的uuid,ssh密钥等等)
[root@foundation images]# virt-sysprep -d small
[root@foundation images]# du -h small.qcow2
5.1G small.qcow2
[root@foundation images]# df -h /
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/rhel_foundation50-root 138G 97G 41G 71% /
[root@foundation images]# virt-sparsify --compress small.qcow2 /content/small.qcow2
[root@foundation images]# du -h /content/small.qcow2
513M /content/small.qcow2
[root@foundation html]# mkdir content
[root@foundation html]# cp small.qcow2 content/
4. 上传镜像,创建虚拟机
1)登录admin用户创建镜像
small.qcow2放到apache的默认发布目录下
创建与镜像相匹配的云主机类型
2)登录demo用户以新的镜像创建虚拟机