删除不需要的(辅助)SQL Server事务日志文件

This article explores the use of multiple SQL Server Transaction Log Files and the process of removing the secondary transaction log file.

本文探讨了多个SQL Server事务日志文件的使用以及删除辅助事务日志文件的过程。

介绍 (Introduction)

By default, a SQL Server database contains a primary data file and transaction log file. It is a good practice configuring multiple data files and split data across multiple data files. We can have these data files in separate storage drives to have multiple IO. It helps data management, improves performance, plans backup approaches according to filegroups.

默认情况下,SQL Server数据库包含主数据文件和事务日志文件。 这是配置多个数据文件并将数据拆分到多个数据文件中的一个好习惯。 我们可以将这些数据文件放在单独的存储驱动器中以具有多个IO。 它可以帮助数据管理,提高性能,根据文件组计划备份方法。

Database architecture

We can have multiple transaction log files for a database as well.

我们也可以有一个数据库的多个事务日志文件。

SQL Server uses the multiple transaction log files in sequential order. Suppose we have two transaction log files. SQL Server uses one log file at a time and once it is full, SQL Server uses another log file. Since SQL Server does not use it in parallel, we do not get any performance benefit of it. Ideally, we should have only one transaction log file per database.

SQL Server按顺序使用多个事务日志文件。 假设我们有两个事务日志文件。 SQL Server一次使用一个日志文件,一旦它满了,SQL Server将使用另一个日志文件。 由于SQL Server不会并行使用它,因此我们无法获得任何性能优势。 理想情况下,每个数据库应该只有一个事务日志文件。

Let’s assume we have a production database, and we receive a critical alert that disk is running out of space. After investigation, we’ve found out that this drive holds a transaction log file. Due to active transactions, this SQL Server transaction log file is full. We’ve tried shrinking the log file, but it did not work. We back up the transaction log also, but due to active transactions, it could not release needed space. Adding another transaction log file in a separate disk with free space will resolve this issue.

假设我们有一个生产数据库,并且收到一个严重警报,提示磁盘空间不足。 经过调查,我们发现该驱动器包含一个事务日志文件。 由于事务处于活动状态,因此此SQL Server事务日志文件已满。 我们尝试缩小日志文件,但是没有用。 我们也备份了事务日志,但是由于事务处于活动状态,因此无法释放所需的空间。 在具有可用空间的单独磁盘中添加另一个事务日志文件将解决此问题。

As SQL Server uses serial mode for writing data in a transaction log file, we should remove the additional log file later. Let’s explore the process of removing an additional log file.

由于SQL Server使用串行模式在事务日志文件中写入数据,因此我们应在以后删除其他日志文件。 让我们探讨一下删除其他日志文件的过程。

创建具有多个SQL Server事务日志文件的数据库 (Create a database with multiple SQL Server Transaction Log files)

Connect to a SQL instance in SQL Server Management Studio. Right-click on the Databases node in the Object Explorer pane and click on the New Database command:

连接到SQL Server Management Studio中SQL实例。 右键单击“对象资源管理器”窗格中的“数据库”节点,然后单击“新建数据库”命令:

Create a new database

It opens the New database window. Specify a database name and add another transaction log file. For testing p

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值