安装完openstack的必要组件keystone,nova,glance,neutron以后就可以使用openstack命令创建一台云虚拟机了
------------------- 完美的分割线 --------------------
8.0.neutron的两种虚拟网络
对于实际的网络环境,购买好路由器交换机等网络设备后,还需要连接网线,配置局域网络才可以让服务器正常连接上网。
同样,对于openstack,安装好neutron只相当于购买好了网络设备,仍然需要创建一个虚拟的网络才可以让虚拟机在里面运行。
对于openstack的虚拟网络,在安装neutron时只进行了简单的叙述,有两种模式:
1)Provider network(提供者网络)
# 网络结构图参考:https://docs.openstack.org/install-guide/launch-instance-networks-provider.html
简单理解就是与现有物理网络桥接起来的网络,网络结构图如下,
在这种网络中,集群中的各个节点通过物理网络连接,节点内部通过L2(provider网桥/交换机)与物理网络进行连接,这个网络可以包括为实例提供IP地址的DHCP服务器。
集群中的实例(虚拟机)通过Provider网络为其分配映射的tap端口与桥接网卡传输数据从而进行内外部通信,类似kvm虚拟机采用桥接模式使得网络结构,网络结构示意图如下:
# ok
2)Self-service network(自服务网络)
# 网络结构图参考:https://docs.openstack.org/install-guide/launch-instance-networks-selfservice.html
类似阿里云的内部私有网络,可以让使用者自己构建一个内部使用对外隔离的网络,结构如下图:
是在provider网络上的扩展,通过self-service网桥使用vxlan技术创建一个独立的网络,这个独立的网络也可以通过vxlan tunnels连接到物理网络进行数据传输
网络连接拓扑图如下:
# ok
8.1.创建provider提供者网络
1)在控制节点上,创建网络接口
# 加载 admin 凭证来获取管理员能执行的命令访问权限
cd /server/tools/ source keystone-admin-pass.sh openstack network create --share --external --provider-physical-network provider --provider-network-type flat provider
openstack network list
# 实例演示:
[root@openstack01 tools]# openstack network create --share --external --provider-physical-network provider --provider-network-type flat provider +---------------------------+--------------------------------------+ | Field | Value | +---------------------------+--------------------------------------+ | admin_state_up | UP | | availability_zone_hints | | | availability_zones | | | created_at | 2018-11-06T06:34:01Z | | description | | | dns_domain | None | | id | 25346d04-0f1f-4277-b896-ba3f01425d86 | | ipv4_address_scope | None | | ipv6_address_scope | None | | is_default | None | | is_vlan_transparent | None | | mtu | 1500 | | name | provider | | port_security_enabled | True | | project_id | 3706708374804e2eb4ed056f55d84666 | | provider:network_type | flat | | provider:physical_network | provider | | provider:segmentation_id | None | | qos_policy_id | None | | revision_number | 0 | | router:external | External | | segments | None | | shared | True | | status | ACTIVE | | subnets | | | tags | | | updated_at | 2018-11-06T06:34:01Z | +---------------------------+--------------------------------------+ [root@openstack01 tools]# openstack network list +--------------------------------------+----------+---------+ | ID | Name | Subnets | +--------------------------------------+----------+---------+ | 25346d04-0f1f-4277-b896-ba3f01425d86 | provider | | +--------------------------------------+----------+---------+
# 附:旧版的命令(在这个版本中会少创建一些东西),可以参考
neutron net-create --shared --provider:physical_network [自定义的物理网卡的名称] --provider:network_type flat(单一扁平网络) [创建的虚拟网络名称]
neutron net-create --shared --provider:physical_network provider --provider:network_type flat provider
2)检查网络配置
# 确认ml2_conf.ini以下配置选项
# 上面的命令--provider-network-type flat网络名称provider与此对应
vim /etc/neutron/plugins/ml2/ml2_conf.ini ----------------------------- [ml2_type_flat] flat_networks = provider -----------------------------
# 确认linuxbridge_agent.ini以下配置选项
# 上面的命令--provider-physical-network provider于此对应,网卡注意要于此对应,控制节点的网卡名称
vim /etc/neutron/plugins/ml2/linuxbridge_agent.ini ----------------------------- [linux_bridge] physical_interface_mappings = provider:eno16777736 -----------------------------
3)创建provider子网
openstack subnet create --network provider --no-dhcp --allocation-pool start=192.168.1.210,end=192.168.1.220 --dns-nameserver 4.4.4.4 --gateway 192.168.1.1 --subnet-range 192.168.1.0/24 provider-subnet01 openstack subnet create --network provider --dhcp --subnet-range 192.168.2.0/24 provider-subnet02 openstack subnet list
# 实例演示:
[root@openstack01 tools]# openstack subnet create --network provider --no-dhcp --allocation-pool start=192.168.1.210,end=192.168.1.220 --dns-nameserver 4.4.4.4 --gateway 192.168.1.1 --subnet-range 192.168.1.0/24 provider-subnet01 +-------------------+--------------------------------------+ | Field | Value | +-------------------+--------------------------------------+ | allocation_pools | 192.168.1.210-192.168.1.220 | | cidr | 192.168.1.0/24 | | created_at | 2018-11-12T12:48:08Z | | description | | | dns_nameservers | 4.4.4.4 | | enable_dhcp | False | | gateway_ip | 192.168.1.1 | | host_routes | | | id | 2aaf50aa-ab80-4ed5-99c8-58d4d4d31ff3 | | ip_version | 4 | | ipv6_address_mode | None | | ipv6_ra_mode | None | | name | provider-subnet01 | | network_id | 25346d04-0f1f-4277-b896-ba3f01425d86 | | project_id | 3706708374804e2eb4ed056f55d84666 | | revision_number | 0 | | segment_id | None | | service_types | | | subnetpool_id | None | | tags | | | updated_at | 2018-11-12T12:48:08Z | +-------------------+--------------------------------------+ [root@openstack01 tools]# openstack subnet create --network provider --dhcp --subnet-range 192.168.2.0/24 provider-subnet02 +-------------------+--------------------------------------+ | Field | Value | +-------------------+--------------------------------------+ | allocation_pools | 192.168.2.2-192.168.2.254 | | cidr | 192.168.2.0/24 | | created_at | 2018-11-12T12:48:13Z | | description | | | dns_nameservers | | | enable_dhcp | True | | gateway_ip | 192.168.2.1 | | host_routes | | | id | 0d21b823-ae0c-4c3e-87e6-22e3b2d794c4 | | ip_version | 4 | | ipv6_address_mode | None | | ipv6_ra_mode | None | | name | provider-subnet02 | | network_id | 25346d04-0f1f-4277-b896-ba3f01425d86 | | project_id | 3706708374804e2eb4ed056f55d84666 | | revision_number | 0 | | segment_id | None | | service_types | | | subnetpool_id | None | | tags | | | updated_at | 2018-11-12T12:48:13Z | +-------------------+--------------------------------------+ [root@openstack01 tools]# openstack subnet list +--------------------------------------+-------------------+--------------------------------------+----------------+ | ID | Name | Network | Subnet | +--------------------------------------+-------------------+--------------------------------------+----------------+ | 0d21b823-ae0c-4c3e-87e6-22e3b2d794c4 | provider-subnet02 | 25346d04-0f1f-4277-b896-ba3f01425d86 | 192.168.2.0/24 | | 2aaf50aa-ab80-4ed5-99c8-58d4d4d31ff3 | provider-subnet01 | 25346d04-0f1f-4277-b896-ba3f01425d86 | 192.168.1.0/24 | +--------------------------------------+-------------------+--------------------------------------+----------------+
# 至此,provider网络创建完成,可以创建虚拟机
8.3.在
8.3.创建私有网络
#Create the self-service network
https://docs.openstack.org/install-guide/launch-instance-networks-selfservice.html
1)创建私有网络接口