使用Directio时,如果具有多个具有不同扇区大小的安装点,Nginx无法读取文件。
我们的服务器在Nginx的根文件夹下安装了不同的硬盘。我们所有的旧磁盘的扇区大小均为512,当我们更换磁盘时,Nginx突然无法从该磁盘读取文件。
服务器上似乎没有什么问题,我们可以毫无问题地列出/读取文件,但是Nginx不能。在error_log中向客户端发送响应时显示失败(22:无效参数)。
[crit] pread() "/str/.../dsf13at.mp4" failed (22: Invalid argument) while sending response to client
[crit] pread() "/str/.../dsf13at.mp4" failed (22: Invalid argument) while sending response to client
[crit] pread() "/str/.../dsf13at.mp4" failed (22: Invalid argument) while sending response to client
[crit] pread() "/str/.../dsf13at.mp4" failed (22: Invalid argument) while sending response to client
[crit] pread() "/str/.../dsf13at.mp4" failed (22: Invalid argument) while sending response to client
[crit] pread() "/str/.../dsf13at.mp4" failed (22: Invalid argument) while sending response to client
[crit] pread() "/str/.../dsf13at.mp4" failed (22: Invalid argument) while sending response to client
[crit] pread() "/str/.../dsf13at.mp4" failed (22: Invalid argument) while sending response to client
硬盘信息
具有512个硬盘的硬盘
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
具有4096的新硬盘驱动器
Units = sectors of 1 * 4096 = 4096 bytes
Sector size (logical/physical): 4096 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 4096 bytes
答案 0 :(得分:0)
问题在于Nginx使用的directio_alignment为512,但是当硬盘驱动器的扇区大小为4096时似乎不起作用。
将 directio_alignment 设置为4k可解决该问题,并且Nginx现在可以从具有512和4096扇区的驱动器中读取数据。
Nginx配置:
aio threads;
aio_write on;
directio 8M;
directio_alignment 4k;