简体   繁体   English

修复疑似的TFS数据库

[英]Repair Suspected TFS database

i am using this T-SQL to repair my TFS suspected database 我正在使用此T-SQL修复我的TFS可疑数据库

EXEC sp_resetstatus [TFS_Projects];
ALTER DATABASE [TFS_Projects] SET EMERGENCY
DBCC checkdb([TFS_Projects])
ALTER DATABASE [TFS_Projects] SET SINGLE_USER WITH ROLLBACK IMMEDIATE
DBCC CheckDB ([TFS_Projects], REPAIR_ALLOW_DATA_LOSS)
ALTER DATABASE [TFS_Projects] SET MULTI_USER

but when i use this T-SQL i will get error 但是当我使用这个T-SQL时我会得到错误

Database 'TFS_Projects' cannot be opened due to inaccessible files or insufficient memory or disk space. 由于文件不可访问或内存或磁盘空间不足,无法打开数据库“ TFS_Projects”。

how can i repair my SQL database? 如何修复我的SQL数据库?

i am using SQL Server 2012 我正在使用SQL Server 2012

UPDATE 1: 更新1:

this error will Occurred in line : 该错误将在以下行发生:

DBCC checkdb([TFS_Projects]) DBCC checkdb([TFS_Projects])

UPDATE 2: 更新2:

i have 20GB free on hard drive that my mdf and ldf on it 我的mdf和ldf硬盘上有20GB可用空间

UPDATE 3: 更新3:

i can not chek Autogrow becuase when i right click on db the error will appear 我无法点击自动增长,因为当我右键单击数据库时,将出现错误

mdf and ldf is not readonly mdf和ldf不是只读的

and i am loged in by windows administartor, and loged in sql server by sa 我是由Windows administartor登录的,而sa是由sql server登录的

1) If possible add more hard drive space either by removing of unnecessary files from hard drive or add new hard drive with larger size. 1)如果可能,请通过从硬盘驱动器中删除不必要的文件或添加更大尺寸的新硬盘来增加硬盘驱动器空间。

2) Check if the database is set to Autogrow on. 2)检查数据库是否设置为自动增长。

3) Check if the account which is trying to access the database has enough permission to perform operation. 3)检查试图访问数据库的帐户是否具有足够的权限来执行操作。

4) Make sure that .mdf and .ldf file are not marked as read only on operating system file system level. 4)确保在操作系统文件系统级别上,.mdf和.ldf文件未标记为只读。

Found here: http://blog.sqlauthority.com/2007/08/02/sql-server-fix-error-945-database-cannot-be-opened-due-to-inaccessible-files-or-insufficient-memory-or-disk-space-see-the-sql-server-error-log-for-details/ 在此处找到: http : //blog.sqlauthority.com/2007/08/02/sql-server-fix-error-945-database-can-be-opened-due-to-inaccessible-files-or-insufficient-memory -或磁盘空间不足,看到最SQL服务器错误日志换细节/

i update my answer becuase old answer is dangerous and will damage TFS database! 我更新我的答案,因为旧答案很危险,并且会损坏TFS数据库! this answer is from microsoft : http://msdn.microsoft.com/en-us/library/jj620932.aspx 这个答案来自微软: http : //msdn.microsoft.com/en-us/library/jj620932.aspx

To back up your databases 备份数据库

Launch TFSBackup.exe. 启动TFSBackup.exe。 The TFSBackup.exe tool is in the Tools folder where you installed Team Foundation Server. TFSBackup.exe工具位于安装Team Foundation Server的“工具”文件夹中。 The default location is C:\\Program Files\\Microsoft Team Foundation Server 12.0\\Tools. 默认位置是C:\\ Program Files \\ Microsoft Team Foundation Server 12.0 \\ Tools。 In Source SQL Server Instance, enter the name of the SQL Server instance that hosts the TFS databases you want to back up and choose Connect. 在“源SQL Server实例”中,输入承载要备份的TFS数据库的SQL Server实例的名称,然后选择“连接”。 In Select databases to backup, choose the databases to back up. 在“选择要备份的数据库”中,选择要备份的数据库。 Need help? 需要帮忙? List of TFS 2010 databases on MSDN; MSDN上的TFS 2010数据库列表; List of TFS 2012 databases on MSDN. MSDN上的TFS 2012数据库列表。 In Backup Databases to, enter the name of a network share that is configured with read/write access for Everyone, or accept the default location in the file system of the SQL Server you connected to in step 2. Note Note If you want to overwrite backups stored in this network location, you can choose Overwrite existing database backups at this location. 在“将数据库备份到”中,输入配置有“所有人”的读/写访问权限的网络共享的名称,或接受您在步骤2中连接到的SQL Server的文件系统中的默认位置。注意注意如果要覆盖在此网络位置存储的备份,您可以选择在此位置覆盖现有数据库备份。 Choose Backup Now. 选择立即备份。 The Backup tool reports progress on each database being backed up. 备份工具报告正在备份的每个数据库的进度。 Choose Close. 选择关闭。 Restore your data 恢复数据

