首页 > 数据库 >【Checkpoint】Command for log's checkpoint - SQLserver, Oracle, PostgreSQL

【Checkpoint】Command for log's checkpoint - SQLserver, Oracle, PostgreSQL

时间:2023-06-06 23:12:05浏览次数:51  
标签:PostgreSQL log checkpoint file backups backup shrink

文档引子

最近,SQLserver环境中的SQL always on 因事务爆满 导致磁盘持续告警, 通过这次事件,记载下SQLserver AG的事务日志处理的正确方式,同时也把Oracle以及PG的相关的checkpoint问题一并做个简单的总结,并且只从结果的角度给出过程,至于具体的理论,请移步官方文档查阅。

SQLserver检查点

-- 首先明确一点,SQL AG 就是SQLmirroring的升级版,同时在这两种架构下, 数据库模式都是full,而不是simple,也不能改成simple(注意甄别网上论说的)

那么 正确的truncate log的方法是: 备份事务日志,同时确保 log_reuse_wait_desc 必须是 【0】


同时通过以下命令查看,不能收缩的原因

DBCC SQLPERF(LOGSPACE)  
GO  
SELECT name,recovery_model_desc,log_reuse_wait,log_reuse_wait_desc  
FROM sys.databases  
GO 
DBCC loginfo(),可以看到该数据库的所有VLF的状态都为2,也就是active状态。


-- 官方提供很完善的处理方式 
https://learn.microsoft.com/zh-cn/sql/relational-databases/logs/troubleshoot-a-full-transaction-log-sql-server-error-9002?view=sql-server-2017
(介绍了log_reuse_wait的13个参数的意义和对应的解决方案)




-- 摘抄点老外写的原著

If you are in simple recovery model
Just shrink the file! If the file doesn't shrink to the size you want, then try again, and again. If it still doesn't shrink to the size you want, then read this (the "Shrinking of transaction log file" section).

If you are in full recovery model
... and this is where you want to be, then you have to make a decision:

Is it OK to break the transaction log backup chain? 
By this we mean the chain of log backups you may have. If you don't have any prior log backups (perhaps not even a prior database backup), then it is OK to break the chain of log backups. If you do have earlier log backups and want to be able to restore from them up to any point in time then it isn't OK to break the chain of log backups.
OK to break the chain of log backups. This is easiest:
Set recovery model to simple.
Do the shrink according to the steps above (for a database in simple recovery model).
Set recovery model to full.
Perform a full database backup, so your scheduled log backups have somewhere to begin from.
Not OK to break the log backup chain. Then you backup the log (which can produce a huge log backup file, and consequently take some time), and then shrink the file. If the file doesn't shrink to the size you want, then backup log and shrink again, and again. If it still doesn't shrink to the size you want, then read this (the "Shrinking of transaction log file" section).

ORACLE的检查点

-- checkpoint 官方文档介绍:https://docs.oracle.com/en/database/oracle/oracle-database/19/refrn/LOG_CHECKPOINT_INTERVAL.html 
-- checkpoint 需要和 SCN 等理论,移步google或者https://docs.oracle.com查阅
-- 这里我们只讲 checkpoint的意义和什么时候最好是有这么一个操作。

Oracle checkpoint 的意义在于保持数据库中的内存数据都能即使写入磁盘,

Oracle checkpoint 有多种自动触发方式,如日志自动切换时/shutdown immediate时/表空间offline/数据库执行冷备份时/删除extend等
也有手动触发方式,如alter system switch logfile ,alter system checkpoint 


Oracle checkpoint 需要手动执行的情况一般发生在 使用数据泵进行数据迁移时, 为了保证正在运行的数据库能保持数据的一致性 在 expdp中加入参数 flashback_time=systimestamp

PostgreSQL检查点



标签:PostgreSQL,log,checkpoint,file,backups,backup,shrink
From: https://www.cnblogs.com/Jeona/p/17461963.html

相关文章

  • 日志技术:logback的快速入门
         ......
  • 日志技术:体系结构、Logback日志框架介绍
         ......
  • sklearn和statsmodels中logit的区别
    sklearn中的logit是加了L2正则的逻辑回归,statsmodels中的是标准的LR 原文......
  • 2_Transferring Files, Passwordless login & Managing multiple servers
     原文:https://www.codewithharry.com/blogpost/transferring-files-passwordless-login-ubuntu-20-04/ TransferringFiles,Passwordlesslogin&ManagingmultipleserversInthispost,Iwillshowyouhowtoavoidenteringpasswordsmultipletimeswhilema......
  • 合并数组与非合并数组 -- SystemVerilog
    合并型数组(packed):合并型数组可以实现连续的存储,赋值时不需要用 ’{}。 数组中,数据排列为{ b_pack[2], b_pack[1],b_pack[0]},其中每个b_pack为8个bit;bit是二值逻辑,每位bit只占据1位。故24位(8bit*3)只占据一个word(一般一个word为32bit)的存储空间。 非合并型数组......
  • git log 的使用方法
    1,显示被修改文件的修改统计信息,添加或删除了多少行。gitlog--stat2,显示最近两条的修改gitlog--stat-23,显示具体的修改gitlog-p-24,显示我自己的修改gitlog--stat--author=wangkongming5,查看单个文件最近两次修改的记录gitlog--stat-2--./classes/api/controller......
  • Postgresql,MySQL, SQL Server 的多表连接(join)update 操作
    数据库更新时经常会join其他表做判断更新,PostgreSQL的写法与其他关系型数据库更有不同,下面以SQLServer,MySQL,PostgreSQL的数据库做对比和展示。先造数据源。createtableA(idint,cityvarchar(20));createtableB(idint,namevarchar(20));insertintoAvalues(1......
  • 拓扑错误:自交。jts.geom.TopologyException: found non-noded intersection between L
    Thatbeingsaid,youwillwanttoensurethegeometriesarevalidbeforecomputingtheintersection,using polygon1.isValid() and polygon2.isValid().Thesampledatafor polygon2 isself-intersecting,sotheintersectionoperationfailswithcom.vividso......
  • slf4j 和 log4j合用的(Maven)配置
    简述: 添加logger的日志输出,下面是配置信息供备忘  步骤:1.在Maven的porn.xml文件中添加dependency如下<dependency><groupId>org.slf4j</groupId><artifactId>slf4j-log4j12</artifactId><version>1.7.2</version></dependency>......
  • Storm-源码分析-Topology Submit-Client
    1StormClient最开始使用storm命令来启动topology,如下stormjarstorm-starter-0.0.1-SNAPSHOT-standalone.jarstorm.starter.WordCountTopology这个storm命令是用python实现的,看看其中的jar函数,很简单,调用exec_storm_class,其中jvmtype=”-client” 而exec_storm_clas......