本文提供了在安装期间或启动 Windows 上的 SQL Server 实例时排查错误的解决方案。 本文对所有已发布版本的 SQL Server 有效。
本文讨论与大于 4 KB 的系统磁盘扇区大小相关的错误。 尝试在系统磁盘扇区大小大于 4 KB 的计算机上安装 SQL Server 实例时,可能会遇到以下情况:
适用于:SQL Server 所有版本
情景 1:将文件移动到具有兼容扇区大小的卷
如果尝试使用大于 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.
方案 2:找不到数据库引擎启动句柄
尝试在运行 Windows 的 Azure 虚拟机(VM)上安装 SQL Server 实例时,安装会失败,当引擎尝试在安装期间启动时,SQL Server 错误日志中会收到以下错误消息:
无法使用文件“...\master.mdf”,因为它最初采用扇区大小 4096 的格式,现在位于扇区大小为 8192 的卷上。 请将此文件移到其扇区大小小于或等于原始扇区大小的卷。
此外,可以在 SQL Server 安装文件夹中Summary.txt日志文件中看到以下信息:
Detailed results:
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: 0x851A0019
Error description: Could not find the Database Engine startup handle.
有关详细信息,请参阅 SQL Server 在 Windows Server 2022 Azure 虚拟机上因扇区大小错误而安装失败。
方案 3:等待数据库引擎恢复句柄失败
安装任何版本的 SQL Server 时,会看到类似于 SQL Server 数据库引擎服务组件以下消息的错误:
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.
方案 4:存在 256 个未对齐的日志 IO,需要回退到同步 IO
在 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.
方案 5
在 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
方案 6:将文件移动到扇区大小与原始扇区大小相同或更小的卷中
在 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 实例,可能会遇到上述情况中提到的故障。
原因
在服务启动期间,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 一文中的硬盘驱动器扇区大小支持边界。
决议
目前,当使用提供大于 4 KB 扇区大小的新式存储平台(例如 NVMe)时,需要使用
ForcedPhysicalSectorSizeInBytes
注册表项才能成功安装 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 字节的扇区存储大小。
谨慎
如果已创建包含扇区大小大于 4 KB 的磁盘来托管 SQL Server 文件的存储池,必须先删除存储池,应用本文中提到的故障排除方法之一,然后在尝试在存储池或池上安装 SQL Server 之前重新生成存储池。
详细信息
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 |