由于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 ...
随机推荐
- HttpClient发送Get和Post请求
package JanGin.httpClient.demo; import java.io.IOException; import java.io.UnsupportedEncodingExcept ...
- 【转】Oracle索引的类型
数据库的应用类型分为 OLTP(OnLine Transaction Processing ,联机事务处理):OLTP是传统关系型数据库的主要应用,其主要面向基本的.日常的事务处理,例如银行交易. O ...
- Object-C 1.0 第三章:面向对象编程基础知识(OOP)
1. 间接(indirection) 1.1 变量和间接(使用变量来代替一些数字) 1.2 使用文件名的间接 const 表示一个变量不允许 ...
- ThinkPHP框架的一些基础应用
这是俺滴师傅给俺传授了的知识,特在此分享. TP框架,做PHP开发的都应该有所耳闻.下面,我们就来说说入口文件的生成: 创建新项目时,首先,在目录文件下创建一个新的文件夹.然后将Thinkphp框架文 ...
- CentOS安装配置redis
安装前准备,安装gcc 先用 gcc -v命令检测本机是否安装gcc,如果没有则用下面命令安装: yum install cpp yum install binutils yum install gl ...
- chm文件索引丢失和不能搜索
regsvr32 hhctrl.ocx regsvr32 itss.dll regsvr32 itircl.dll
- C#委托与事件初探
最近刚刚接触C#,学到事件与委托部分无法理解,于是上网查阅了各种资料,终于明白了一些,在此进行总结. 一.C语言中的函数指针 想要理解什么是委托,就要先理解函数指针的概念.所谓函数指针,就是指向函数的 ...
- swfupload纠结bug总结
上传控件传到客户端的信息在IE7下乱码: 服务端 HttpUtility.UrlEncode,客户端 decodeURIComponent 上传大文件报404错: 用fiddler截取发现提示: 最可 ...
- #iOS问题记录#动态Html加载本地CSS和JS文件
所谓动态Html,指代码中组合生成的html字符串: 若需要加载本地CSS,图片,JS文件,则, 1,需要文件的全路径: 2,需要"file:///"标志: 例如: //获取文件全 ...
- html、canvas、视频灰度、反色
效果图: 代码: <!DOCTYPE html> <html lang="en"> <head> <meta charset=" ...