We have a TFS2017 environment. The size is growing every week for a long time now.
In this environment , i have multiple collection ; the size of Transaction Log File , is very big (overtop the 155 Gb)
My question is : It's safe to do a shirnk of the log file for the defined TFS collection ? (without loss data or getting error in administration console) ?
Thanks
Yes. You can.
The log file is there so you can restore to a point in time between full backups. If you have backups enabled on your server and regularly take a full backup, then you can truncate the logs after each full backup.
If you want to just "delete the logs" then temporarily turn off TFS by running this on every application tier server you have: TFSServiceControl quiesce, then truncate the logs, then turn TFS back on using TFSServiceControl unquiesce.
You may also want to verify your backup strategy. If all is well, you shouldn't see a ever growing log file.
See:
https://learn.microsoft.com/en-us/azure/devops/server/command-line/tfsservicecontrol-cmd?view=azure-devops-2019
Related
I am getting below error when trying to restore DB from S3 Bak file -
100 percent processed.
[2018-11-12 19:32:21.677] Processed 32980832 pages for
database 'RDSBackup', file 'SourceDB_NEW' on file 1.
[2018-11-12 19:32:21.680]
Processed 4547 pages for database
'RDSBackup', file 'SourceDB_NEW_log' on file 1.
[2018-11-12 19:32:22.013]
RDSBackup_FULL_COPY_ONLY_20181112_010009.bak:
S3 processing has been aborted.
Error started after the source DB version changed from SQL2012 Enterprise to SQL2016 Standard.
I escalated this issue to AWS. As per the latest update, they have made some changes to RDS and I could restore the DB even with a large log file (300GB).
Link for the newest update details is below -
https://aws.amazon.com/blogs/database/rds-sql-server-has-two-new-exciting-backup-and-restore-enhancements/
Alternate solution - At first, I was asked to try to restore with a smaller log file. I shrunk the logs and the restore worked.Although AWS engineers asked me to keep a check on the logfile size, they made some changes to RDS so as to accommodate S3 bak files with relatively large size as well.
Currently my db logs for my production SQL Server 2008 R2 server is growing out of control:
DATA file: D:\Data...\MyDB.mdf = 278859 MB on disk
LOG file: L:\Logs...\MyDB_1.ldf = 394542 MB on disk
The server mentioned above has daily backups scheduled #1am & translog backups every 15 min.
The database is replicated in full recovery model to a subscriber. Replciation is pushed from the node above (publisher). That same db log file on the subscriber is ~< 100 GB on disk.
What I did to try and fix:
Run a full backup of the db (takes 1h:47m)
Run the translog backup job which runs every 15 min. (takes 1m:20s)
Run another full backup of the db
Nothing above has worked so I then attempt to shrink the log files which doesn't work either using DBCC SHRINKFILE. The size doesn't ever change.
Can anyone please tell me what is wrong or what I need to do as a SQL Server DBA to resolve the above issue?
Possible things that may stop you from shrinking the translog file:
Long running transaction is occurring on your database
Your replication distribution agent runs quite frequent
Looking at the size of your translog file size, most likely it was caused by the 2nd possibility.
Your replication distribution agent runs quite frequent
SQL Server log reader agent marks the translog file as being used and prevent them from being shrunk, which is what SQL Server does after the translog file is backed up. If this process happens frequent and long enough, this could prevent your translog file from being shrunk on translog scheduled back up.
Look at this MSDN transactional explaination and how to modify log reader agent.
And a thread in MSDN forum that describe similar problem, there is DBCC query here that helps you identify running transaction that may be blocking the translog file (DBCC OPENTRAN).
Long running transaction is occurring on your database
You can check wheter any long running transaction is happening by using DBCC OPENTRAN and what process is running then decide what to do with it. As soon as the long running transaction is finished you should be able to shrink the log file.
After running sp_who2, I noticed a long running transaction on the log that was growing uncontrollably. I used kill on that SPID and not I'm proceeding to shrink the log file.
You should make blank database with same table and migrate your old database data to blank database from migration script.
for eg:
INSERT INTO customers(cust_id, Name, Address)
SELECT cust_id, Name, Address
FROM olddb.customers
--this script should run in new blank database
You can manually shrink you log file
1.right click your database > task > shrink > file > file type=log
than ok
Suddenly I saw my SQL Server is in suspect/OFF Line mode. That's why I am not able to do any any operation in my db. For this reason I restarted my server (Windows Server 2003) .
But when I get ready I found that some of my data has been lost. I have no any back up of my db.
Is there any way to get back the data that I have lost.
the error log:
Could not redo log record (5108:10151:5), for transaction ID
(0:1552370), on page (1:3679), database '??'
The database may go in suspected/offline mode if the location of datafile and the log file have been misplaced accidentally or intentionally, and so after restart the database is unable to find its datafiles and goes in suspect or offline mode. This can be resolved by bringing the datafile and the log file back to the original path that has been configured for the database. After that, the database can be restored with no loss using the command 'Restore with recovery'. The original path for the datafile and the log file can be found in the error log of the server that contains the database.
Try the solution, hope it will help as it did for me.
In another case, the database may go in suspected/offline mode due to off and restart of the server in middle of a transaction and after the restart the transactions may not be committed or rolled back to a consistent state thus leaving database in an inconsistent state turning it suspected or offline. The solution for this is:
alter database <database name> set emergency dbcc checkdb (repair_allow_data_loss)
As the commnand itself states allow data loss, this command may result in loss of some data from the transaction log and hence we may face a data loss, so it is not recommended for a frequent or unapproved use.
In this case, I suggest you check your log file (LDF). In SQL, this log file records all the INSERT, UPDATE, and DELETE query operations performed on a database.
Suppose you have an LDF file. You can work with Restore and recovery process. I used this process for one of my existing clients & It worked.
https://learn.microsoft.com/en-us/sql/relational-databases/backup-restore/restore-and-recovery-overview-sql-server?view=sql-server-ver16
If you do not have a log file, you can use stellar repair for SQL this process helps me to recover my data many times.
Thanks
i'm trying to restore our live DB onto our Dev box. To do this, I when onto production, TASKS -> backup Db. it created a 4Gig file. I zipped this down to 2.2Gig. download that to my dev server.
On my dev server, i create a new DB (called 'xxxxx') and then Tasks -> restore DB from file. I give it the .bak file name, overwrite all and go.
When it gets to 40% it fails. here's the screenie:
alt text http://img19.imageshack.us/img19/1/restorefailurejl5.png
Now, i can manually zip up the .mdf and .log files, zip them, download them and then attach them to my dev server sql instance. I did that last night actually, to get this working .. so that worked.
But i'm not sure why the backup/restore method didn't work? I've downloaded the .bak file a few times (in case the download was corrupt). i tried to rezip and re-backup the live server a few times also .. but after about the 5 download of a 2Gig file, I'm starting to get grumpy :)
I've tried doing a DBCC CHECKDB('live db name', RESTORE_REBUILD) and that worked fine and THEN backup, download, restore, fail.
My live DB is sql2008 x64bit and my dev box is x86 (32 bit), so i'm not sure if that's an issue. Both servers are versions 10.0 RTM.
I don't want to have to stop the db to be able to copy the .mdf/.log files (cause u can't access them while the db is running, i believe) .. which is why i prefer the backup/restore method.
Any suggestions?
UPDATE 1
Before i posted this question, I did do a DBCC CHECKDB ('xxxxx', RESTORE_REBUILD). I noted this in my initial post, which i've now just highlighted for future reference.
When i get a chance to stop the DB, i'll post the end results here (and save the text output incase someone asks for some other info).
UPDATE 2
I tried to restore the backup to a dummy live db i created. Failed (same error message). I'm running a DBCC CHECKDB('LiveDB') right now. Just before I did this, i stopped the SQL Server service & manually copy-backedup the .mdb and .log files.
UPDATE 3
This is the result from the DBCC CHECKDB ('LiveDb')
DBCC results
for 'Addresses' There are 1689363 rows
in 101624 pages for object 'Addresses'
DBCC results for 'Thumbnails' There
are 1197 rows in 30 pages for object
'Thumbnails' ..
CHECKDB found 0 allocation errors and
0 consistency errors in database
'LiveDb' DBCC execution completed. If
DBCC printed error messages, contact
your administrator.
hmm :( Any further ideas? Should i run DBCC again with RESTORE_REBUILD or some other magic argument?
Final Update
Ok - this is sooo weird. After running CHECK DBCC and then doing another full backup (using the same sql script that we have been using for eons) the restore now works fine! I just don't get it :(
Looks like i can close the job now. I just don't get it :(
This is IMPORTANT, you may potentially have an issue with the live database.
Have you performed DBCC CHECKDB on your production server recently? If not, do so at the next possible maintenance window.
You should ideally be performing CHECKDB before you take your full backups (although not always practical) in order to validate that the backups you are generating, are of a database that has been confirmed to be without issue.
Please feel free to pose further questions. You can contact me directly if you require additional assistance.
Cheers, John
We do the same thing every morning.
RESTORE DATABASE Accounts FROM DISK = '\\server\F$\SQL_BACKUP\DB.bak' WITH REPLACE
This works fine for us. I'm not sure if the x64 > x32 will have an impact, I wasn't aware that data was stored differently between those kinds of platforms. We basically dump our live database every night, a process on our SQL server then picks them up, and another process sends them to be backed up to disk.
The command above will create you a new database and import the data, it's worth a shot.
Sounds like your production database has some corruption. Run DBCC CHECKDB on your production database and see what is returned.
Does a restore on the live machine (to a different db) fail? If so, try running DBCC CHECKDB.
My sql server marked one database as suspected , on checking i found my mdf,ldf files are missing, but no errors on chkdsk, what it means some virus ?
Either the files were deleted, or they have been moved and a master database backup restored from before the change in location. In both cases the physical files can only be deleted or moved if the database is offline - either because sql server was shut down or the database was closed.
Either of these things is highly unlikely to have happened accidentally. It's unlikely to be a generic virus or trojan as such would either have to specifically delete the files on startup before SQL Server started (assuming your database starts automatically) or shut down the database then specifically delete the files. Given that chkdsk doesn't report errors either it's unlikely to be a disk issue, so it's a virtual certainty that the cause of the error is deliberate database (mis)management.
I think the most likely option is that a dba has decided that the files should be moved elsewhere - typically this is done for space or performance reasons - for instance if a new drive is added to a machine that is running out of space then the database could be moved to that. For some reason a backup of the master database has subsequently been restored from a point before the move.
My first action would be to do a full scan of the system for all mdf/ldf files and (hopefully) locate them. I'd also do a scan of backups and look for the latest master database backup. You could either then try restoring the last master backup and see if that fixed the issue (i'd back up the current master first of course), and failing that, or directly, reattach the missing files.
If you cannot find the mdf/ldf files then your only option is restore from backup. If you don't have a backup then your database is lost.
http://support.microsoft.com/kb/180500
At startup, SQL Server attempts to obtain an exclusive lock on the device file. If the device is being used by another process (for example, backup software) or if the file is missing, the scenario described above will be encountered. In these cases, there is usually nothing wrong with the devices and database. For the database to recover correctly, the device must be made available, and the database status must be reset.
It means someone deleted the files.
They can not be deleted when in use so it happened:
when SQL Server was shut down
the database was closed (Express version usually)
the database was taken offline
All user dbs will share the same folder (edit) by default (end edit) so this is deliberate
The more exotic options include restoring the master db where the databases/MDF files listed in the restored master db do not exist etc. But I doubt it.
In this situation, you can check the SQL Server logs. Go to Management, Click on SQL Server Logs and click on current and check the message.
In my case, I got this:
Error 17207, severity 16, state 1 (it is related to log file deletion or corruption)
Solution:
Set the database into single user mode:
Alter database dbname set single_user
Now set the database into emergency mode:
Alter database dbname set emergency
Repair missing log file or corrupted log file with data loss.
DBCC CHECKDB ('dbname', REAPIR_ALLOW_DATA_LOSS)
Note: You may loss the data by using this command. It also depends on client's approval.
Now set the db in multi user mode;
alter database dbname set multi_user
In SQL Server suspect database is a mode when user unable to connect with database.
At this time user unable to perform any action and can not do anything like no open no backup and no restore etc.
Possible cause for this problem can be one of the following:
1. Database is corrupted
2. Insufficient memory state.
3. unexpected shutdown etc.
4. OS is unable to find the database file