在虚拟机上部署SPDK NVME测试案例

1 背景介绍_

正如我们之前在微信中所讨论的在物理机器[1]上使用SoftRoCE部署SPDK NVMe-oF的方法一样,现在,我们将要讨论在虚拟机上使用部署SPDK NVMe测试案例[2]的方法。为什么我们需要在虚拟机上部署它呢?原因很明显随着主机CPU Core越来越强大,我们需要有效地利用CPU Core,而对于不同种类且不需要太多计算和内存资源的功能测试来说,我们可以充分利用虚拟机运行功能测试如NVMe,vhost,iSCSI测试。限于篇幅,这篇文章主要介绍如何在VM上部署SPDK NVME测试案例。后面会有陆续介绍vhost和iSCSI的介绍。同时在9月北京的峰会我们也会做一些相应的介绍。

希望通过这篇文章能让大家熟悉SPDK,不管在真实NVMe SSD场景下,还是在虚拟环境下。

_2 配置虚拟机环境_

在Windows10(1607)操作系统的机器上配置虚拟机的步骤如下所示:

1.安装VirtualBox(https://www.virtualbox.org/wiki/Downloads)及其相关组件,需要安装两个安装包

  • 在BIOS里面确保VT选项是打开的,安装VirtualBox5.1.38 或者更新版本(建议使用5.1.38版本)

  • 搜索“Windows features”并关闭Hyper-V选项,重启windows 操作系统,安装VirtualBox ExtensionPack(https://www.virtualbox.org/wiki/Downloads)5.1.38版本或者更新版本(同样建议使用5.1.38版本)

2.安装Vagrant(https://www.vagrantup.com/)1.9.4版本或者更新版本(建议使用1.9.4版本)

3.安装Git Bash(https://www.git-scm.com/download/win)(版本不做要求)

4.打开Gitbash终端,下载SPDK代码并创建虚拟机环境

a.如果有防火墙,建议使用代理来提高下载速度

  i.设置http_proxy和https_proxy代理,命令行如下

$export https_proxy=

$export http_proxy=

  ii.安装proxyconf plugin,命令如下

$vagrant plugin install vagrant-proxyconf

b.下载SPDK代码,命令行如下

$git clone https://github.com/spdk/spdk.git

c.编译并创建虚拟机,命令行如下

$cd spdk/

$git submodule update –init

$./spdk/scripts/vagrant/create_vbox.sh –n 4  –s 4096 fedora28

-n指定虚拟机CPU数量,-s指定虚拟机内存大小,执行这一步如遇到下面的问题,则很有可能是网络不够稳定或者网速太慢,可以选择一个网速比较稳定或者快的时间重新下载

d.登录虚拟机,命令如下

$cd fedora28-virtualbox

$vagrant ssh

恭喜你!从现在开始,你可以登录虚拟机工作了

e.验证虚拟NVMe设备是否存在,命令行如下

$lspci | grep “Non-Volatile”

00:0e.0 Non-Volatile  memory controller: InnoTek Systemberatung GmbH Device 4e56

f.同样,在虚拟机里面,也需要对代理进行设置,然后编译SPDK代码,命令行如下:

$apt-get update

$cd ~/spdk_repo/spdk

$git submodule update –init

如果无法成功执行上面的命令,可以尝试重新下载SPDK代码,命令为

$git  clone https://github.com/spdk/spdk.git

$scripts/pkgdep.sh

如果出现警告可以使用如下命令进行清除

$git reset --hard

$make

g.通过运行hello_word实例来验证SPDK安装成功

$script/setup.sh

$cd examples/bdev/hello_world/

$./hello_bdev –c bdev.conf

_3 在VM上部署SPDK NVMe测试案例_

在examples目录运行NVMe测试案例


1.运行setup.sh脚本

$cd /home/vagrant/spdk_repo/spdk

$./scripts/setup.sh

0000:00:0e.0 (80ee 4e56): nvme -> uio_pci_generic

2.在examples目录下运行NVMe的hello_world测试案例来确保环境已经能够正常使用虚拟的nvme设备

$./examples/nvme/hello_world/hello_world

Starting SPDK v19.10-pre / DPDK 19.05.0 initialization...

[ DPDK EAL parameters: hello_world -c 0x1  --log-level=lib.eal:6 --log-level=lib.cryptodev:5 --log-level=user1:6  --base-virtaddr=0x200000000000 --match-allocations --file-prefix=spdk0  --proc-type=auto ]

Initializing NVMe Controllers

Attaching to 0000:00:0e.0

Attached to 0000:00:0e.0

Using controller ORCL-VBOX-NVME-VER12 (VB1234-56789        ) with 1 namespaces.

  Namespace ID: 1  size: 1GB

Initialization complete.

INFO: using host memory buffer for IO

Hello world!

3.在examples目录下运行NVMe的perf测试案例测试各种IO的性能

$./examples/nvme/perf/perf  -q 128 -o 4096 -w randread -r 'trtype:PCIe traddr:0000:00:0e.0' -t 10

Starting SPDK v19.10-pre / DPDK 19.05.0 initialization...

[ DPDK EAL parameters: perf --no-shconf -c 0x1  --log-level=lib.eal:6 --log-level=lib.cryptodev:5 --log-level=user1:6  --base-virtaddr=0x200000000000 --match-allocations --file-prefix=spdk_pid7543  ]

Initializing NVMe Controllers

Attaching to NVMe Controller at 0000:00:0e.0

Attached to NVMe Controller at 0000:00:0e.0 [80ee:4e56]

Associating PCIE (0000:00:0e.0) with lcore 0

Initialization complete. Launching workers.

Starting thread on core 0

========================================================

                                                                     Latency(us)

Device Information             :       IOPS      MiB/s     Average        min        max

PCIE (0000:00:0e.0) from core 0:    6257.30      24.44    20476.55    2274.99   31814.34

========================================================

Total                          :    6257.30      24.44    20476.55    2274.99   31814.34

4.在examples目录下运行NVMe的nvme_manage测试案例,这里nvme_manage可用来查看controller的信息,创建namespace以及更新firmware等,具体可以通过选择相应数字选项来操作

$./examples/nvme/nvme_manage/nvme_manage

Starting SPDK v19.10-pre / DPDK 19.05.0 initialization...

[ DPDK EAL parameters: nvme_manage --no-shconf -c 0x1  --log-level=lib.eal:6 --log-level=lib.cryptodev:5 --log-level=user1:6 --base-virtaddr=0x200000000000  --match-allocations --file-prefix=spdk_pid7547 ]

NVMe Management Options

        [1: list  controllers]

        [2: create  namespace]

        [3: delete  namespace]

        [4: attach  namespace to controller]

        [5: detach  namespace from controller]

        [6: format  namespace or controller]

        [7: firmware  update]

        [8: opal]

        [9: quit]

5.在examples目录下运行NVMe的identify测试案例,用于查看SSD的vendorID,firmware以及型号等信息

$./examples/nvme/identify/identify

Starting SPDK v19.10-pre / DPDK 19.05.0 initialization...

[ DPDK EAL parameters: identify --no-shconf -c 0x1 -n 1 -m  0 --log-level=lib.eal:6 --log-level=lib.cryptodev:5 --log-level=user1:6  --base-virtaddr=0x200000000000 --match-allocations --file-prefix=spdk_pid7554  ]

=====================================================

NVMe Controller at 0000:00:0e.0 [80ee:4e56]

=====================================================

Controller Capabilities/Features

================================

Vendor ID:                             80ee

Subsystem Vendor ID:                   80ee

Serial Number:                         VB1234-56789

Model Number:                           ORCL-VBOX-NVME-VER12

Firmware Version:                      1.0

Recommended Arb Burst:                 0

IEEE OUI Identifier:                   00 00 00

Multi-path I/O

  May have multiple  subsystem ports:   No

  May be connected to  multiple hosts:  No

  Associated with  SR-IOV VF:           No

Max Data Transfer Size:                Unlimited

Error Recovery Timeout:                 Unlimited

NVMe Specification Version (VS):       1.2

NVMe Specification Version (Identify): 1.2

Maximum Queue Entries:                 4096

Contiguous Queues Required:            Yes

Arbitration Mechanisms Supported

  Weighted Round  Robin:                Not Supported

  Vendor  Specific:                     Not  Supported

Reset Timeout:                         5000 ms

Doorbell Stride:                       4 bytes

NVM Subsystem Reset:                   Not Supported

Command Sets Supported

  NVM Command  Set:                     Supported

Boot Partition:                        Not Supported

Memory Page Size Minimum:              4096 bytes

Memory Page Size Maximum:              4096 bytes

Optional Asynchronous Events Supported

  Namespace Attribute  Notices:         Not Supported

  Firmware Activation  Notices:         Not Supported

128-bit Host Identifier:               Not Supported

限于篇幅,后续的打印日志省略

在test目录运行nvme测试案例


1.运行aer测试案例

$./test/nvme/aer/aer -r 'trtype:PCIe traddr:0000:00:0e.0'

Starting SPDK v19.10-pre / DPDK 19.05.0 initialization...

[ DPDK EAL parameters: aer --no-shconf -c 0x1  --log-level=lib.eal:6 --log-level=lib.cryptodev:5 --log-level=user1:6  --base-virtaddr=0x200000000000 --match-allocations --file-prefix=spdk_pid7715  ]

Asynchronous Event Request test

Attaching to 0000:00:0e.0

Attached to 0000:00:0e.0

Registering asynchronous event callbacks...

Cleaning up...

2.运行e2edp测试案例

$./test/nvme/e2edp/nvme_dp

Starting SPDK v19.10-pre / DPDK 19.05.0 initialization...

[ DPDK EAL parameters: nvme_dp -c 0x1 --log-level=lib.eal:6  --log-level=lib.cryptodev:5 --log-level=user1:6  --base-virtaddr=0x200000000000 --match-allocations --file-prefix=spdk0  --proc-type=auto ]

NVMe Write/Read with End-to-End data protection test

Attaching to 0000:00:0e.0

Attached to 0000:00:0e.0

Cleaning up...

3.运行run_perf.sh命令

$ ./test/nvme/perf/run_perf.sh --numjobs=1 --iodepth=128  --rw=randread --fio-bin=/usr/src/fio/fio --ramp-time=10 --run-time=10

++++ dirname ./test/nvme/perf/run_perf.sh

+++ readlink -f ./test/nvme/perf

++ BASE_DIR=/home/vagrant/spdk/test/nvme/perf

+++ readlink -f /home/vagrant/spdk/test/nvme/perf/../../..

++ ROOT_DIR=/home/vagrant/spdk

++  PLUGIN_DIR_NVME=/home/vagrant/spdk/examples/nvme/fio_plugin

++  PLUGIN_DIR_BDEV=/home/vagrant/spdk/examples/bdev/fio_plugin

++ BDEVPERF_DIR=/home/vagrant/spdk/test/bdev/bdevperf

++ . /home/vagrant/spdk/scripts/common.sh

++ . /home/vagrant/spdk/test/common/autotest_common.sh

+++ xtrace_disable

+++ PREV_BASH_OPTS=ehxB

+++ set +x

   01:27:46     # xtrace_enable

  01:27:46      #  NVME_FIO_RESULTS=/home/vagrant/spdk/test/nvme/perf/result.json

  01:27:46      # PRECONDITIONING=true

  01:27:46      # FIO_BIN=/usr/src/fio/fio

  01:27:46      # RUNTIME=600

  01:27:46      # PLUGIN=nvme

  01:27:46      # RAMP_TIME=30

  01:27:46      # BLK_SIZE=4096

  01:27:46      # RW=randrw

  01:27:46      # MIX=100

  01:27:46      # IODEPTH=256

  01:27:46      # DISKNO=1

  01:27:46      # ONEWORKLOAD=false

  01:27:46      # CPUS_ALLOWED=1

  01:27:46      # NUMJOBS=1

  01:27:46      # REPEAT_NO=3

  01:27:46      # NOIOSCALING=false

  01:27:46      # getopts h-: optchar

  01:27:46      # case "$optchar" in

  01:27:46      # case "$OPTARG" in

  01:27:46      # NUMJOBS=1

限于篇幅,这里只列出前面几行的打印日志

最后的测试性能数据保存在下列文件中: /home/vagrant/spdk/test/nvme/perf/results/perf_results_4096BS_128QD_randread_100MIX_nvme_08_05_2019_012746/perf_results_4096BS_128QD_randread_100MIX_nvme_08_05_2019_012746.csv

_4 问题解答_

1.在虚拟机中使用自动测试运行时,如果遇到以下问题,说明虚拟机没有给虚拟机中的大页面分配足够的内存,则需要在虚拟机创建时分配更多内存,如12288KB

## ERROR: requested 4096 hugepages but only  1719 could be allocated.

## Memory might be heavily fragmented. Please try flushing the system  cache, or reboot the machine.

0000:00:0e.0 (80ee 4e56): uio_pci_generic -> nvme

Clean

2.当用下列命令创建虚拟机的时候,如果遇到网速不稳定或者网速较慢的时候,会遇到如下问题,可以通过选择一个网速较快的时段下

$/spdk/scripts/vagrant/create_vbox.sh –n 4 –s4096 fedora28

Errormessage: An error occurred while downloading the remote file. The error

message,if any, is reproduced below. Please fix this error and try again. OpenSSLSSL_read: SSL_ERROR_SYSCALL, errno 10054

原文链接:https://mp.weixin.qq.com/s/Cg-6a8avDVwkxNya5b0j1g

 
学习更多dpdk资料
DPDK 学习资料、视频和学习路线图 :https://space.bilibili.com/1600631218
Dpdk/网络协议栈/ vpp /OvS/DDos/NFV/虚拟化/高性能专家 学习地址: https://ke.qq.com/course/5066203?flowToken=1043799
DPDK开发学习资料、教学视频和学习路线图分享有需要的可以自行添加学习交流q 君羊909332607 获取

猜你喜欢

转载自blog.csdn.net/weixin_60043341/article/details/126624167