1

Topic: Rebuilding master database when corrupt

Recorder crashed and now will not open, in the error log I found

The log scan number (395:216:1) passed to log scan in database 'master' is not valid. This error may indicate data corruption or that the log file (.ldf) does not match the data file (.mdf). If this error occurred during replication, re-create the publication. Otherwise, restore from backup if the problem results in a failure during startup.
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.

I have no backups of the master database so assume I need to rebuild it.

More googling found the setup command in C:\Program Files\Microsoft SQL Server\100\Setup Bootstrap\Release which should be run at the command prompt

Setup /QUIET /ACTION=REBUILDDATABASE /INSTANCENAME=InstanceName
/SQLSYSADMINACCOUNTS=accounts [/SAPWD= StrongPassword][/SQLCOLLATION=CollationName] 

Am I on the right lines and what parameters should I use

Many thanks in anticipation

2

Re: Rebuilding master database when corrupt

Can you access Sql server via Managenent Studio ? If so I would first try detaching Nbndsta.Deleting the log file and resttaching Nbndsta. This might regenerate the log file.

Mike Weideli

3

Re: Rebuilding master database when corrupt

Thanks.

I can open studio manager but when I try to connect to server it fails with

TITLE: Connect to Server
------------------------------

Cannot connect to (local).

------------------------------
ADDITIONAL INFORMATION:

A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server) (Microsoft SQL Server, Error: 2)

For help, click: http://go.microsoft.com/fwlink?ProdName … nkId=20476

4

Re: Rebuilding master database when corrupt

Does look like there is some corruption in SQL Server.  Once installed R6 doesn't make any changes to the Master database. It may turn out that you need to reinstall SQL Server, I will see what additional advice I can obtain for you

Mike Weideli

5

Re: Rebuilding master database when corrupt

The advice I have obtained suggests that the solution may vary depending exactly which version of Sql Server you are using.  If you can let me know this then we can look into it further.

Mike Weideli

6

Re: Rebuilding master database when corrupt

I am running SQL Server 2008 R2

7

Re: Rebuilding master database when corrupt

These seem to be the most comprehensive instructions

http://www.mytechmantra.com/learnsqlser … _2008.html

also

http://blogs.msdn.com/b/psssql/archive/ … -2008.aspx

Mike Weideli

8

Re: Rebuilding master database when corrupt

Thanks

I have run setup viz

setup.exe /QUIET /ACTION=REBUILDDATABASE /INSTANCENAME=MSSQLSERVER /SQLSYSADMINACCOUNTS=ADMINISTRATOR /SAPWD=r2k

which failed.  I attach one of the log files produced.

Also can you confirm SQLSYSADMINACCOUNTS=ADMINISTRATOR is correct

Post's attachments

Summary_DerekCOLEMAN-PC_20150402_171657.txt 2.94 kb, 2 downloads since 2015-04-02 

You don't have the permssions to download the attachments of this post.

9

Re: Rebuilding master database when corrupt

There are two setup commands: one in RELEASE and the other in SQLSERVER2008R2.  Since I am running SQL Server 2008 R2, I consider the latter to be more appropriate but have been using both.

I am still unsure what value I should be using for the parameter /SQLSYSADMINACCOUNTS= accounts

I have used
ADMINISTRATOR
sa
“DerekCOLEMAN-PC/Derek Coleman” (my username in the connect to server window)
“Derek Coleman”

When trying setup from RELEASE for the above four accounts, I get same the error messages

Final result:                  Failed: see details below
Exit code (Decimal):           -2068643838
Exit facility code:            1203
Exit error code:               2

Exception type: Microsoft.SqlServer.Setup.Chainer.Workflow.NoopWorkflowException

Message:
The state of your SQL Server installation was not changed after the setup execution.

I have found one blog
http://blogs.msdn.com/b/psssql/archive/ … -2008.aspx
which suggests this error is because master.mdf does not exist in
C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\Binn\Templates
however it does

When trying setup from SQLServer2008R2 for the above four accounts, I get same the error messages

Final result:                  Failed: see details below
Exit code (Decimal):           1152035024
Exit facility code:            1194
Exit error code:               43216
Exit message:                  Exception has been thrown by the target of an invocation.

Inner exception type: System.ArgumentNullException
Message:
                Value cannot be null.
                Parameter name: InstallMediaPath.

There is no parameter InstallMediaPath on the setup command so presumably is called elsewhere.

I also tried deleting the corrupt master, model, msdb data and log files in
C:\Program Files\Microsoft SQL Server\MSSQL10.50MSSQLSERVER\MSSQL\DATA
and replacing them with the files in
C:\Program Files\Microsoft SQL Server\MSSQL10.50MSSQLSERVER\MSSQL\Binn\Templates
then opening SQL Server Management Studio and connecting to server but this failed.

10

Re: Rebuilding master database when corrupt

I have found some old blogs that suggest the InstallMediaPath error is a bug and that it will be fixed at a later release.

I had another go at replacing the corrupt database files with the files to be found in C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\Binn\Templates.  Instead of using SQL Server Management Studio, which failed last time, I ran SQL Server Configuration Manager and started the SQL Server, which worked except that the model database was read-only.  Once I made model database read-write, I could login into SQL Server Management Studio and the Recorder application was working again.

Two questions:

In SQL Server Configuration Manager, there is also SQL Server Browser and SQL Server Agent.  The former was already running and the latter is stopped.   Should I try to get SQL Server Agent running?

Does Recorder modify the master database in any way?  I note that the backup database had disappeared, a problem that I have previously encountered and solved.

Many thanks

11

Re: Rebuilding master database when corrupt

Please that you have got it running again. It could be that Server Objects/Backup devices are part of the Master database, which is why you have lost backup. Otherwise Recorder doesn't modify the Master Database and certainly doesn't write to it during normal operation.  Agent isn't running on my machine, but browser is.

For the record  from what I can see SQLSYSADMINACCOUNTS= DerekCOLEMAN-PC\Derek Coleman would be correct although  I have read that if you installed using mixed mode then you also have to provide  the sa password for the repair. SQLSYSADMINACCOUNTS= DerekCOLEMAN-PC\Derek Coleman/SAPWD=r2k.

Also if  there are other  instances of SQL Server installed elsewhere which use exactly  the same version of SQL SERVER then  you can use  a backup from there to restore the master.  It appears that you have done something on these lines.

Mike Weideli

12

Re: Rebuilding master database when corrupt

Many thanks for all your help