postgresql Postgres 12恢复

qyzbxkaa  于 2023-02-22  发布在  PostgreSQL
关注(0)|答案(1)|浏览(190)

我无法恢复我的Postgres服务器12。我有群集,2个服务器PSQL12s01、PSQL12s02。在arch_log复制之间。数据库大小约为45 GB + 400 GB arch_log。我在从服务器上运行脚本

D=$(date +%Y%m%d%H%M)
sudo -u postgres -H bash -c "pg_basebackup -l db_TECH_$D -D - -Ft -X fetch | bzip2 > /var/lib/postgresql/BKP/db_TECH_$D.tar.bz2"

文件在REST服务器上解压缩并运行docker container

docker run -d \
    --name tc12s02-postgres \
    -e POSTGRES_PASSWORD=postgres \
    -e PGDATA=/var/lib/postgresql/data/pgdata \
    -p 15432:5432 \
    -v /var/lib/postgresql/BKP:/var/lib/postgresql/data/pgdata \
    -v /var/lib/postgresql/SMB/arch_log:/var/lib/postgresql/data/pgdata/arch_log \
    postgres:12

当我的启动容器日期为2022年10月17日时

restore_command = 'cp /var/lib/postgresql/data/pgdata/arch_log/%f %p'
recovery_target_time = '2023-02-18 20:00:00'
recovery_target_action = 'promote'

touch recovery.signal

我不知道为什么我不想访问arch_log中的数据。也许我必须为不在从机上的主机执行pg_basebackup。我不想给主机增加额外的负担

l0oc07j2

l0oc07j21#

2023-02-21 11:08:51.691 UTC [1] LOG:  starting PostgreSQL 12.13 (Debian 12.13-1.pgdg110+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 10.2.1-6) 10.2.1 20210110, 64-bit
2023-02-21 11:08:51.692 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2023-02-21 11:08:51.692 UTC [1] LOG:  listening on IPv6 address "::", port 5432
2023-02-21 11:08:51.784 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2023-02-21 11:08:53.500 UTC [45] LOG:  database system was shut down at 2023-02-21 11:07:33 UTC
cp: cannot stat '/var/lib/postgresql/data/pgdata/arch_log/00000002.history': No such file or directory
2023-02-21 11:08:53.580 UTC [45] LOG:  starting point-in-time recovery to 2023-02-18 20:00:00+00
cp: cannot stat '/var/lib/postgresql/data/pgdata/arch_log/000000010000006A0000001F': No such file or directory
2023-02-21 11:08:53.781 UTC [45] LOG:  consistent recovery state reached at 6A/1F216420
2023-02-21 11:08:53.782 UTC [1] LOG:  database system is ready to accept read only connections
2023-02-21 11:08:53.783 UTC [45] LOG:  invalid record length at 6A/1F216420: wanted 24, got 0
2023-02-21 11:08:53.783 UTC [45] LOG:  redo is not required
cp: cannot stat '/var/lib/postgresql/data/pgdata/arch_log/000000010000006A0000001F': No such file or directory
cp: cannot stat '/var/lib/postgresql/data/pgdata/arch_log/00000002.history': No such file or directory
2023-02-21 11:08:53.993 UTC [45] LOG:  selected new timeline ID: 2
2023-02-21 11:08:56.437 UTC [45] LOG:  archive recovery complete
cp: cannot stat '/var/lib/postgresql/data/pgdata/arch_log/00000001.history': No such file or directory
2023-02-21 11:08:58.496 UTC [1] LOG:  database system is ready to accept connections
2023-02-21 11:27:09.218 UTC [104] LOG:  using stale statistics instead of current ones because stats collector is not responding

相关问题