使用 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
问题是 Nginx 使用 512 的 directio_alignment,但当硬盘驱动器的扇区大小为 4096 时,这似乎不起作用。
Setting 方向对齐到 4k 解决了这个问题,Nginx 现在可以从 512 和 4096 扇区的驱动器中读取数据。
Nginx 配置:
aio threads;
aio_write on;
directio 8M;
directio_alignment 4k;
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)