环境说明:OpenStack版本为pike
一、开启SRIOV(bios中默认开启)请先做好备份
[博主对控制和计算节点都做了修改,如有问题,还请指正]
①在/etc/default/grub中增加 “intel_iommu=on”
vi /etc/default/grub
GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet intel_iommu=on"
②执行
grub2-mkconfig -o /boot/grub2/grub.cfg
reboot
③确定你要使用的物理口 本例使用eth0 eth1
echo 4 > /sys/class/net/eth0/device/sriov_numvfs
echo 4 > /sys/class/net/eth1/device/sriov_numvfs
二、计算节点
①安装sriov-agent
yum install openstack-neutron-sriov-nic-agent
②编辑sriov-agent配置文件
vi /etc/neutron/plugins/ml2/sriov_agent.ini
[sriov_nic]
physical_device_mappings = sriov1:eth0,sriov2:eth1
③启动sriov-agent服务
systemctl restart neutron-sriov-nic-agent.service
④修改nova配置
vi /etc/nova/nova.conf
passthrough_whitelist = [{"devname":"eth0", "physical_network":"sriov1"},{"devname":"eth1", "physical_network":"sriov2"}]
⑤重启nova-compute服务
systemctl restart openstack-nova-compute.service
三、控制节点
①编辑nova配置文件
vi /etc/nova/nova.conf
available_filters=nova.scheduler.filters.all_filters
enabled_filters=RetryFilter,AvailabilityZoneFilter,ComputeFilter,ComputeCapabilitiesFilter,ImagePropertiesFilter,ServerGroupAntiAffinityFilter,ServerGroupAffinityFilter,PciPassthroughFilter
②重启nova-scheduler服务
systemctl restart openstack-nova-scheduler.service
③编辑neutron配置文件
vi /etc/neutron/plugins/ml2/ml2_conf.ini
mechanism_drivers = openvswitch,l2population,sriovnicswitch
编辑/etc/neutron/plugins/ml2/ml2_conf_sriov.ini配置文件【不存在则新建】
lspci -nn |grep net查看vendor and product id
vi /etc/neutron/plugins/ml2/ml2_conf_sriov.ini
[ml2_sriov]
supported_pci_vendor_devs = 8086:1520
agent_required = True
增加config-file
vi /usr/lib/systemd/system/neutron-server.service
--config-file /etc/neutron/plugins/ml2/ml2_conf_sriov.ini
④添加映射关系(相信大家使用flat网络和vlan网络的话,比较熟悉)
vi /etc/neutron/plugins/ml2/ml2_conf.ini
[ml2_type_vlan]
flat_networks = provider1,sriov1,sriov2
⑤重启neutron服务
systemctl daemon-reload
systemctl restart neutron-server.service
四、创建云主机
以上配置已完成,接下来我们进行网络创建,云主机使用此网络。
①创建网络flat_sriov192
neutron net-create flat_sriov192 --provider:network_type vlan --provider:physical_network sriov1 --provider:segmentation_id 192
②创建子网sriov_subnet192
neutron subnet-create flat_sriov192 --name sriov_subnet192 --allocation-pool start=192.85.1.1,end=192.85.1.253 --gateway 192.85.1.254 192.85.1.0/24 --disable-dhcp
③创建网络flat_sriov193
neutron net-create flat_sriov193 --provider:network_type vlan --provider:physical_network sriov2 --provider:segmentation_id 193
④创建子网sriov_subnet193
neutron subnet-create flat_sriov193 --name sriov_subnet193 --allocation-pool start=193.85.1.1,end=193.85.1.253 --gateway 193.85.1.254 193.85.1.0/24 --disable-dhcp
⑤创建port riov-192-1
neutron port-create flat_sriov192 --name sriov-192-1 --binding:vnic-type direct
⑥创建port riov-193-1
neutron port-create flat_sriov193 --name sriov-193-1 --binding:vnic-type direct
⑦使用port启动云主机(可自行添加管理网络,便于管理)
nova boot --flavor m1.mid \
--image 3ae6ba6d-cf3e-49e2-9521-ad6e49f598a0 \
--nic port-id=1245fgdf-a665-42b4-a046-264c07dbad43 \
--nic port-id=0gfd44c9-d4bb-470c-b370-05b8197af463 \
sriov-vm1
flavor:云主机类型名称
image:镜像id
port_id:步骤⑤⑥所创建port对应id