patternsqlMinor
Can not start SQL Server, model db in RESTORING state
Viewed 0 times
cansqlrestoringstatestartservernotmodel
Problem
Quick run down:
First problem started when sysadmin received error that
Sometime later vendor tried to do some upgrades to the database. When they restarted SQL Server it failed to start.
Looking at error log. I found the following error
Error The database 'model' is marked RESTORING and is in a state that
does not allow recovery to be run. Error: 927, Severity: 14, State: 2.
Database 'model' cannot be opened. It is in the middle of a restore.
Could not create tempdb. You may not have enough 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.
after searching around on the web found this article on MSDN
using steps from article started sql server using
Now I get the following error:
Starting up database 'tempdb'. Error: 3456, Severity: 21, State: 1.
Could not redo log record (19:45:366), for transaction ID (0:0), on
page (1:16), database 'tempdb' (database ID 2). Page: LSN = (18:72:8),
type = 1. Log: OpCode = 18, context 2, PrevPageLSN: (19:45:287).
Restore from a backup of the database, or repair the database.
First problem started when sysadmin received error that
model is recovering.Sometime later vendor tried to do some upgrades to the database. When they restarted SQL Server it failed to start.
Looking at error log. I found the following error
Error The database 'model' is marked RESTORING and is in a state that
does not allow recovery to be run. Error: 927, Severity: 14, State: 2.
Database 'model' cannot be opened. It is in the middle of a restore.
Could not create tempdb. You may not have enough 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.
after searching around on the web found this article on MSDN
using steps from article started sql server using
Sqlservr.exe -sInstanceName -T3608 -c -f -T3609 when i tried to run Use tempdb got error message. Following advice from article I copied tempdb.mdf and templog.ldf from another server.Now I get the following error:
Starting up database 'tempdb'. Error: 3456, Severity: 21, State: 1.
Could not redo log record (19:45:366), for transaction ID (0:0), on
page (1:16), database 'tempdb' (database ID 2). Page: LSN = (18:72:8),
type = 1. Log: OpCode = 18, context 2, PrevPageLSN: (19:45:287).
Restore from a backup of the database, or repair the database.
Solution
After trying large number of alternative steps was able to fix the problem and get the database started.
Here are the steps I took:
-
On another SQL Server 2008 R2, I moved my
-
Replaced model and tempdb .mdf and .ldf files on my problem server. Old files I saved in another directory just incase.
-
Tried to start the SQL Server services, verified error message
The database 'model' is marked RESTORING and is in a state that does
not allow recovery to be run. Error: 927, Severity: 14, State: 2.
Database 'model' cannot be opened. It is in the middle of a restore.
Could not create tempdb. You may not have enough 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.
After that I opened two separate Command Prompt windows.
Below to make it easier I call first command prompt windows CPA, and second one CPB.
-
-
Using SQL Server Configuration Manager or Services page start SQL Server service.
After I was able to connect using SSMS.
Here are the steps I took:
-
On another SQL Server 2008 R2, I moved my
model and temp db files to same location as on my problem server. Refer to this http://technet.microsoft.com/en-us/library/ms345408.aspx-
Replaced model and tempdb .mdf and .ldf files on my problem server. Old files I saved in another directory just incase.
-
Tried to start the SQL Server services, verified error message
The database 'model' is marked RESTORING and is in a state that does
not allow recovery to be run. Error: 927, Severity: 14, State: 2.
Database 'model' cannot be opened. It is in the middle of a restore.
Could not create tempdb. You may not have enough 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.
After that I opened two separate Command Prompt windows.
Below to make it easier I call first command prompt windows CPA, and second one CPB.
- in CPA run
Sqlservr.exe -sInstanceName -T3608 -c -f -T3609(note: I had to navigate to binary location) don't forget to replaceInstanceNamewith yours
-
-T3608only startsmasterTrace Flags documentation
-
-T3609skips creation oftempdb
- in CPB run
SQLCMD -E -SADMIN:Servername\InstanceNamereplace with your ServerName\InstanceName. Using a Dedicated Administrator Connection
- in CPB run
sp_detach_db 'model'thengo
- in CPB run the following code, just replace with your file location.
CREATE DATABASE [model] ON
( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.R2\MSSQL\DATA\model.mdf' ),
( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.R2\MSSQL\DATA\modellog.ldf' ) FOR ATTACH
go- in CPA you should see
Starting 'MODEL'messsage
- in CPA hit Ctrl+C that will show message if you want to exit hit Y
Using SQL Server Configuration Manager or Services page start SQL Server service.
After I was able to connect using SSMS.
Code Snippets
CREATE DATABASE [model] ON
( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.R2\MSSQL\DATA\model.mdf' ),
( FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.R2\MSSQL\DATA\modellog.ldf' ) FOR ATTACH
goContext
StackExchange Database Administrators Q#61300, answer score: 5
Revisions (0)
No revisions yet.