【SPDK】【NoF】使用SPDK部署NVMe over TCP

SPDK NVMe over Fabrics Target是一个用户空间应用程序,通过以太网,Infiniband或光纤通道等结构呈现块设备,SPDK目前支持RDMA和TCP传输。

本文将在已经编译好SPDK的基础上演示如何使用SPDK搭建NVMe over TCP,前提是您已经将一块NVMe硬盘挂载到linux系统中。

如果您想获取有关SPDK更详细的信息,请参考 官方文档。

演示过程的Host主机的ip地址是192.168.0.21,Target主机的ip地址是192.168.0.22

Target端配置

假设您已经成功编译SPDK

初始化SPDK

进入spdk目录

$ cd spdk

# 运行脚本转让设备控制权给SPDK
$ sudo scripts/setup.sh
0000:03:00.0 (15ad 07f0): nvme -> uio_pci_generic

查看设备状态

$ sudo scripts/setup.sh status

Hugepages

node hugesize free / total

node0 1048576kB 0 / 0

node0 2048kB 1024 / 1024

Type BDF Vendor Device NUMA Driver Device Block devices

NVMe 0000:03:00.0 15ad 07f0 0 uio_pci_generic - -

启动 nvmf-tgf

$ sudo build/bin/nvmf_tgt

创建TCP传输
$ sudo scripts/rpc.py nvmf_create_transport -t TCP -u 16384 -m 8 -c 8192

**创建 NVMe 块设备
$ sudo scripts/rpc.py bdev_nvme_attach_controller -b NVMe1 -t PCIe -a 0000:03:00.0
将NVMe块设备分配给子系统

创建子系统

$ sudo scripts/rpc.py nvmf_create_subsystem nqn.2016-06.io.spdk:cnode1 -a -s SPDK00000000000001 -d SPDK_Controller1**

# 将NVMe块设备分配给刚刚创建的子系统
$ sudo scripts/rpc.py nvmf_subsystem_add_ns nqn.2016-06.io.spdk:cnode1 NVMe1n1

# 为子系统添加TCP监听器
$ sudo scripts/rpc.py nvmf_subsystem_add_listener nqn.2016-06.io.spdk:cnode1 -t TCP -a 192.168.0.22 -s 4420

Host端配置

安装 nvme-cli

$ sudo apt install nvme-cli

加载驱动程序

$ sudo modprobe nvme-tcp

发现 Target
$ sudo nvme discover -t tcp -a 192.168.0.22 -s 4420

Discovery Log Number of Records 1, Generation counter 5

=====Discovery Log Entry 0======

trtype: tcp

adrfam: ipv4

subtype: nvme subsystem

treq: not required

portid: 0

trsvcid: 4420

subnqn: nqn.2016-06.io.spdk:cnode1

traddr: 192.168.0.22

sectype: none

连接Target
$ sudo nvme connect -t tcp -n "nqn.2016-06.io.spdk:cnode1" -a 192.168.0.22 -s 4420

查看设备

$ sudo fdisk -l

...

Disk /dev/nvme0n1: 5 GiB, 5368709120 bytes, 10485760 sectors

Disk model: SPDK_Controller1

Units: sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disklabel type: dos

Disk identifier: 0x441af706

Device Boot Start End Sectors Size Id Type

/dev/nvme0n1p1 2048 10485759 10483712 5G 83 Linux

...

此时可将块设备nvme0n1p1进行挂载访问

取消连接Target

$ nvme disconnect -n "nqn.2016-06.io.spdk:cnode1"

或者

$ nvme disconnect-all

Reference

[1]: https://spdk.io/doc/nvmf.html

[2]: https://www.cnblogs.com/JamesLi/p/11399054.html

相关推荐
Ciderw6 天前
SPDK从安装到运行hello_world示例程序
架构·nvme·存储·spdk
robin591125 天前
SPDK 部署NVMe over TCP
网络·网络协议·tcp/ip·spdk
大隐隐于野8 个月前
spdk技术原理简介和实践经验
spdk
大隐隐于野9 个月前
NVMe-oF RDMA vs. TCP延时测试对比:端到端SPDK的意义
网络·网络协议·tcp/ip·spdk·nvmeof
大隐隐于野9 个月前
【SPDK】【NoF】使用SPDK实现NVMe over Fabrics Target
spdk·nof
大隐隐于野1 年前
利用SPDK改善NVMe存储I/O性能
spdk
大隐隐于野1 年前
spdk用户态块层详解
spdk