码迷,mamicode.com
首页 > 数据库 > 详细

SQL Server Instance无法启动了, 因为TempDB所在的分区没有了, 怎么办?

时间:2014-09-18 18:07:14      阅读:297      评论:0      收藏:0      [点我收藏+]

标签:blog   http   color   io   os   使用   ar   strong   for   

我的SQL 2014的虚拟机在迁移的时候, 存放TempDB的LUN被删掉了. 在虚拟机的操作系统启动了之后, SQL Server Instance却启动不起来了. 检查Event Log, 报错.

于是, 找到了这篇文章. 其目标是强制SQL Server启动, 并允许接收sqlcmd的修改一些选项的命令.  一旦SQL可以接受命令, 那我们就可以重新指定tempdb的路径了.

 

然而, 使用文章中的步骤, 我还是无法强制启动SQL Server.

检查Sqlservr.exe /f /c的输出, 发现报错如下:

2014-09-18 15:51:36.88 spid10s     Clearing tempdb database.
2014-09-18 15:51:36.89 spid10s     Error: 5123, Severity: 16, State: 1.
2014-09-18 15:51:36.89 spid10s     CREATE FILE encountered operating system erro
r 3(The system cannot find the path specified.) while attempting to open or crea
te the physical file ‘E:\SQLDatabaseData\tempdb.mdf‘.
2014-09-18 15:51:36.89 spid10s     Error: 5123, Severity: 16, State: 1.
2014-09-18 15:51:36.89 spid10s     CREATE FILE encountered operating system erro
r 3(The system cannot find the path specified.) while attempting to open or crea
te the physical file ‘F:\SQLServerDatabaseLog\templog.ldf‘.
2014-09-18 15:51:36.90 spid10s     Error: 17204, Severity: 16, State: 1.
2014-09-18 15:51:36.90 spid10s     FCB::Open failed: Could not open file E:\SQLD
atabaseData\tempdb.mdf
for file number 1.  OS error: 3(The system cannot find th
e path specified.).
2014-09-18 15:51:36.91 spid10s     Error: 5120, Severity: 16, State: 101.
2014-09-18 15:51:36.91 spid10s     Unable to open the physical file "E:\SQLDatab
aseData\tempdb.mdf
". Operating system error 3: "3(The system cannot find the pat
h specified.)".
2014-09-18 15:51:36.91 spid10s     Error: 1802, Severity: 16, State: 4.
2014-09-18 15:51:36.91 spid10s     CREATE DATABASE failed. Some file names liste
d could not be created. Check related errors.
2014-09-18 15:51:36.91 spid10s     Could not create tempdb. You may not have eno
ugh disk space available. Free additional disk space by deleting other files on
the tempdb drive and then restart SQL Server. Check for additional errors in the
event log that may indicate why the tempdb files could not be initialized.
2014-09-18 15:51:36.92 spid15s     The SQL Server Network Interface library succ
essfully deregistered the Service Principal Name (SPN) [ MSSQLSvc/SQL2014-1.SPS.
P51359 ] for the SQL Server service.

看来即使是强制启动SQL, tempdb文件所在的原始路径还是需要存在的. 于是笔者给这台虚拟重新分配了两个虚拟硬盘. 把相应路径都建立好. SQL Server Instance终于可以强制启动了.

后面照着文章所讲的步骤就可以成功解决问题了.

 

========================

为方便将来查找和防止原文的丢失, 我把重要的步骤列在这里:

Following are the steps needed to add a new file to TEMPDB and then restart SQL Server.

1)   Open command prompt window #1 as ADMIN and go to the BINN directory where SQL Server is installed. This is typically in

C:\Program Files\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\Binn

OR

C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Binn

2) Then execute command like

Sqlservr.exe /f /c

3)   Then open one more command window #2 and if this is a default instance then open SQLCMD  using the following command

SQLCMD –S localhost –E

4)   This will open a SQL command prompt there where you can type the following commands

1> USE MASTER

2> GO

3> ALTER DATABASE tempdb MODIFY FILE

4> (NAME = tempdev, FILENAME = ‘C:\NEWPATH\datatempdb.mdf‘)

5> GO

6> quit

5)   Now go back to Command window #1 and hit CTRL C.It will ask if you want to stop the instance. Y/N. Enter Y

 

6)   Now start the SQL Server instance from configuration manager. You should see the new data file created and SQL Server started.

 

参考资料

========================

How to start SQL Server if you lost TEMPDB Data files?

http://blogs.xtivia.com/home/-/blogs/how-to-start-sql-server-if-you-lost-tempdb-data-files-

SQL Server Instance无法启动了, 因为TempDB所在的分区没有了, 怎么办?

标签:blog   http   color   io   os   使用   ar   strong   for   

原文地址:http://www.cnblogs.com/awpatp/p/3979596.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!