排查与大于 4 KB 的系统磁盘扇区大小相关的错误
本文提供了在安装期间或启动 Windows 上的 SQL Server 实例时排查错误的解决方案。 本文对所有已发布版本的 SQL Server 有效。
本文中讨论的错误与大于 4 KB 的系统磁盘扇区大小相关。
适用于:SQL Server 所有版本
症状
方案 #1: 安装任何版本的 SQL Server。 然后,会看到类似于 SQL Server 数据库引擎 Services 组件的以下消息的错误:
Feature: Database Engine Services
Status: Failed
Reason for failure: An error occurred during the setup process of the feature.
Next Step: Use the following information to resolve the error, uninstall this feature, and then run the setup process again.
Component name: SQL Server Database Engine Services Instance Features
Component error code: 0x851A001A
Error description: Wait on the Database Engine recovery handle failed. Check the SQL Server error log for potential causes.
或者,SQL Server 错误日志中看到类似于:
2025-02-26 20:01:16.79 spid14s Starting up database 'master'.
2025-02-26 20:01:16.80 spid14s Error: 5178, Severity: 16, State: 1.
2025-02-26 20:01:16.80 spid14s Cannot use file 'C:\Program Files\Microsoft SQL Server\MSSQL16.MSSQLSERVER\MSSQL\DATA\master.mdf' because it was originally formatted with sector size 4096 and is now on a volume with sector size 8192. Move the file to a volume with a sector size that is the same as or smaller than the original sector size.
方案 #2: 在 Windows 10 设备上安装任何版本的 SQL Server。 然后,将设备上的 OS 升级到 Windows 11。 尝试在 Windows 11 设备上启动 SQL Server 时,服务无法启动,在 SQL Server 错误日志中,你会注意到类似于:
2021-11-05 23:42:47.14 spid9s There have been 256 misaligned log IOs which required falling back to synchronous IO. The current IO is on file C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\DATA\master.mdf.
方案 #3: 在 Windows 10 设备上安装任何版本的 SQL Server。 然后,将设备上的 OS 升级到 Windows 11。 尝试在 Windows 11 设备上启动 SQL Server 时,服务无法启动。 在 SQL Server 错误日志中,你会注意到类似于以下内容的条目:
Faulting application name: sqlservr.exe, version: 2019.150.2000.5, time stamp: 0x5d8a9215
Faulting module name: ntdll.dll, version: 10.0.22000.120, time stamp: 0x50702a8c
Exception code: 0xc0000005
Fault offset: 0x00000000000357ae
Faulting process id: 0x1124
Faulting application start time: 0x01d7bf67449d262c
Faulting application path: C:\Program Files\Microsoft SQL Server\MSSQL15.MSSQLSERVER\MSSQL\Binn\sqlservr.exe
Faulting module path: C:\Windows\SYSTEM32\ntdll.dll
方案 #4: 在 Windows 11 设备上安装 LocalDB。 安装程序失败,在 SQL Server 错误日志中,你会注意到类似于以下内容的条目:
2021-12-15 23:25:04.28 spid5s Cannot use file 'C:\Users\Administrator\AppData\Local\Microsoft\Microsoft SQL Server Local DB\Instances\TestInstance\master.mdf' because it was originally formatted with sector size 4096 and is now on a volume with sector size 16384. Move the file to a volume with a sector size that is the same as or smaller than the original sector size.
在 Windows 11 应用程序事件日志中,你会注意到类似于以下内容的条目:
Message : Windows API call WaitForMultipleObjects returned error code: 575. Windows system error message is: {Application Error}
The application was unable to start correctly (0x%lx). Click OK to close the application.
Reported at line: 3621.
Source : SQLLocalDB 11.0
备注
对于手动安装的 SQL Server 实例或应用程序安装的 LocalDB 实例,可能会遇到上述情况中提到的故障。
方案 #5: 如果尝试使用大于 4 KB 的扇区大小,则会看到以下错误消息:
Error: 5179, Severity: 16, State: 1.
Cannot use file 'data file path', because it is on a volume with sector size 8192. SQL Server supports a maximum sector size of 4096 bytes. Move the file to a volume with a compatible sector size.
原因
在服务启动期间,SQL Server 将开始数据库恢复过程,以确保数据库一致性。 此数据库恢复过程的一部分涉及在尝试打开系统和用户数据库文件之前对基础文件系统进行一致性检查。
某些新的存储设备和设备驱动程序公开的磁盘扇区大小大于支持的 4 KB 扇区大小。
发生这种情况时,由于不支持的文件系统,SQL Server 无法启动,因为 SQL Server 当前支持 512 字节和 4 KB 的扇区存储大小。
可以通过运行以下命令来确认遇到此特定问题:
fsutil fsinfo sectorinfo <volume pathname>
例如,若要分析 E: 卷,请运行以下命令:
fsutil fsinfo sectorinfo E:
查找值PhysicalBytesPerSectorForAtomicity
,并PhysicalBytesPerSectorForPerformance
返回以字节为单位,如果值不同,请保留最大的值以确定磁盘扇区大小。 值为 4096 表示扇区存储大小为 4 KB。
此外,请注意文件系统和存储扇区大小的 Windows 支持策略。 有关详细信息,请参阅 Windows 一文中针对 4 KB 扇区硬盘驱动器的Microsoft支持策略。
备注
没有与扇区大小大于 4 KB 的已发布版本的 SQL Server 兼容。 有关详细信息,请参阅 SQL Server 一文中的硬盘驱动器扇区大小支持边界。
解决方法
目前,
ForcedPhysicalSectorSizeInBytes
在使用新式存储平台(如 NVMe)提供大于 4 KB 的扇区大小时,需要注册表项才能成功安装 SQL Server。 此 Windows作系统注册表项强制将扇区大小模拟为 4 KB。 若要添加ForcedPhysicalSectorSizeInBytes
注册表项,请使用注册表编辑器或运行命令,如命令提示符或 PowerShell 部分中所述。 添加此更改的注册表项后,必须重新启动设备才能生效。 无需为此方案添加跟踪标志 1800。重要
本部分包含有关如何修改 Windows 注册表的步骤。 但是,注册表修改不当可能会出现严重问题。 因此,按以下步骤操作时请务必谨慎。 作为额外保护措施,请在修改注册表之前先将其备份。 如果出现问题,可以还原注册表。 有关如何备份和还原注册表的详细信息,请参阅 Windows 文章中的“如何备份和还原注册表”。
- 注册表编辑器
- 命令提示符
- PowerShell
- 以管理员身份运行注册表编辑器。
- 导航到
Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\stornvme\Parameters\Device
。 - 选择“编辑>新>多字符串”值并将其命名为 。
ForcedPhysicalSectorSizeInBytes
- 右键单击名称,选择“修改”,然后在“值数据”字段中键入
* 4095
。 - 选择“确定”并关闭注册表编辑器。
如果未添加注册表项,并且此系统上有多个驱动器,可以在安装 SQL Server 完成后为数据库文件指定其他位置。 确保驱动器反映查询
fsutil
命令时支持的扇区大小。 SQL Server 目前支持 512 字节和 4,096 字节的扇区存储大小。
详细信息
Windows 11 本机 NVMe 驱动程序已更新,包括 NVMe 存储设备直接报告的实际扇区大小。 这是完成的,而不是依赖于从文件系统驱动程序模拟的信息。
Windows 10 驱动程序不报告物理存储的源扇区大小。
改进的 Windows 11 驱动程序无视常见的 NVMe 存储设备使用的仿真。 例如, fsutil
显示扇区大小为 8 KB 或 16 KB,而不是模拟 Windows 所需的 4 KB 扇区大小。
下表对作系统报告的扇区大小进行了比较。 此示例说明了使用相同存储设备的 Windows 10 和 Windows 11 之间的差异。 对于值 PhysicalBytesPerSectorForAtomicity
, PhysicalBytesPerSectorForPerformance
Windows 10 显示 4 KB,Windows 11 显示 16 KB。
示例输出 fsutil fsinfo sectorinfo <volume pathname>
Windows 10 | Windows 11 |
---|---|
LogicalBytesPerSector : 512 |
LogicalBytesPerSector : 512 |
PhysicalBytesPerSectorForAtomicity : 4096 |
PhysicalBytesPerSectorForAtomicity : 16384 |
PhysicalBytesPerSectorForPerformance : 4096 |
PhysicalBytesPerSectorForPerformance : 16384 |
FileSystemEffectivePhysicalBytesPerSectorForAtomicity : 4096 |
FileSystemEffectivePhysicalBytesPerSectorForAtomicity : 4096 |
Device Alignment : Aligned (0x000) |
Device Alignment : Aligned (0x000) |
Partition alignment on device : Aligned (0x000) |
Partition alignment on device : Aligned (0x000) |
No Seek Penalty |
No Seek Penalty |
Trim Supported |
Trim Supported |
Not DAX capable |
Not DAX capable |
Not Thinly-Provisioned |
Not Thinly-Provisioned |