本文可帮助你排查和解决执行数据库升级脚本时 SQL Server 累积更新(CU)或 Service Pack(SP)报告错误 5133 的问题。
现象
应用 CU 或 SP 时,安装程序可能会报告以下错误:
等待数据库引擎恢复句柄失败。 有关可能的原因,请查看 SQL Server 错误日志。
查看 SQL Server 错误日志时,可能会注意到以下错误消息:
Error: 5133, Severity: 16, State: 1
Directory lookup for the file "<path>\MSSQL10.<Instancename>\MSSQL\Data\temp_MS_AgentSigningCertificate_database.mdf" failed with the operating system error 3(The system cannot find the path specified.).
Error: 1802, Severity: 16, State: 1.
CREATE DATABASE failed. Some file names listed could not be created. Check related errors.
Error: 912, Severity: 21, State: 2.
Script level upgrade for database 'master' failed because upgrade step 'sqlagent100_msdb_upgrade.sql' encountered error 598, state 1, severity 25.
This is a serious error condition which might interfere with regular operation and the database will be taken offline.
If the error happened during upgrade of the 'master' database, it will prevent the entire SQL Server instance from starting.
Examine the previous errorlog entries for errors, take the appropriate corrective actions and re-start the database so that the script upgrade steps run to completion.
Error: 3417, Severity: 21, State: 3.
Cannot recover the master database. SQL Server is unable to run. Restore master from a full backup, repair it, or rebuild it. For more information about how to rebuild the master database, see SQL Server Books Online.
原因
SQL Server 在尝试确定文件的目录时遇到操作系统错误时报告错误 5133。 SQL Server 在执行 CREATE DATABASE 或 ALTER DATABASE 语句时报告错误 598。
注意
从数据库引擎事件和错误中,可以看到Error 598: An error occurred while executing CREATE/ALTER DB. Please look at the previous error for more information
。
错误 598 之前的条目可以提供有关失败原因的详细信息。 例如,在本文中,上述错误为 1802,因为升级脚本无法在默认数据路径中创建临时数据库。 临时数据库由安装程序用于它在更新过程中运行的各种操作。 有关在 CU 或 SP 安装过程中执行的数据库升级脚本的详细信息,请参阅 应用更新时对升级脚本失败进行故障排除。
解决方法
验证 数据路径 属性是否已在 SQL Server 中配置有效且正确的值。
从SQL Server 配置管理器:
打开 SQL Server 配置管理器并选择“SQL Server 服务”。
右键单击 SQL Server 实例并选择“ 属性”。
选择“高级”选项卡并验证数据路径的值是否正确,并且没有任何拼写错误或额外字符。 (若要验证该值,可以复制该值,并尝试使用 Windows 资源管理器访问该值。
在 Windows 注册表编辑器中:
在 任务栏上的“搜索 ”框中,键入 regedit 以打开 注册表编辑器。
导航到默认数据路径的注册表项。 然后,验证路径是否正确,并且没有额外的空格或字符。 默认数据路径的注册表项为
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL10.<Instance Name>\Setup\SQLDataRoot
。如果注册表项具有正确的数据路径,并且继续收到错误,请执行以下步骤:
导航到注册表项:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL10.<Instance Name>\MSSQLServer\Parameters
.查看和更改数据路径的值以匹配值。
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL10.<Instance Name>\Setup\SQLDataRoot
重新启动 SQL Server 实例。
启动 SQL Server 实例后,将再次执行升级脚本。
- 如果 SP 或 CU 升级脚本成功完成,可以检查 SQL Server 错误日志和启动文件夹进行验证。
- 如果升级脚本再次失败,请检查 SQL Server 错误日志中是否存在其他错误,并排查新错误。