ICode9

精准搜索请尝试: 精确搜索
首页 > 其他分享> 文章详细

pg14.3主备切换时报错

2022-08-18 16:31:53  阅读:130  来源: 互联网

标签:03 时报 16 18 08 主备 pg14.3 CST postgres


一、报错:

[postgres@dba01 archive]$ pg_ctl -D /data/pg14 start
waiting for server to start....2022-08-18 16:11:43.883 CST [45459] LOG: redirecting log output to logging collector process
2022-08-18 16:11:43.883 CST [45459] HINT: Future log output will appear in directory "/data/pg14/log".
stopped waiting
pg_ctl: could not start server
Examine the log output.

[postgres@dba01 log]$ cat pg_log_2022-08-18_160305.
pg_log_2022-08-18_160305.csv pg_log_2022-08-18_160305.log
[postgres@dba01 log]$ cat pg_log_2022-08-18_160305.csv
2022-08-18 16:03:05.244 CST,,,45400,,62fdf239.b158,1,,2022-08-18 16:03:05 CST,,0,LOG,00000,"ending log output to stderr",,"Future log output will go to log destination ""csvlog"".",,,,,,,"","postmaster",,0
2022-08-18 16:03:05.244 CST,,,45400,,62fdf239.b158,2,,2022-08-18 16:03:05 CST,,0,LOG,00000,"starting PostgreSQL 14.3 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-44), 64-bit",,,,,,,,,"","postmaster",,0
2022-08-18 16:03:05.245 CST,,,45400,,62fdf239.b158,3,,2022-08-18 16:03:05 CST,,0,LOG,00000,"listening on IPv4 address ""0.0.0.0"", port 1921",,,,,,,,,"","postmaster",,0
2022-08-18 16:03:05.245 CST,,,45400,,62fdf239.b158,4,,2022-08-18 16:03:05 CST,,0,LOG,00000,"listening on IPv6 address ""::"", port 1921",,,,,,,,,"","postmaster",,0
2022-08-18 16:03:05.247 CST,,,45400,,62fdf239.b158,5,,2022-08-18 16:03:05 CST,,0,LOG,00000,"listening on Unix socket ""/tmp/.s.PGSQL.1921""",,,,,,,,,"","postmaster",,0
2022-08-18 16:03:05.249 CST,,,45402,,62fdf239.b15a,1,,2022-08-18 16:03:05 CST,,0,LOG,00000,"database system was shut down at 2022-08-18 15:55:59 CST",,,,,,,,,"","startup",,0
2022-08-18 16:03:05.249 CST,,,45402,,62fdf239.b15a,2,,2022-08-18 16:03:05 CST,,0,LOG,00000,"entering standby mode",,,,,,,,,"","startup",,0
2022-08-18 16:03:05.249 CST,,,45402,,62fdf239.b15a,3,,2022-08-18 16:03:05 CST,,0,FATAL,XX000,"requested timeline 2 is not a child of this server's history","Latest checkpoint is at 0/D000028 on timeline 1, but in the history of the requested timeline, the server forked off from that timeline at 0/7000148.",,,,,,,,"","startup",,0
2022-08-18 16:03:05.249 CST,,,45400,,62fdf239.b158,6,,2022-08-18 16:03:05 CST,,0,LOG,00000,"startup process (PID 45402) exited with exit code 1",,,,,,,,,"","postmaster",,0
2022-08-18 16:03:05.249 CST,,,45400,,62fdf239.b158,7,,2022-08-18 16:03:05 CST,,0,LOG,00000,"aborting startup due to startup process failure",,,,,,,,,"","postmaster",,0
2022-08-18 16:03:05.250 CST,,,45400,,62fdf239.b158,8,,2022-08-18 16:03:05 CST,,0,LOG,00000,"database system is shut down",,,,,,,,,"","postmaster",,0

二、原因:

新备库pg_wal目录下的00000002.history 这个跟新主库不一致。

 

三、新备库(主转)

[postgres@dba01 pg_wal]$ ls -la
总用量 49164
drwx------. 3 postgres postgres 196 8月 18 16:13 .
drwx------. 20 postgres postgres 4096 8月 18 16:14 ..
-rw-------. 1 postgres postgres 338 8月 18 14:55 00000001000000000000000B.00000028.backup
-rw-------. 1 postgres postgres 16777216 8月 18 15:55 00000001000000000000000C
-rw-------. 1 postgres postgres 16777216 8月 18 15:55 00000001000000000000000D
-rw-------. 1 postgres postgres 16777216 8月 18 14:55 00000001000000000000000E
-rw-------. 1 postgres postgres 41 8月 18 16:13 00000002.history
drwx------. 2 postgres postgres 125 8月 18 15:55 archive_status
[postgres@dba01 pg_wal]$ pwd
/data/pg14/pg_wal

将新备库的00000002.history备份,并删除,新主库上复制过来

 

-bash-4.2$ scp -rv 00000002.history postgres@192.168.159.133:/data/pg14/pg_wal/

[postgres@dba01 pg_wal]$ pg_ctl start 正常

 

[postgres@dba01 pg_wal]$ pg_controldata
pg_control version number: 1300
Catalog version number: 202107181
Database system identifier: 7133089316689948049
Database cluster state: in archive recovery   主成为了备库
pg_control last modified: 2022年08月18日 星期四 16时14分02秒
Latest checkpoint location: 0/D000028
Latest checkpoint's REDO location: 0/D000028
Latest checkpoint's REDO WAL file: 00000001000000000000000D
Latest checkpoint's TimeLineID: 1
Latest checkpoint's PrevTimeLineID: 1
Latest checkpoint's full_page_writes: on
Latest checkpoint's NextXID: 0:739
Latest checkpoint's NextOID: 16389
Latest checkpoint's NextMultiXactId: 1
Latest checkpoint's NextMultiOffset: 0
Latest checkpoint's oldestXID: 727
Latest checkpoint's oldestXID's DB: 1
Latest checkpoint's oldestActiveXID: 0
Latest checkpoint's oldestMultiXid: 1
Latest checkpoint's oldestMulti's DB: 1
Latest checkpoint's oldestCommitTsXid:0
Latest checkpoint's newestCommitTsXid:0
Time of latest checkpoint: 2022年08月18日 星期四 15时55分59秒
Fake LSN counter for unlogged rels: 0/3E8
Minimum recovery ending location: 0/D0000A0
Min recovery ending loc's timeline: 1
Backup start location: 0/0
Backup end location: 0/0
End-of-backup record required: no
wal_level setting: replica
wal_log_hints setting: on
max_connections setting: 100
max_worker_processes setting: 8
max_wal_senders setting: 10
max_prepared_xacts setting: 0
max_locks_per_xact setting: 64
track_commit_timestamp setting: off
Maximum data alignment: 8
Database block size: 8192
Blocks per segment of large relation: 131072
WAL block size: 8192
Bytes per WAL segment: 16777216
Maximum length of identifiers: 64
Maximum columns in an index: 32
Maximum size of a TOAST chunk: 1996
Size of a large-object chunk: 2048
Date/time type storage: 64-bit integers
Float8 argument passing: by value
Data page checksum version: 0
Mock authentication nonce: 218bf631b257b4b1ed58bb161a4aa34adae4dadf1e0526583be42419b640f18b

标签:03,时报,16,18,08,主备,pg14.3,CST,postgres
来源: https://www.cnblogs.com/chinaops/p/16599157.html

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有