Friday, April 5, 2013

SQL2008R2: Error-Model database ldf file missing- Database 'model' cannot be opened due to inaccessible files or insufficient memory or disk space.

While trying to restart SQL service, I am getting the below error message.

Then I had a look in the error log file. (Refer below section)
2013-03-14 10:56:06.95 Server      Microsoft SQL Server 2008 R2 (RTM) - 10.50.1600.1 (Intel X86)
                Apr  2 2010 15:53:02
                Copyright (c) Microsoft Corporation
                Developer Edition on Windows NT 5.1 <X86> (Build 2600: Service Pack 3)

2013-03-14 10:56:06.95 Server      (c) Microsoft Corporation.
2013-03-14 10:56:06.95 Server      All rights reserved.
2013-03-14 10:56:06.95 Server      Server process ID is 26684.
2013-03-14 10:56:06.95 Server      Authentication mode is MIXED.
2013-03-14 10:56:06.95 Server      Logging SQL Server messages in file 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQL2008R2\MSSQL\Log\ERRORLOG'.
2013-03-14 10:56:06.95 Server      This instance of SQL Server last reported using a process ID of 16596 at 14/03/2013 10:55:54 (local) 14/03/2013 10:55:54 (UTC). This is an informational message only; no user action is required.
2013-03-14 10:56:06.96 Server      Registry startup parameters:
                 -d C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQL2008R2\MSSQL\DATA\master.mdf
                 -e C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQL2008R2\MSSQL\Log\ERRORLOG
                 -l C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQL2008R2\MSSQL\DATA\mastlog.ldf
2013-03-14 10:56:06.97 Server      SQL Server is starting at normal priority base (=7). This is an informational message only. No user action is required.
2013-03-14 10:56:06.97 Server      Detected 2 CPUs. This is an informational message; no user action is required.
2013-03-14 10:56:07.76 Server      Using dynamic lock allocation.  Initial allocation of 2500 Lock blocks and 5000 Lock Owner blocks per node.  This is an informational message only.  No user action is required.
2013-03-14 10:56:07.93 Server      Node configuration: node 0: CPU mask: 0x00000003:0 Active CPU mask: 0x00000003:0. This message provides a description of the NUMA configuration for this computer. This is an informational message only. No user action is required.
2013-03-14 10:56:07.98 spid7s      Starting up database 'master'.
2013-03-14 10:56:07.99 spid7s      Error: 17207, Severity: 16, State: 1.
2013-03-14 10:56:07.99 spid7s      FCB::RemoveAlternateStreamsByHandle(BackupSeek): Operating system error 6(failed to retrieve text for this error. Reason: 1815) occurred while creating or opening file 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQL2008R2\MSSQL\DATA\master.mdf'. Diagnose and correct the operating system error, and retry the operation.
2013-03-14 10:56:08.17 spid7s      Resource governor reconfiguration succeeded.
2013-03-14 10:56:08.17 spid7s      SQL Server Audit is starting the audits. This is an informational message. No user action is required.
2013-03-14 10:56:08.20 spid7s      SQL Server Audit has started the audits. This is an informational message. No user action is required.
2013-03-14 10:56:08.21 spid7s      FILESTREAM: effective level = 0, configured level = 0, file system access share name = 'SQL2008R2'.
2013-03-14 10:56:08.25 spid7s      SQL Trace ID 1 was started by login "sa".
2013-03-14 10:56:08.26 spid7s      Starting up database 'mssqlsystemresource'.
2013-03-14 10:56:08.30 spid7s      The resource database build version is 10.50.1600. This is an informational message only. No user action is required.
2013-03-14 10:56:08.60 spid10s     Starting up database 'model'.
2013-03-14 10:56:08.61 spid7s      Server name is ‘servername’. This is an informational message only. No user action is required.
2013-03-14 10:56:08.63 spid10s     Error: 17207, Severity: 16, State: 1.
2013-03-14 10:56:08.63 spid10s     FCB::RemoveAlternateStreamsByHandle(BackupSeek): Operating system error (null) occurred while creating or opening file 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQL2008R2\MSSQL\DATA\model.mdf'. Diagnose and correct the operating system error, and retry the operation.
2013-03-14 10:56:08.78 spid10s     Error: 17207, Severity: 16, State: 1.
2013-03-14 10:56:08.78 spid10s     FileMgr::StartLogFiles: Operating system error 2(failed to retrieve text for this error. Reason: 1815) occurred while creating or opening file 'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQL2008R2\MSSQL\DATA\modellog.ldf'. Diagnose and correct the operating system error, and retry the operation.
2013-03-14 10:56:08.79 spid10s     File activation failure. The physical file name "C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQL2008R2\MSSQL\DATA\modellog.ldf" may be incorrect.
2013-03-14 10:56:08.79 spid10s     Error: 945, Severity: 14, State: 2.
2013-03-14 10:56:08.79 spid10s     Database 'model' cannot be opened due to inaccessible files or insufficient memory or disk space.  See the SQL Server errorlog for details.
2013-03-14 10:56:08.79 spid10s     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.
2013-03-14 10:56:08.79 spid10s     SQL Trace was stopped due to server shutdown. Trace ID = '1'. This is an informational message only; no user action is required.

Solution:
Step 1: Look for the model database backup
Step 2: Restore the same to some other server by the following query in some other name.
RESTORE DATABASE [ModelTemp] FROM
 DISK = N'C:\Documents and Settings\T001855\Desktop\Backup Model_Full_Backup.bak'
WITH  FILE = 1, 
MOVE N'modeldev'
TO N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQL2008R2\MSSQL\DATA\ModelTemp.mdf',
  MOVE N'modellog'
  TO N'C:\Program Files\Microsoft SQL Server\MSSQL10_50.SQL2008R2\MSSQL\DATA\ModelTemp_1.ldf',
  NOUNLOAD,  STATS = 10
GO

Step 3: Stop the SQL services of other server to copy the recently restored modeltemp database mdf and ldf files to the problem server.
Refer below screenshot.

Step 4: Rename the old model database files to some other name like model111 if it exists, then change the modeltemp.mdf and modeltemp.ldf to model.mdf and model.ldf.
 Step 5: Finally restart the SQL services. SQL services will restart without issues.
 

No comments:

Post a Comment

MYSQL:::Seamless Data Archiving: Exporting, Importing, and Pruning MySQL Tables

  Seamless Data Archiving: Exporting, Importing, and Pruning MySQL Tables Introduction: In the dynamic landscape of database management...