The log file for database is full

孤人 提交于 2019-12-04 19:32:50

问题


So our SQL Server 2000 is giving me the error, "The log file for database is full. Back up the transaction log for the database to free up some log space."

How do I go about fixing this without deleting the log like some other sites have mentioned?

Additional Info: Enable AutoGrowth is enabled growing by 10% and is restricted to 40MB.


回答1:


Scott, as you guessed: truncating the log is a bad move if you care about your data.

The following, free, videos will help you see exactly what's going on and will show you how to fix the problem without truncating the logs. (These videos also explain why that's such a dangerous hack and why you are right to look for another solution.)

  • SQL Server Backups Demystified
  • SQL Server Logging Essentials
  • Understanding Backup Options

Together these videos will help you understand exactly what's going on and will show you whether you want to switch to SIMPLE recovery, or look into actually changing your backup routines. There are also some additional 'how-to' videos that will show you exactly how to set up your backups to ensure availability while managing log file sizing and growth.




回答2:


To just empty it:

backup log <dbname> with truncate_only  

To save it somewhere:

backup log <dbname> to disk='c:\somefile.bak'

If you dont really need transactional history, try setting the database recovery mode to simple.




回答3:


ether backup your database logs regularly if you need to recover up to the minute or do other fun stuff like log shipping in the future, or set the database to simple mode and shrink the data file.

DO NOT copy, rename, or delete the .ldf file this will break your database and after you recover from this you may have data in an inconsistent state making it invalid.




回答4:


I don't think renaming or moving the log file will work while the database is online.

Easiest thing to do, IMO, is to open the properties for the database and switch it to Simple Recovery Model. then shrink the database and then go back and set the DB to Full Recoery Model (or whatever model you need).

Changing the logging mode forces SQL Server to set a checkpoint in the database, after which shrinking the database will free up the excess space.




回答5:


My friend who faced this error in the past recommends:

Try

  • Backing up the DB. The maintenance plan includes truncation of these files.
  • Also try changing the 'recovery mode' for the DB to Simple (instead of Full for instance)

Cause: The transaction log swells up due to events being logged (Maybe you have a number of transactions failing and being rolled back.. or a sudden peaking in transactions on the server )




回答6:


You may want to check related SO question:

  • How do you clear the transaction log in a SQL Server 2005 database?



回答7:


Well you could take a copy of the transaction log, then truncate the log file, which is what the error message suggests.

If disk space is full and you can't copy the log to another machine over the network, then connect a drive via USB and copy it off that way.




回答8:


You have the answer in your question: Backup the log, then it will be shrunk. Make a maintenance plan to regularly backup the database and don't forget to select "Backup the transaction log". That way you'll keep it small.




回答9:


If it's a non production environment use

dump tran <db_name> with no_log;

Once this has completed shrink the log file to free up disk space. Finally switch database recovery mode to simple.




回答10:


As soon as you take a full backup of the database, and the database is not using the Simple recovery model, SQL Server keeps a complete record of all transactions ever performed on the database. It does this so that in the event of a catastrophic failure where you lose the data file, you can restore to the point of failure by backing up the log and, once you have restored an old data backup, restore the log to replay the lost transactions.

To prevent this building up, you must back up the transaction log. Or, you can break the chain at the current point using the TRUNCATE_ONLY or NO_LOG options of BACKUP LOG.

If you don't need this feature, set the recovery model to Simple.




回答11:


My dear friend it is vey important for a DBA to check his log file quite frequently. Because if you don't give much attention towards it some day it is going to give this error.

For this purpose you have to periodically take back up so that the logs file would not faced such error.

Other then this the above given suggestion are quite right.




回答12:


Rename it it. eg:
old-log-16-09-08.log

Then the SQL server can use a new empty one.



来源:https://stackoverflow.com/questions/72961/the-log-file-for-database-is-full

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!