由于Replication,DBCC Shrink不能收缩Log File
使用Backup创建测试环境之后,发现testdb的Log File过大,达到400GB,由于测试环境实际上不需要这么大的Log Space,占用400GB的Disk Space实在浪费Disk Resource,于是使用DBCC Shrink收缩Log File:
dbcc shrinkfile(testdb_log_5,10240,notruncate)
dbcc shrinkfile(testdb_log_5,10240,truncateonly)
命名执行完成之后,发现还有300多GB,实际Log File占用的空间的百分比十分低,0.000428%
DBCC SQLPERF(LOGSPACE)
由于test db的还原模式是Simple,并且没有active user,最大的可能性是db的Trasaction log被标记为Replication,使用以下函数统计,发现有大量的log未被LogReader读取。
select count(0)
from sys.fn_dblog(null,null) f
where f.Description ='REPLICATE'
在Publisher database中,使用 sp_repltrans 查看没有被LogReader标记为Distributed的Transaction。
sp_repltrans returns a result set of all the transactions in the publication database transaction log that are marked for replication but have not been marked as distributed.
exec sys.sp_repltrans
Unable to execute procedure. The database is not published. Execute the procedure in a database that is published for replication.
由于testdb是使用backup还原的测试数据库,没有在master中注册为Publisher database,必须设置 database 为publish,表示 Database can be used for other types of publications.
exec sys.sp_replicationdboption
@dbname = N'testdb',
@optname = N'publish',
@value = N'true'
注册成功之后,使用 sp_repldone,将所有的Transaction Log 标记为Distributed。
sp_repldone updates the record that identifies the last distributed transaction of the server.
EXEC sys.sp_repldone
@xactid = NULL,
@xact_segno = NULL,
@numtrans = 0,
@time = 0,
@reset = 1
When xactid is NULL, xact_seqno is NULL, and reset is 1, all replicated transactions in the log are marked as distributed. This is useful when there are replicated transactions in the transaction log that are no longer valid and you want to truncate the log,
最后,使用DBCC ShrinkFile命令,Transaction Log File收缩完成。
参考doc:
sp_replicationdboption (Transact-SQL)
由于Replication,DBCC Shrink不能收缩Log File的更多相关文章
- SharePoint Config database Log file too big – reduce it!
SharePoint Config database logs are one thing to keep an eye on since they do have a tendency to gro ...
- Got fatal error 1236 from master when reading data from binary log: 'Could not find first log file name in binary log index file'
setup slave from backup i got error Got fatal error 1236 from master when reading data from binary l ...
- innodb log file与binlog的区别在哪里?
Q: innodb log file与binlog的区别在哪里?有人说1.mysql的innodb引擎实际上是包装了inno base存储引擎.而innodb log file是由 inno base ...
- ORACLE等待事件: log file parallel write
log file parallel write概念介绍 log file parallel write 事件是LGWR进程专属的等待事件,发生在LGWR将日志缓冲区(log_buffer)中的重做日志 ...
- MYSQL 5.7 无法启动(Could not open error log file errno 2)
前两天电脑中毒, 病毒好像把mysql的 log.err 文件给删掉了.然后服务一直启动不了:Could not open error log file errno 2. 然后疯狂百度,搜索的结果大多 ...
- mariadb:InnoDB: Error: log file ./ib_logfile0 is of different size 0 5242880 bytes
mariadb 启动中 InnoDB: Error: log file ./ib_logfile0 is of different size 0 起因:线上正在运行的系统,因为需要调整性能,变更了my ...
- Nginx启动报错: could not open error log file: open() &q
启动nginx报如下错误: nginx: [alert] could not open error log file: open() "/usr/local/nginx/logs/error ...
- Managing IIS Log File Storage
Managing IIS Log File Storage You can manage the amount of server disk space that Internet Informa ...
- bdb log file 预设长度的性能优化
看代码随手记:log_put.c, __log_write() /* * If we're writing the first block in a log file on a filesystem ...
随机推荐
- C语言题目复习前7章重点程序
/** #include <stdio.h> #include <stdlib.h> int max(int n1, int n2) { return (n1 > n2) ...
- js中自定义构造函数讲解
什么是构造函数? 构造函数其实就是一个函数,只是用途和普通函数,不太一样, 构造函数一般用于初始化对象 <script> function Person(){ this.name=&quo ...
- C#编写windows服务
项目要求: 数据库用有一张表,存放待下载文件的地址,服务需要轮训表将未下载的文件下载下来. 表结构如下: 过程: VS--文件-->新建项目-->windows-->windows服 ...
- python使用总结
近来公司的测试部门要我们开发,按他们给我测试案例,写vba脚本,方便他们做自动化测试,老大把这事交给了我做.之前没写过vba,很多API都不会用,边写边谷歌,写得很慢. 我记得测试第一次做的是打开关闭 ...
- Oozie_示例
Oozie 官方示例 解压oozie-examples.tar.gz 将examples/上传到HDFS家目录 $ bin/hdfs dfs -put /opt/cdh-5.6.3/oozie-4.0 ...
- js实现div居中
<!doctype html> <html> <head> <meta charset="utf-8"> <title> ...
- SpringMVC 框架的搭建及基本功能的实现
首先新建一个WEB项目 导入jar包 我们基于Spring mvc框架进行开发,需要依赖一下的spring jar包: spring-aop-4.0.4.RELEASE.jar spring-bean ...
- $.each ---- 跳出当前的循环
有些朋友可能会以为在jquery跳出循环可以直接使用continue和break了,但是使用之后没有效果,因为在jquery中没有这两条命令.后来上网查了下,得到了结果:return false;—— ...
- StreamingAssets文件夹在不同平台上的引用
On a desktop computer (Mac OS or Windows) the location of the files can be obtained with the followi ...
- 转:隐马尔可夫模型(HMM)攻略
隐马尔可夫模型 (Hidden Markov Model,HMM) 最初由 L. E. Baum 和其它一些学者发表在一系列的统计学论文中,随后在语言识别,自然语言处理以及生物信息等领域体现了很大的价 ...