Tuning Data Drives
Install and enable the SPDK to significantly improve the I/O performance of data drives and reduce latency, thereby enhancing the performance of the MySQL database.
- Install the SPDK.
git clone https://github.com/spdk/spdk -b v21.01.1 cd spdk git submodule update --init ./configure --with-shared --enable-debug --disable-tests --disable-unit-tests make -j`nproc` make -j`nproc` install ln -s `pwd`/build/bin/vhost /usr/bin/vhost ln -s `pwd`/scripts/rpc.py /usr/bin/rpc export LIBRARY_PATH=/usr/local/lib:/home/spdk/dpdk/build-tmp/lib:/home/spdk/dpdk/build/lib:${LIBRARY_PATH} export LD_LIBRARY_PATH=/usr/local/lib:/home/spdk/dpdk/build-tmp/lib:/home/spdk/dpdk/build/lib:${LD_LIBRARY_PATH} - Start the vhost process and specify the CPU IDs for polling. For example, specify the CPU IDs as 8, 9, 10, 11.
vhost -S /var/tmp -m [8,9,10,11] &
- [8, 9, 10, 11] indicates the CPU IDs for polling, which can be adjusted as required.
- It is recommended that the core binding operation in this step and core binding operation in 2 be on the same NUMA node.
- Create a block device and a controller.
- Creates an AIO block device.
rpc bdev_aio_create /dev/nvme0n1p5 aio_0 512
- /dev/nvme0n1p5 indicates the volume name, which can be a .image file of QEMU or an RBD device.
- aio_0 indicates the name of the block device.
- 512 indicates the block size.
- Creates a vhost blk controller.
rpc vhost_create_blk_controller vhost.0 aio_0
vhost.0 indicates the socket file name. The preceding command generates a socket file in /var/tmp/vhost.0.
- Creates an AIO block device.
- Add the SPDK data drive to the VM XML configuration file.
1 2 3 4 5 6 7
<disk type='vhostuser' device='disk' snapshot='no'> <driver name='qemu' type='raw' queues='8'/> <source type='unix' path='/var/tmp/vhost.0'> <reconnect enabled='yes' timeout='10'/> </source> <target dev='vdb' bus='virtio'/> </disk>
The value of queues cannot exceed the number of CPUs on the VM. Otherwise, the VM cannot be started.
The SPDK environment deployment is complete, and the data drive provided by the SPDK can be used on the VM.
Parent topic: MySQL Performance Tuning