To restore your TFS data 恢复您的TFS数据

Launch TFSRestore.exe. 启动TFSRestore.exe。 The TFSRestore.exe tool is in the Tools folder where you installed Team Foundation Server. TFSRestore.exe工具位于安装Team Foundation Server的“工具”文件夹中。 The default location is C:\\Program Files\\Microsoft Team Foundation Server 12.0\\Tools. 默认位置是C:\\ Program Files \\ Microsoft Team Foundation Server 12.0 \\ Tools。 In Target SQL Server Instance, enter the SQL Server instance you will use as the data tier and choose Connect. 在“目标SQL Server实例”中,输入将用作数据层的SQL Server实例,然后选择“连接”。 Choose Add Share and enter the UNC path to the network share that is configured with read/write access to Everyone where you stored the backups of your TFS data. 选择“添加共享”,然后输入配置为对存储TFS数据备份的“所有人”具有读/写访问权限的网络共享的UNC路径。 For example, \\servername\\sharename. 例如,\\ servername \\ sharename。 If the backup files are located on the file system of the server that is running TFSRestore.exe, you can use the drop down box to select a local drive. 如果备份文件位于运行TFSRestore.exe的服务器的文件系统上,则可以使用下拉框选择本地驱动器。 Note Note The service account for the instance of SQL Server you identified at the start of this procedure must have read access to this share. 注意注意在此过程开始时您标识的SQL Server实例的服务帐户必须对此共享具有读取权限。 In the left hand navigation pane, choose the network share or local disk you identified in the previous step. 在左侧导航窗格中,选择在上一步中确定的网络共享或本地磁盘。 The TFS Restore Tool displays the database backups stored on the file share. TFS还原工具显示存储在文件共享上的数据库备份。 Select the check boxes for the databases you want to restore to the SQL Server you identified at the start of this procedure. 选中要还原到此过程开始时标识的SQL Server的数据库的复选框。 Important note Important For SharePoint, you must only restore the WSS_Content database. 重要说明重要说明对于SharePoint,您必须仅还原WSS_Content数据库。 Do not restore the WSS_AdminContent or WSS_Config databases. 不要还原WSS_AdminContent或WSS_Config数据库。 You want the new SharePoint Foundation versions of these databases, not the ones from the previous version of SharePoint or from a SharePoint installation running on any other server. 您需要这些数据库的新SharePoint Foundation版本,而不是先前版本的SharePoint或任何其他服务器上运行的SharePoint安装的版本。 Choose Overwrite the existing database(s) and then choose Restore. 选择“覆盖现有数据库”,然后选择“还原”。 The Database Restore Tool restores your data and displays progress reports. 数据库还原工具可还原您的数据并显示进度报告。 Choose Close. 选择关闭。

Probably your database is corrupt either due to an unexpected server restart or filesystem corruption. 您的数据库可能由于服务器意外重启或文件系统损坏而损坏。 You can use CheckDB to check for issues & remove the suspect status. 您可以使用CheckDB检查问题并删除可疑状态。 However, the best bet is to restore it from a working backup. 但是,最好的选择是从工作备份中还原它。

Some reasons for when this happens are 发生这种情况的一些原因是

  1. Database is corupted database files are being "opened" or held by some process (operating system, other program(s)...) 数据库损坏了,数据库文件正在“打开”或由某个进程(操作系统,其他程序...)保存。
  2. Not enough disk space for SQL Server 没有足够的磁盘空间用于SQL Server
  3. Insufficient memory (RAM) for SQL Server SQL Server的内存(RAM)不足
  4. Unexpected SQL Server shutdown caused by power failure 由于电源故障导致意外的SQL Server关闭

How to repair a suspect database 如何修复可疑数据库

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM