PostgreSQL參數—recovery_target_timeline
PostgreSQL參數—recovery_target_timeline
參數說明
postgres=# show recovery_target_timeline;
recovery_target_timeline
--------------------------
1
(1 row)
postgres=# \x
Expanded display is on.
postgres=# select * from pg_settings where name = 'recovery_target_timeline';
-[ RECORD 1 ]---+----------------------------------------------
name | recovery_target_timeline
setting | 1
unit |
category | Write-Ahead Log / Recovery Target
short_desc | Specifies the timeline to recover into.
extra_desc |
context | postmaster
vartype | string
source | configuration file
min_val |
max_val |
enumvals |
boot_val | latest
reset_val | 1
sourcefile | /home/postgres/pgdata14/pg_rman_recovery.conf
sourceline | 4
pending_restart | f
postgres=#
參數含義
recovery_target_timeline ( ``string)
指定恢復到特定時間軸。默認設置是沿著執行基本備份時的當前時間線恢復。將此設置為 latest 將恢復到存檔中找到的最新時間軸,這在備用服務器中很有用。
除此之外,您只需要在復雜的重新恢復情況下設置此參數,您需要返回到在時間點恢復后到達的狀態。
在通過pg_basebackup進行備份的時候添加參數“-R”就可以在備中自動產生recovery.conf文件,在這里就可以指定recovery_target_timeline=’‘和recovery_target_time=’'參數來進行精準恢復了,而這里的recovery_target_timeline參數可以直接填寫時間線產生的“歷史文件”名字用來指定恢復到哪一條時間線上去。
[postgres@lyp pg_wal]$ ll
total 114696
-rw-------. 1 postgres postgres 16777216 Feb 17 23:01 00000002000000000000000E
-rw-------. 1 postgres postgres 16777216 Feb 17 22:56 00000002000000000000000F
-rw-------. 1 postgres postgres 16777216 Feb 17 22:51 000000020000000000000010
-rw-------. 1 postgres postgres 16777216 Feb 17 22:51 000000020000000000000011
-rw-------. 1 postgres postgres 16777216 Feb 17 22:51 000000020000000000000012
-rw-------. 1 postgres postgres 16777216 Feb 17 22:51 000000020000000000000013
-rw-------. 1 postgres postgres 16777216 Feb 17 22:51 000000020000000000000014
-rw-------. 1 postgres postgres 50 Feb 17 22:56 00000002.history
drwx------. 2 postgres postgres 88 Feb 17 22:56 archive_status
[postgres@lyp pg_wal]$
當我們基于時間點的還原后,時間線便會加1,并創建一個名為NewTimelineID.history的新文件。00000002.history即為時間線產生的“歷史文件”名字。
[postgres@lyp ~]$ cat /home/postgres/pgdata14/pg_rman_recovery.conf # added by pg_rman 1.3.14 restore_command = 'cp /home/postgres/pgdata14/archive/%f %p' recovery_target_time = '2022-02-17 22:50:19' recovery_target_timeline = '1' [postgres@lyp ~]$
開啟數據庫之后通過讀取歸檔日志就會將數據庫恢復到’2022-02-17 22:50:19’這個時間點。
「喜歡這篇文章,您的關注和贊賞是給作者最好的鼓勵」
關注作者
【版權聲明】本文為墨天輪用戶原創內容,轉載時必須標注文章的來源(墨天輪),文章鏈接,文章作者等基本信息,否則作者和墨天輪有權追究責任。如果您發現墨天輪中有涉嫌抄襲或者侵權的內容,歡迎發送郵件至:contact@modb.pro進行舉報,并提供相關證據,一經查實,墨天輪將立刻刪除相關內容。




