PG14归档失败解决办法archiver failed on wal_lsn

案例1:pg_wal下有wal_lsn文件

案例1适用于以下场景:

  • pg_wal下有该wal_lsn文件而归档目录下无该wal_lsn文件
  • pg_wal和归档目录下同时都有该wal_lsn文件

问题描述

昨晚Repmgr+PG14主备主库因wal日志撑爆磁盘,删除主库过期wal文件重做备库后上午进行主备状态巡查,主库向备库发送wal文件正常,但是查主库状态时发现显示有1条归档失败的记录。
postgres: archiver failed on 000000010000006F00000086

  • 主库:

walsender repmgr 172.28.32.23(36122) streaming 72/1BAC3A10" walsender正常
archiver failed on 000000010000006F00000086" 归档失败

  • 备库:

walreceiver streaming 77/9EB6A198" “” “” " walreceiver正常

--查主库数据库状态
[root@pgmaster ~]# systemctl status postgres
● postgres.service - PostgreSQL database server
Loaded: loaded (/usr/lib/systemd/system/postgres.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2023-10-12 22:04:08 CST; 13h ago
Process: 3710968 ExecStart=/server/data/pgdb/pgsql/bin/pg_ctl start -D $PGDATA (code=exited, status=0/SUCCESS)
Main PID: 3710970 (postgres)
Tasks: 53 (limit: 201967)
Memory: 19.0G
CGroup: /system.slice/postgres.service
├─ 3710970 /server/data/pgdb/pgsql/bin/postgres -D /server/data/pgdb/data
├─ 3710971 "postgres: logger " "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
├─ 3710992 "postgres: checkpointer " "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
├─ 3710993 "postgres: background writer " "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
├─ 3710994 "postgres: walwriter " "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
├─ 3710995 "postgres: archiver failed on 000000010000006F00000086" "" "" "" "" "" "" "" "" ""
├─ 3710996 "postgres: logical replication launcher " "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
├─ 3711001 "postgres: top_portal top_portal 172.28.32.18(41438) idle" "" "" "" "" "" ""
├─ 3711003 "postgres: tj_sjjh dataexchange 172.28.32.28(35406) idle" "" "" "" "" "" "" ""
├─ 3711009 "postgres: repmgr repmgr 172.28.32.22(64096) idle" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
├─ 3711468 "postgres: top_portal top_portal 172.28.32.18(41720) idle" "" "" "" "" "" ""
├─ 3713807 "postgres: top_portal top_portal 172.28.32.20(44492) idle" "" "" "" "" "" ""
├─ 3723017 "postgres: walsender repmgr 172.28.32.23(36122) streaming 72/1BAC3A10"  #wal 发送正常

--查备库状态
[root@pgslave ~]# systemctl status postgres
● postgres.service - PostgreSQL database server
Loaded: loaded (/usr/lib/systemd/system/postgres.service; enabled; vendor preset: disabled)
Active: active (running) since Fri 2023-10-13 00:12:19 CST; 12h ago
Process: 1931221 ExecStart=/server/data/pgdb/pgsql/bin/pg_ctl start -D $PGDATA (code=exited, status=0/SUCCESS)
Main PID: 1931223 (postgres)
Tasks: 7 (limit: 201967)
Memory: 23.2G
CGroup: /system.slice/postgres.service
├─ 1931223 /server/data/pgdb/pgsql/bin/postgres -D /server/data/pgdb/data
├─ 1931224 "postgres: logger " "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
├─ 1931225 "postgres: startup recovering 00000001000000770000009E" "" "" "" "" "" "" "" "" ""
├─ 1931226 "postgres: checkpointer " "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
├─ 1931227 "postgres: background writer " "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
├─ 1931230 "postgres: walreceiver streaming 77/9EB6A198" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""   #wal接收
└─ 1931430 "postgres: repmgr repmgr 172.28.32.23(22956) idle" "" "" "" "" "" "" "" "" "" "" "" "" "" ""

Oct 13 00:12:17 pgslave systemd[1]: Starting PostgreSQL database server...
Oct 13 00:12:17 pgslave pg_ctl[1931221]: waiting for server to start....
Oct 13 00:12:17 pgslave pg_ctl[1931223]: 2023-10-13 00:12:17.497 CST [1931223] LOG:  redirecting log output to logging collector process
Oct 13 00:12:17 pgslave pg_ctl[1931223]: 2023-10-13 00:12:17.497 CST [1931223] HINT:  Future log output will appear in directory "log".
Oct 13 00:12:19 pgslave pg_ctl[1931221]: . done
Oct 13 00:12:19 pgslave pg_ctl[1931221]: server started
Oct 13 00:12:19 pgslave systemd[1]: Started PostgreSQL database server.

问题分析

1.查看数据库日志

image.png

2.查看归档配置参数

参数配置正确,归档目录权限也正确

postgres=# show archive_command;
                      archive_command                      
-----------------------------------------------------------
 /usr/bin/lz4 -q -z %p /server/data/pgdb/pg_archive/%f.lz4
(1 row)

postgres=# show archive_mode;
 archive_mode 
--------------
 on
(1 row)

--查看归档目录的权限
[postgres@pgmaster ~]$ ls -ld /server/data/pgdb/pg_archive
drwxr-x--- 2 postgres postgres 4214784 Oct 13 13:14 /server/data/pgdb/pg_archive

3.手动切日志

手工归档成功,但是未解决,查看状态依然时卡住归档失败的那条wal记录那里

--手工归档
top_portal=# select pg_switch_wal();
 pg_switch_wal 
---------------
 72/51C4CFD8
(1 row)

--查主库数据库状态
[root@pgmaster ~]# systemctl status postgres
● postgres.service - PostgreSQL database server
Loaded: loaded (/usr/lib/systemd/system/postgres.service; enabled; vendor preset: disabled)
Active: active (running) since Thu 2023-10-12 22:04:08 CST; 13h ago
Process: 3710968 ExecStart=/server/data/pgdb/pgsql/bin/pg_ctl start -D $PGDATA (code=exited, status=0/SUCCESS)
Main PID: 3710970 (postgres)
Tasks: 53 (limit: 201967)
Memory: 19.0G
CGroup: /system.slice/postgres.service
├─ 3710970 /server/data/pgdb/pgsql/bin/postgres -D /server/data/pgdb/data
├─ 3710971 "postgres: logger " "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
├─ 3710992 "postgres: checkpointer " "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
├─ 3710993 "postgres: background writer " "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
├─ 3710994 "postgres: walwriter " "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
├─ 3710995 "postgres: archiver failed on 000000010000006F00000086" "" "" "" "" "" "" "" "" ""
├─ 3710996 "postgres: logical replication launcher " "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
├─ 3711001 "postgres: top_portal top_portal 172.28.32.18(41438) idle" "" "" "" "" "" ""
├─ 3711003 "postgres: tj_sjjh dataexchange 172.28.32.28(35406) idle" "" "" "" "" "" "" ""
├─ 3711009 "postgres: repmgr repmgr 172.28.32.22(64096) idle" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
├─ 3711468 "postgres: top_portal top_portal 172.28.32.18(41720) idle" "" "" "" "" "" ""
├─ 3713807 "postgres: top_portal top_portal 172.28.32.20(44492) idle" "" "" "" "" "" ""
├─ 3723017 "postgres: walsender repmgr 172.28.32.23(36122) streaming 72/1BAC3A10"  #wal 发送正常


--查当前wal_lsn
top_portal=# select pg_current_wal_lsn();
 pg_current_wal_lsn 
--------------------
 72/52638F10
(1 row)

--查当前wal_lsn对应的wal文件
top_portal=# select pg_walfile_name(pg_current_wal_lsn());
     pg_walfile_name      
--------------------------
 000000010000007200000052
(1 row)

--查当前最新检查点,最新检查点之前的wal文件均可以删除
[postgres@pgmaster ~]$ pg_controldata $PGDATA
pg_control version number:            1300
Catalog version number:               202107181
Database system identifier:           7268852449124462799
Database cluster state:               in production
pg_control last modified:             Fri 13 Oct 2023 10:07:35 AM CST  
Latest checkpoint location:           71/CDD2FF28
Latest checkpoint's REDO location:    71/CDD28F18
Latest checkpoint's REDO WAL file:    0000000100000071000000CD

--查报错中的wal文件
[postgres@pgmaster pg_wal]$ ls -l 000000010000006F00000086
-rw------- 1 postgres postgres 16777216 Oct 12 21:12 000000010000006F00000086
[postgres@pgmaster pg_wal]$ find /server/data/pgdb/pg_archive -name 000000010000006F00000086*
ls: cannot access '000000010000006F00000086': No such file or directory
[postgres@pgmaster pg_wal]$ find /server -name 000000010000006F00000086*
-rw------- 1 postgres postgres 16777216 Oct 12 21:12 000000010000006F00000086

4.检查$PGDATA/pg_wal/archive_status/目录下文件

[postgres@pgmaster ~]$ cd /server/data/pgdb/data/pg_wal/archive_status/
[postgres@pgmaster archive_status]$ ls -l *.ready
ls: cannot access '*.ready': No such file or directory

说明不存在需要归档但没归档的文件

该目录下,ready说明是需要归档但是没归档的,done是归档完成了的

解决办法

1.将归档失败的wal文件备份到/home/postgres目录下(生产环境如果磁盘空间允许切记不要rm删除,mv备份到目标位置)
2.手工归档select pg_switch_wal();
3.再次查看主备库状态

--1.将归档失败的wal文件备份到/home/postgres目录下
[postgres@pgmaster pg_wal]$ mv 000000010000006F00000086 /home/postgres/000000010000006F00000086
[postgres@pgmaster pg_wal]$ ls -l /home/postgres/000000010000006F00000086
-rw------- 1 postgres postgres 16777216 Oct 12 21:12 /home/postgres/000000010000006F00000086

--2.手工归档
postgres=# select pg_switch_wal();
 pg_switch_wal 
---------------
 73/7EF502E0
(1 row)

--3.再次查看主库状态显示正常
[root@pgmaster data]# systemctl status postgres
● postgres.service - PostgreSQL database server
     Loaded: loaded (/usr/lib/systemd/system/postgres.service; enabled; vendor preset: disabled)
     Active: active (running) since Thu 2023-10-12 22:04:08 CST; 13h ago
    Process: 3710968 ExecStart=/server/data/pgdb/pgsql/bin/pg_ctl start -D $PGDATA (code=exited, status=0/SUCCESS)
   Main PID: 3710970 (postgres)
      Tasks: 50 (limit: 201967)
     Memory: 26.6G
     CGroup: /system.slice/postgres.service
             ├─ 3710970 /server/data/pgdb/pgsql/bin/postgres -D /server/data/pgdb/data
             ├─ 3710971 "postgres: logger " "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
             ├─ 3710992 "postgres: checkpointer " "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
             ├─ 3710993 "postgres: background writer " "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
             ├─ 3710994 "postgres: walwriter " "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
             ├─ 3710995 "postgres: archiver archiving 000000010000007100000035" "" "" "" "" "" "" "" "" ""
             ├─ 3710996 "postgres: logical replication launcher " "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
             ├─ 3711001 "postgres: top_portal top_portal 172.28.32.18(41438) idle" "" "" "" "" "" ""
             ├─ 3711003 "postgres: tj_sjjh dataexchange 172.28.32.28(35406) idle" "" "" "" "" "" "" ""
             ├─ 3711009 "postgres: repmgr repmgr 172.28.32.22(64096) idle" "" "" "" "" "" "" "" "" "" "" "" "" "" ""
             ├─ 3711468 "postgres: top_portal top_portal 172.28.32.18(41720) idle" "" "" "" "" "" ""
             ├─ 3713807 "postgres: top_portal top_portal 172.28.32.20(44492) idle" "" "" "" "" "" ""
             ├─ 3723017 "postgres: walsender repmgr 172.28.32.23(36122) streaming 73/7F000BD0"

补充

若$PGDATA/pg_wal/archive_status/目录下存在大量的*.ready文件
可能的原因分析:如果数据库是突然断电,那么可能arvchive命令没有完全完成,归档目录会存在不完整的文件名称,重启数据库后,会出现归档失败的情况,这个时候,需要去归档目录删除相关归档失败文件,那么归档就会重新归档。
需要注意的是,archive_command 设定的归档命令是否成功执行,如果未成功,它会周期性的重试,在此期间已有的WAL日志将不会被覆盖重用,新的WAL日志信息会不断占用 pg_wal 的磁盘空间,知道pg_wal所在磁盘沾满后数据库关闭。由于参数 wal_level 与 archive_mode 需要重启数据库,可以在安装之初启动数据库之前,开启这两个参数,然后将 archive_command 的值设置为永远为真的值,例如:/bin/true。当需要开启归档时,只需要修改 archive_command,reload即可。省去重启数据库的步骤。

案例2:pg_wal和归档目录下同时都没该wal_lsn文件

案例2适用于以下场景:

  • pg_wal和归档目录下同时都没该wal_lsn文件

问题描述

开发让释放测试环境pg10数据库的归档空间,清理前检查数据库运行状态发现归档失败,提示archiver process failed on 000000010000000000000001,分析发下pg_wal和归档目录下同时都没该wal_lsn文件,查看多个日志最终发现从2022-12-31开始就已经归档失败了,沟通得知该库一直没人维护。

--查看数据库运行状态时发现归档失败
[root@localhost log]# ps -ef | grep postgres
postgres  1099     1  0 11月14 ?      00:00:05 /usr/pgsql-11/bin/postmaster -D /dsg3/postgres/pg115_data
postgres  1103     1  0 11月14 ?      00:00:15 /usr/pgsql-10/bin/postmaster -D /dsg3/postgres/pg10_data/
postgres  1532  1099  0 11月14 ?      00:00:00 postgres: logger   
postgres  1595  1103  0 11月14 ?      00:00:16 postgres: logger process   
postgres  1674  1099  0 11月14 ?      00:00:00 postgres: checkpointer   
postgres  1675  1099  0 11月14 ?      00:00:18 postgres: background writer   
postgres  1676  1099  0 11月14 ?      00:00:18 postgres: walwriter   
postgres  1677  1099  0 11月14 ?      00:00:12 postgres: autovacuum launcher   
postgres  1678  1099  0 11月14 ?      00:00:39 postgres: archiver   
postgres  1679  1099  0 11月14 ?      00:00:14 postgres: stats collector   
postgres  1680  1099  0 11月14 ?      00:00:01 postgres: logical replication launcher   
postgres  1682  1103  0 11月14 ?      00:00:00 postgres: checkpointer process   
postgres  1683  1103  0 11月14 ?      00:00:19 postgres: writer process   
postgres  1684  1103  0 11月14 ?      00:00:18 postgres: wal writer process   
postgres  1685  1103  0 11月14 ?      00:00:13 postgres: autovacuum launcher process   
postgres  1686  1103  0 11月14 ?      00:05:19 postgres: archiver process   failed on 000000010000000000000001
postgres  1687  1103  0 11月14 ?      00:00:28 postgres: stats collector process   
postgres  1688  1103  0 11月14 ?      00:00:01 postgres: bgworker: logical replication launcher   
root      8779  8736  0 15:01 pts/0    00:00:00 su - postgres
postgres  8780  8779  0 15:01 pts/0    00:00:00 -bash
root     10057  8888  0 15:17 pts/1    00:00:00 grep --color=auto postgres
postgres 16957  1103  0 11月21 ?      00:00:00 postgres: topicis topicis 192.168.5.211(58552) idle
postgres 16958  1103  0 11月21 ?      00:00:00 postgres: topicis topicis 192.168.5.211(58555) idle
postgres 16959  1103  0 11月21 ?      00:00:00 postgres: topicis topicis 192.168.5.211(58556) idle
postgres 16960  1103  0 11月21 ?      00:00:00 postgres: topicis topicis 192.168.5.211(58558) idle

问题分析

--检查归档参数配置
-bash-4.2$ /usr/pgsql-10/bin/psql -p 54310
psql (10.22)
输入 "help" 来获取帮助信息.

postgres=# show archive_mode;
 archive_mode 
--------------
 on
(1 行记录)

postgres=# show archive_command;
               archive_command                
----------------------------------------------
 cp %p /dsg3/postgres/pg10_data/pg_archive/%f
(1 行记录)

postgres=# \q

--检查归档目录权限
-bash-4.2$ ls -ld /dsg3/postgres/pg10_data/pg_archive
drwxr-xr-x 2 postgres postgres 4096 12月  1 13:59 /dsg3/postgres/pg10_data/pg_archive

--查看多个日志最终发现从2022-12-31开始就已经归档失败了
-bash-4.2$ tail -200f postgresql-2022-12-31_000000.log
cp: 无法获取"pg_wal/000000010000000000000001" 的文件状态(stat): 没有那个文件或目录
2022-12-31 23:58:29.002 CST [1706] 日志:  归档命令执行失败,退出代码为 1
2022-12-31 23:58:29.002 CST [1706] 详细信息:  执行失败的归档命令是: cp pg_wal/000000010000000000000001 /dsg3/postgres/pg10_data/pg_archive/000000010000000000000001
cp: 无法获取"pg_wal/000000010000000000000001" 的文件状态(stat): 没有那个文件或目录
2022-12-31 23:58:30.012 CST [1706] 日志:  归档命令执行失败,退出代码为 1
2022-12-31 23:58:30.012 CST [1706] 详细信息:  执行失败的归档命令是: cp pg_wal/000000010000000000000001 /dsg3/postgres/pg10_data/pg_archive/000000010000000000000001
2022-12-31 23:58:30.012 CST [1706] 警告:  archiving write-ahead log file "000000010000000000000001" failed too many times, will try again later
2022-12-31 23:59:00.016 CST [23391] 错误:  字段 "sysdate" 不存在 第 147 个字符处
2022-12-31 23:59:00.016 CST [23391] 语句:  select code,sum(1) as sum,sum(investorcount) as invsum from LOG_SYNCNAMEINFO where logtype = '成功' and date_trunc('day',logTime)= date_trunc('day',sysdate - interval '1 day') group by code order by code
2022-12-31 23:59:00.027 CST [23391] 错误:  字段 "sysdate" 不存在 第 123 个字符处
2022-12-31 23:59:00.027 CST [23391] 语句:  select * from(select * from log_entopenplatformpush t where t.logtype in('失败','异常') and (t.nexttime is null or t.nexttime<sysdate) and cast(t.excount as numeric)<cast(t.maxcount as numeric) order by t.nexttime) foo limit $1 offset 0

[root@localhost log]# tail -200f postgresql-2023-12-01_000000.log
...
cp: 无法获取"pg_wal/000000010000000000000002" 的文件状态(stat): 没有那个文件或目录
2023-12-01 16:14:50.314 CST [1686] 日志:  归档命令执行失败,退出代码为 1
2023-12-01 16:14:50.314 CST [1686] 详细信息:  执行失败的归档命令是: cp pg_wal/000000010000000000000002 /dsg3/postgres/pg10_data/pg_archive/000000010000000000000002
2023-12-01 16:14:50.314 CST [1686] 警告:  archiving write-ahead log file "000000010000000000000002" failed too many times, will try again later
cp: 无法获取"pg_wal/000000010000000000000002" 的文件状态(stat): 没有那个文件或目录
2023-12-01 16:15:50.387 CST [1686] 日志:  归档命令执行失败,退出代码为 1
2023-12-01 16:15:50.387 CST [1686] 详细信息:  执行失败的归档命令是: cp pg_wal/000000010000000000000002 /dsg3/postgres/pg10_data/pg_archive/000000010000000000000002
cp: 无法获取"pg_wal/000000010000000000000002" 的文件状态(stat): 没有那个文件或目录
2023-12-01 16:15:51.397 CST [1686] 日志:  归档命令执行失败,退出代码为 1
2023-12-01 16:15:51.397 CST [1686] 详细信息:  执行失败的归档命令是: cp pg_wal/000000010000000000000002 /dsg3/postgres/pg10_data/pg_archive/000000010000000000000002
...

--查找000000010000000000000001文件,发现pg_wal目录和整个服务器上都没有该wal文件
[root@localhost dsg2]# ls -l /dsg3/postgres/pg10_data/pg_wal/000000010000000000000001
[root@localhost dsg2]# find /dsg2 -name 000000010000000000000001
[root@localhost dsg2]# find /dsg3 -name 000000010000000000000001
[root@localhost dsg2]# find / -name 000000010000000000000001

不晓得是被删除还是其他什么原因,反正是没有了000000010000000000000001文件

--查当前最新检查点,最新检查点之前的wal文件均可以删除
-bash-4.2$ /usr/pgsql-10/bin/pg_controldata -D /dsg3/postgres/pg10_data/
pg_control 版本:                      1002
Catalog 版本:                         201707211
数据库系统标识符:                     7145756055167210409
数据库簇状态:                         在运行中
pg_control 最后修改:                  2023年12月01日 星期五 14时06分38秒
最新检查点位置:                       5C/CC000098
优先检查点位置:                       5C/CB000098
最新检查点的 REDO 位置:               5C/CC000060
最新检查点的重做日志文件: 000000010000005C000000CC
最新检查点的 TimeLineID:              1
最新检查点的PrevTimeLineID: 1
最新检查点的full_page_writes: 开启
最新检查点的NextXID:          0:18857199
最新检查点的 NextOID:                 5631206
最新检查点的NextMultiXactId: 1
最新检查点的NextMultiOffsetD: 0
最新检查点的oldestXID:            548
最新检查点的oldestXID所在的数据库:1
最新检查点的oldestActiveXID:  18857199
最新检查点的oldestMultiXid:  1
最新检查点的oldestMulti所在的数据库:1
最新检查点的oldestCommitTsXid:0
最新检查点的newestCommitTsXid:0
最新检查点的时间:                     2023年12月01日 星期五 14时06分38秒
不带日志的关系: 0/1使用虚假的LSN计数器
最小恢复结束位置: 0/0
最小恢复结束位置时间表: 0
开始进行备份的点位置:                       0/0
备份的最终位置:                  0/0
需要终止备份的记录:        否
wal_level设置:                    logical
wal_log_hints设置:        关闭
max_connections设置:   1000
max_worker_processes设置:   8
max_prepared_xacts设置:   0
max_locks_per_xact设置:   64
track_commit_timestamp设置:        关闭
最大数据校准:     8
数据库块大小:                         8192
大关系的每段块数:                     131072
WAL的块大小:    8192
每一个 WAL 段字节数:                  16777216
标识符的最大长度:                     64
在索引中可允许使用最大的列数:    32
TOAST区块的最大长度:                1996
大对象区块的大小:         2048
日期/时间 类型存储:                   64位整数
正在传递Flloat4类型的参数:           由值
正在传递Flloat8类型的参数:                   由值
数据页校验和版本:  0
Mock authentication nonce:            7983f98bfb21a629b6495115d880af674404270a694d663e4e31603c1cb19c41

--查当前wal_lsn
postgres=# select pg_current_wal_lsn();
 pg_current_wal_lsn 
--------------------
 5C/CC000098
(1 row)

--查当前wal_lsn对应的wal文件
postgres=# select pg_walfile_name(pg_current_wal_lsn());
     pg_walfile_name      
--------------------------
 000000010000005C000000CC
(1 row)

--检查$PGDATA/pg_wal/archive_status/目录下文件
[postgres@pgmaster ~]$ cd /server/data/pgdb/data/pg_wal/archive_status/
[postgres@pgmaster archive_status]$ ls -l *.ready
存在大量的.ready结尾的文件,ready说明是需要归档但是没归档的,done是归档完成了的

尝试解决办法

1.关闭归档开启归档(未解决)

关闭归档–>重启库–>开启归档–>重启库,依然报如下错误:

--关闭归档,更改postgresql.conf,注释掉以下参数
-bash-4.2$ vi /dsg3/postgres/pg10_data/postgresql.conf
#archive_mode = on
#archive_command = 'cp %p /dsg3/postgres/pg10_data/pg_archive/%f'

--重启库
/usr/pgsql-10/bin/pg_ctl stop -D /dsg3/postgres/pg10_data/
/usr/pgsql-10/bin/pg_ctl start -D /dsg3/postgres/pg10_data/

--开启归档,更改postgresql.conf,解除以下参数的注释
-bash-4.2$ vi /dsg3/postgres/pg10_data/postgresql.conf
archive_mode = on
archive_command = 'cp %p /dsg3/postgres/pg10_data/pg_archive/%f'

--重启库
/usr/pgsql-10/bin/pg_ctl stop -D /dsg3/postgres/pg10_data/
/usr/pgsql-10/bin/pg_ctl start -D /dsg3/postgres/pg10_data/

--查看数据库运行状态时发现归档失败
[root@localhost log]# ps -ef | grep postgres
postgres  1099     1  0 11月14 ?      00:00:05 /usr/pgsql-11/bin/postmaster -D /dsg3/postgres/pg115_data
postgres  1103     1  0 11月14 ?      00:00:15 /usr/pgsql-10/bin/postmaster -D /dsg3/postgres/pg10_data/
postgres  1532  1099  0 11月14 ?      00:00:00 postgres: logger   
postgres  1595  1103  0 11月14 ?      00:00:16 postgres: logger process   
postgres  1674  1099  0 11月14 ?      00:00:00 postgres: checkpointer   
postgres  1675  1099  0 11月14 ?      00:00:18 postgres: background writer   
postgres  1676  1099  0 11月14 ?      00:00:18 postgres: walwriter   
postgres  1677  1099  0 11月14 ?      00:00:12 postgres: autovacuum launcher   
postgres  1678  1099  0 11月14 ?      00:00:39 postgres: archiver   
postgres  1679  1099  0 11月14 ?      00:00:14 postgres: stats collector   
postgres  1680  1099  0 11月14 ?      00:00:01 postgres: logical replication launcher   
postgres  1682  1103  0 11月14 ?      00:00:00 postgres: checkpointer process   
postgres  1683  1103  0 11月14 ?      00:00:19 postgres: writer process   
postgres  1684  1103  0 11月14 ?      00:00:18 postgres: wal writer process   
postgres  1685  1103  0 11月14 ?      00:00:13 postgres: autovacuum launcher process   
postgres  1686  1103  0 11月14 ?      00:05:19 postgres: archiver process   failed on 000000010000000000000001
postgres  1687  1103  0 11月14 ?      00:00:28 postgres: stats collector process   
postgres  1688  1103  0 11月14 ?      00:00:01 postgres: bgworker: logical replication launcher   
root      8779  8736  0 15:01 pts/0    00:00:00 su - postgres

2.pg_archivecleanup清理过期wal文件(未解决)

--查看pg_wal下面得文件
-bash-4.2$ ls -l /dsg3/postgres/pg10_data/pg_wal/
总用量 394736
-rw------- 1 postgres postgres 16777216 4月  12 2023 000000010000005C000000BC
-rw------- 1 postgres postgres 16777216 4月  12 2023 000000010000005C000000BD
-rw------- 1 postgres postgres 16777216 4月  12 2023 000000010000005C000000BE
-rw------- 1 postgres postgres 16777216 4月  12 2023 000000010000005C000000BF
-rw------- 1 postgres postgres 16777216 4月  12 2023 000000010000005C000000C0
-rw------- 1 postgres postgres 16777216 4月  12 2023 000000010000005C000000C1
-rw------- 1 postgres postgres 16777216 4月  12 2023 000000010000005C000000C2
-rw------- 1 postgres postgres 16777216 4月  12 2023 000000010000005C000000C3
-rw------- 1 postgres postgres 16777216 4月  12 2023 000000010000005C000000C4
-rw------- 1 postgres postgres 16777216 4月  12 2023 000000010000005C000000C5
-rw------- 1 postgres postgres 16777216 4月  12 2023 000000010000005C000000C6
-rw------- 1 postgres postgres 16777216 4月  12 2023 000000010000005C000000C7
-rw------- 1 postgres postgres 16777216 4月  12 2023 000000010000005C000000C8
-rw------- 1 postgres postgres 16777216 4月  12 2023 000000010000005C000000C9
-rw------- 1 postgres postgres 16777216 12月  1 14:00 000000010000005C000000CA
-rw------- 1 postgres postgres 16777216 12月  1 14:04 000000010000005C000000CB
-rw------- 1 postgres postgres 16777216 12月  1 16:17 000000010000005C000000CC
-rw------- 1 postgres postgres 16777216 12月  1 16:26 000000010000005C000000CD
-rw------- 1 postgres postgres 16777216 12月  1 16:39 000000010000005C000000CE

--查当前wal_lsn
postgres=# select pg_current_wal_lsn();
 pg_current_wal_lsn 
--------------------
 5C/CC000098
(1 row)

--查当前wal_lsn对应的wal文件
postgres=# select pg_walfile_name(pg_current_wal_lsn());
     pg_walfile_name      
--------------------------
 000000010000005C000000CC
(1 row)

--清除检查点之前的wal文件
# 000000010000005C000000CC  之前的pg_wal文件可以删除 (pg10以前的叫做pg_xlog)
[postgres@Server ~]$ pg_archivecleanup -d $PGDATA/pg_wal 000000010000005C000000C2
pg_archivecleanup: keep WAL file "/server/data/pgdb/data/pg_wal/000000010000005C000000C2" and later  
pg_archivecleanup: removing file "/server/data/pgdb/data/pg_wal/000000010000005C000000C1" 

虽然是测试环境还是保留了部分wal文件,未从当前wal_lsn000000010000005C000000CC清除,而是选择清除
000000010000005C000000C2之前的文件

--手动切日志
-bash-4.2$ /usr/pgsql-10/bin/psql -p 54310
psql (10.22)
输入 "help" 来获取帮助信息.

postgres=# select pg_switch_wal();
 pg_switch_wal 
---------------
 5C/D10000E8
(1 行记录)

--查看数据库运行状态时发现归档失败
[root@localhost log]# ps -ef | grep postgres
postgres  1099     1  0 11月14 ?      00:00:05 /usr/pgsql-11/bin/postmaster -D /dsg3/postgres/pg115_data
postgres  1103     1  0 11月14 ?      00:00:15 /usr/pgsql-10/bin/postmaster -D /dsg3/postgres/pg10_data/
postgres  1532  1099  0 11月14 ?      00:00:00 postgres: logger   
postgres  1595  1103  0 11月14 ?      00:00:16 postgres: logger process   
postgres  1674  1099  0 11月14 ?      00:00:00 postgres: checkpointer   
postgres  1675  1099  0 11月14 ?      00:00:18 postgres: background writer   
postgres  1676  1099  0 11月14 ?      00:00:18 postgres: walwriter   
postgres  1677  1099  0 11月14 ?      00:00:12 postgres: autovacuum launcher   
postgres  1678  1099  0 11月14 ?      00:00:39 postgres: archiver   
postgres  1679  1099  0 11月14 ?      00:00:14 postgres: stats collector   
postgres  1680  1099  0 11月14 ?      00:00:01 postgres: logical replication launcher   
postgres  1682  1103  0 11月14 ?      00:00:00 postgres: checkpointer process   
postgres  1683  1103  0 11月14 ?      00:00:19 postgres: writer process   
postgres  1684  1103  0 11月14 ?      00:00:18 postgres: wal writer process   
postgres  1685  1103  0 11月14 ?      00:00:13 postgres: autovacuum launcher process   
postgres  1686  1103  0 11月14 ?      00:05:19 postgres: archiver process   failed on 000000010000000000000001
postgres  1687  1103  0 11月14 ?      00:00:28 postgres: stats collector process   
postgres  1688  1103  0 11月14 ?      00:00:01 postgres: bgworker: logical replication launcher   
root      8779  8736  0 15:01 pts/0    00:00:00 su - postgres

3.$PG_DATA/pg_wal下创建空文件(未解决)

--关闭数据库
/usr/pgsql-10/bin/pg_ctl stop -D /dsg3/postgres/pg10_data/

--创建和报错同名的wal_lsn文件
cd /dsg3/postgres/pg10_data/pg_wal
touch 000000010000000000000001

--启动数据库
/usr/pgsql-10/bin/pg_ctl start -D /dsg3/postgres/pg10_data/

--查看数据库运行状态时发现归档失败
[root@localhost log]# ps -ef | grep postgres
postgres  1099     1  0 11月14 ?      00:00:05 /usr/pgsql-11/bin/postmaster -D /dsg3/postgres/pg115_data
postgres  1103     1  0 11月14 ?      00:00:15 /usr/pgsql-10/bin/postmaster -D /dsg3/postgres/pg10_data/
postgres  1532  1099  0 11月14 ?      00:00:00 postgres: logger   
postgres  1595  1103  0 11月14 ?      00:00:16 postgres: logger process   
postgres  1674  1099  0 11月14 ?      00:00:00 postgres: checkpointer   
postgres  1675  1099  0 11月14 ?      00:00:18 postgres: background writer   
postgres  1676  1099  0 11月14 ?      00:00:18 postgres: walwriter   
postgres  1677  1099  0 11月14 ?      00:00:12 postgres: autovacuum launcher   
postgres  1678  1099  0 11月14 ?      00:00:39 postgres: archiver   
postgres  1679  1099  0 11月14 ?      00:00:14 postgres: stats collector   
postgres  1680  1099  0 11月14 ?      00:00:01 postgres: logical replication launcher   
postgres  1682  1103  0 11月14 ?      00:00:00 postgres: checkpointer process   
postgres  1683  1103  0 11月14 ?      00:00:19 postgres: writer process   
postgres  1684  1103  0 11月14 ?      00:00:18 postgres: wal writer process   
postgres  1685  1103  0 11月14 ?      00:00:13 postgres: autovacuum launcher process   
postgres  1686  1103  0 11月14 ?      00:05:19 postgres: archiver process   failed on 000000010000000000000001
postgres  1687  1103  0 11月14 ?      00:00:28 postgres: stats collector process   
postgres  1688  1103  0 11月14 ?      00:00:01 postgres: bgworker: logical replication launcher   
root      8779  8736  0 15:01 pts/0    00:00:00 su - postgres

最终解决办法

--关闭数据库
/usr/pgsql-10/bin/pg_ctl stop -D /dsg3/postgres/pg10_data/

--备份data目录(如果磁盘空间允许务必备份以防万一)
cd /dsg3/postgres/
cp -r pg10_data pg10_data_bak_20231201

--更改postgresql.conf中以下归档参数
-bash-4.2$ vi /dsg3/postgres/pg10_data/postgresql.conf
#archive_mode = on
archive_command = 'ls -l /dsg3/postgres/pg10_data/pg_archive/'

--重启库
/usr/pgsql-10/bin/pg_ctl stop -D /dsg3/postgres/pg10_data/
/usr/pgsql-10/bin/pg_ctl start -D /dsg3/postgres/pg10_data/

--查看数据库状态,
-bash-4.2$ ps -ef | grep postgres
postgres  1099     1  0 11月14 ?      00:00:06 /usr/pgsql-11/bin/postmaster -D /dsg3/postgres/pg115_data
postgres  1532  1099  0 11月14 ?      00:00:00 postgres: logger   
postgres  1674  1099  0 11月14 ?      00:00:00 postgres: checkpointer   
postgres  1675  1099  0 11月14 ?      00:00:18 postgres: background writer   
postgres  1676  1099  0 11月14 ?      00:00:18 postgres: walwriter   
postgres  1677  1099  0 11月14 ?      00:00:12 postgres: autovacuum launcher   
postgres  1678  1099  0 11月14 ?      00:00:39 postgres: archiver   
postgres  1679  1099  0 11月14 ?      00:00:14 postgres: stats collector   
postgres  1680  1099  0 11月14 ?      00:00:01 postgres: logical replication launcher   
root     12967 12922  0 15:56 pts/0    00:00:00 su - postgres
postgres 12968 12967  0 15:56 pts/0    00:00:00 -bash
root     13392 13350  0 16:00 pts/1    00:00:00 su - postgres
postgres 13393 13392  0 16:00 pts/1    00:00:00 -bash
root     15935 15815  0 16:34 pts/2    00:00:00 su - postgres
postgres 15936 15935  0 16:34 pts/2    00:00:00 -bash
postgres 17190     1  3 16:49 pts/0    00:00:00 /usr/pgsql-10/bin/postgres -D /dsg3/postgres/pg10_data
postgres 17191 17190  0 16:49 ?        00:00:00 postgres: logger process   
postgres 17193 17190  0 16:49 ?        00:00:00 postgres: checkpointer process   
postgres 17194 17190  0 16:49 ?        00:00:00 postgres: writer process   
postgres 17195 17190  0 16:49 ?        00:00:00 postgres: wal writer process   
postgres 17196 17190  0 16:49 ?        00:00:00 postgres: autovacuum launcher process   
postgres 17197 17190 71 16:49 ?        00:00:04 postgres: archiver process   last was 000000010000000100000074
postgres 17198 17190  0 16:49 ?        00:00:00 postgres: stats collector process   
postgres 17199 17190  0 16:49 ?        00:00:00 postgres: bgworker: logical replication launcher   
postgres 17584 12968  0 16:49 pts/0    00:00:00 ps -ef
postgres 17585 12968  0 16:49 pts/0    00:00:00 grep --color=auto postgres

多次执行ps -ef | grep postgres会发现
archiver process   last was 000000010000000100000074这个地方会不断地变化,是正常现象,不要慌
等不变为止

--检查$PGDATA/pg_wal/archive_status/目录下文件
[postgres@pgmaster ~]$ cd /server/data/pgdb/data/pg_wal/archive_status/
[postgres@pgmaster archive_status]$ ls -l *.ready
[postgres@pgmaster archive_status]$ ls -l *.done
原来的.ready结尾的文件都变成了.done结尾的文件

补充:.ready结尾的文件说明是需要归档但是没归档的,done是归档完成了的

--开启归档,更改postgresql.conf,修改以下归档参数
-bash-4.2$ vi /dsg3/postgres/pg10_data/postgresql.conf
archive_mode = on
archive_command = 'cp %p /dsg3/postgres/pg10_data/pg_archive/%f'

--重启库
/usr/pgsql-10/bin/pg_ctl stop -D /dsg3/postgres/pg10_data/
/usr/pgsql-10/bin/pg_ctl start -D /dsg3/postgres/pg10_data/

--查看数据库状态
-bash-4.2$ ps -ef | grep postgres
postgres  1099     1  0 11月14 ?      00:00:06 /usr/pgsql-11/bin/postmaster -D /dsg3/postgres/pg115_data
postgres  1532  1099  0 11月14 ?      00:00:00 postgres: logger   
postgres  1674  1099  0 11月14 ?      00:00:00 postgres: checkpointer   
postgres  1675  1099  0 11月14 ?      00:00:18 postgres: background writer   
postgres  1676  1099  0 11月14 ?      00:00:18 postgres: walwriter   
postgres  1677  1099  0 11月14 ?      00:00:14 postgres: autovacuum launcher   
postgres  1678  1099  0 11月14 ?      00:00:39 postgres: archiver   
postgres  1679  1099  0 11月14 ?      00:00:15 postgres: stats collector   
postgres  1680  1099  0 11月14 ?      00:00:01 postgres: logical replication launcher   
root      9783 16354  0 17:00 pts/3    00:00:00 su - postgres
postgres  9784  9783  0 17:00 pts/3    00:00:00 -bash
root     10888 10844  0 17:14 pts/4    00:00:00 su - postgres
postgres 10889 10888  0 17:14 pts/4    00:00:00 -bash
root     12967 12922  0 15:56 pts/0    00:00:00 su - postgres
postgres 12968 12967  0 15:56 pts/0    00:00:00 -bash
root     13392 13350  0 16:00 pts/1    00:00:00 su - postgres
postgres 13393 13392  0 16:00 pts/1    00:00:00 -bash
postgres 15098     1  0 18:16 pts/4    00:00:00 /usr/pgsql-10/bin/postgres -D /dsg3/postgres/pg10_data
postgres 15099 15098  0 18:16 ?        00:00:00 postgres: logger process   
postgres 15101 15098  0 18:16 ?        00:00:00 postgres: checkpointer process   
postgres 15102 15098  0 18:16 ?        00:00:00 postgres: writer process   
postgres 15103 15098  0 18:16 ?        00:00:00 postgres: wal writer process   
postgres 15104 15098  0 18:16 ?        00:00:00 postgres: autovacuum launcher process   
postgres 15105 15098  0 18:16 ?        00:00:00 postgres: archiver process   last was 000000010000005C000000D1
postgres 15106 15098  0 18:16 ?        00:00:00 postgres: stats collector process   
postgres 15107 15098  0 18:16 ?        00:00:00 postgres: bgworker: logical replication launcher   
postgres 15182 10889  0 18:17 pts/4    00:00:00 ps -ef
postgres 15183 10889  0 18:17 pts/4    00:00:00 grep --color=auto postgres
root     15935 15815  0 16:34 pts/2    00:00:00 su - postgres
postgres 15936 15935  0 16:34 pts/2    00:00:00 -bash

问题最终解决,虽说是测试库,但是也吓得不轻,157G的数据。不管测试还是生产环境还是得慎重,毕竟数据无法重现。

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/208912.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

Find My文件袋|苹果Find My技术与文件袋结合,智能防丢,全球定位

文件袋是指用于对自己的私人物品或身份文件保管等、资料袋、白卷宗。款式分为扣式和文件套式。文件袋通常具有足够的容量&#xff0c;可以容纳大量文件。当需要长期存档文件时&#xff0c;文件袋是一个方便的选择&#xff0c;可以将文件整理好放入文件袋中&#xff0c;便于存放…

[github全教程]github版本控制最全教学------- 大厂找工作面试必备!

作者&#xff1a;20岁爱吃必胜客&#xff08;坤制作人&#xff09;&#xff0c;近十年开发经验, 跨域学习者&#xff0c;目前于新西兰奥克兰大学攻读IT硕士学位。荣誉&#xff1a;阿里云博客专家认证、腾讯开发者社区优质创作者&#xff0c;在CTF省赛校赛多次取得好成绩。跨领域…

【笔记】2023最新Python安装教程(Windows 11)

&#x1f388;欢迎加群交流&#xff08;备注&#xff1a;csdn&#xff09;&#x1f388; ✨✨✨https://ling71.cn/hmf.jpg✨✨✨ &#x1f913;前言 作为一名经验丰富的CV工程师&#xff0c;今天我将带大家在全新的Windows 11系统上安装Python。无论你是编程新手还是老手&…

C语言错误处理之 “<errno.h>与<error.h>”

目录 前言 错误号处理方式 errno.h头文件 error.h头文件 参数解释&#xff1a; 关于的”__attribute__“解释&#xff1a; 关于“属性”的解释&#xff1a; 实例一&#xff1a; 实例二&#xff1a; error.h与errno.h的区别 补充内容&#xff1a; 前言 在开始学习…

Redis——某马点评day01——短信登录

项目介绍 导入黑马点评项目 项目架构 基于Session实现登录 基本流程 实现发送短信验证码功能 controller层中 /*** 发送手机验证码*/PostMapping("code")public Result sendCode(RequestParam("phone") String phone, HttpSession session) {// 发送短信…

支持Upsert、Kafka Connector、集成Airbyte,Milvus助力高效数据流处理

Milvus 已支持 Upsert、 Kafka Connector、Airbyte&#xff01; 在上周的文章中《登陆 Azure、发布新版本……Zilliz 昨夜今晨发生了什么&#xff1f;》&#xff0c;我们已经透露过 Milvus&#xff08;Zilliz Cloud&#xff09;为提高数据流处理效率&#xff0c; 先后支持了 Up…

JOSEF约瑟 DY-34 型电压继电器,15-30V 柜内安装,板前接线

DY-30系列电压继电器 DY-32电压继电器&#xff1b; DY-36电压继电器&#xff1b; DY-33电压继电器&#xff1b; DY-37电压继电器&#xff1b; DY-34电压继电器&#xff1b; DY-38电压继电器&#xff1b; DY-31电压继电器&#xff1b; DY-35电压继电器&#xff1b; DY-32/60C电压…

HarmonyOS——解决本地模拟器无法选择设备的问题

在使用deveco studio进行鸿蒙开发的时候&#xff0c;可能会遇到本地模拟器已经启动了&#xff0c;但是仍然无法选择本地模拟器中的设备&#xff0c;尤其在MAC环境中尤为常见。 解决办法&#xff1a; 先打开IDE启动本地模拟器&#xff0c;等模拟器启动后&#xff0c;退出IDE重新…

蓝桥杯每日一题2023.12.1

题目描述 蓝桥杯大赛历届真题 - C 语言 B 组 - 蓝桥云课 (lanqiao.cn) 题目分析 对于此题目而言思路较为重要&#xff0c;实际可以转化为求两个数字对应的操作&#xff0c;输出最前面的数字即可 #include<bits/stdc.h> using namespace std; int main() {for(int i 1…

ARM64版本的chrome浏览器安装

这一快比较玄学&#xff0c;花个半个小时左右才能安装好&#xff0c;也不知道是个什么情况。 sudo snap install chromium只需要以上这个命令&#xff0c;当然&#xff0c;也可以自己去找安装包进行安装&#xff0c;但是测试后发现并没有那么好装&#xff0c;主要是两个部分 一…

第九节HarmonyOS 常用基础组件-Text

一、组件介绍 组件&#xff08;Component&#xff09;是界面搭建与显示的最小单位&#xff0c;HarmonyOS ArkUI声名式为开发者提供了丰富多样的UI组件&#xff0c;我们可以使用这些组件轻松的编写出更加丰富、漂亮的界面。 组件根据功能可以分为以下五大类&#xff1a;基础组件…

Unity中Shader指令优化

文章目录 前言一、解析一下不同运算所需的指令数1、常数基本运算2、变量基本运算3、条件语句、循环 和 函数 前言 上一篇文章中&#xff0c;我们解析了Shader解析后的代码。我们在这篇文章中来看怎么实现Shader指令优化 Unity中Shader指令优化&#xff08;编译后指令解析&…

C语言之联合和枚举

C语言之联合和枚举 文章目录 C语言之联合和枚举1. 联合体1.1 联合体的声明1.2 联合体的特点1.3 结构体和联合体对比1.4 联合体大小的计算1.5 联合体小练习 2. 枚举2.1 枚举类型的声明2.2 枚举类型的优点2.3 枚举类型的使用 1. 联合体 1.1 联合体的声明 像结构体⼀样&#xff…

AI PC行业深度报告:格局演变、发展趋势、产业链及相关公司深度梳理

今天分享的是AI PC系列深度研究报告&#xff1a;《AI PC行业深度报告&#xff1a;格局演变、发展趋势、产业链及相关公司深度梳理》。 &#xff08;报告出品方&#xff1a;慧博智能投研&#xff09; 报告共计&#xff1a;21页 一、AI PC的产生 1、端侧 AI 是 AI 发展下一阶段…

【ASP.NET CORE】数据迁移 codefirst

已经写好实体类&#xff0c;使用add-migration生成数据迁移语句&#xff0c;注意如果项目中有多个dbcontext需要使用 -context 名称&#xff0c;指定下需要使用的dbcontext add-Migration Address -context mvcsqlcontext运行后会生成两个文件 2. 使用Update-Database语句更…

Postman如何导入和导出接口文件

本文介绍2种导出和导入的操作方法&#xff1a;一种是分享链接&#xff0c;导入链接的方式&#xff08;需要登录&#xff09;&#xff1b;另一种是导出json文件&#xff0c;再次导入。下面将详细介绍。 由于第一种分享链接&#xff0c;导入链接的方式需要登录&#xff0c;所以推…

Nacos 架构原理

基本架构及概念​ 服务 (Service)​ 服务是指一个或一组软件功能&#xff08;例如特定信息的检索或一组操作的执行&#xff09;&#xff0c;其目的是不同的客户端可以为不同的目的重用&#xff08;例如通过跨进程的网络调用&#xff09;。Nacos 支持主流的服务生态&#xff0c…

【每日一题】找出叠涂元素

文章目录 Tag题目来源题目解读解题思路方法一&#xff1a;哈希表 写在最后 Tag 【哈希表】【数组】【2023-12-01】 题目来源 2661. 找出叠涂元素 题目解读 从左往右遍历 arr 给矩阵 mat 上色&#xff0c;在上色的过程中矩阵的某一行或者某一列的全部被上色了&#xff0c;返回…

Git的介绍和下载安装

Git的介绍和下载安装 概述 Git是一个分布式版本控制工具, 通常用来管理项目中的源代码文件(Java类、xml文件、html页面等)进行管理,在软件开发过程中被广泛使用 Git可以记录文件修改的历史记录并形成备份从而实现代码回溯, 版本切换, 多人协作, 远程备份的功能Git具有廉价的…

leecode 【二】

相交链表 给你两个单链表的头节点 headA 和 headB &#xff0c;请你找出并返回两个单链表相交的起始节点。如果两个链表不存在相交节点&#xff0c;返回 null 。 图示两个链表在节点 c1 开始相交&#xff1a; 题目数据 保证 整个链式结构中不存在环。 注意&#xff0c;函数返…
最新文章