基础备份和PITR
准备工作
postgres=# select name,setting,unit from pg_settings where category=Preset Options;
postgres=# select version();
$ pg_controldata -D /pgsql |grep wal_level
或者
cat postgresql.conf |grep wal_level
vi postgresql.conf
archive_mode = on
cat postgresql.conf |grep archive_mode
$ mkdir archive
vi postgresql.conf
archive_command = cp %p /pgsql/data/archive/%f
pg_ctl -D /pgsql/data/ reload
max_worker_processes = 16
max_wal_senders = 8
wal_keep_segments = 1024
cd /pgsql/data
mv postgresql.conf postgresql.conf.bak20220227
vi postgresql.conf
listen_addresses = *
port = 5432
superuser_reserved_connections = 20
wal_level = archive
archive_mode = on
archive_command = cp %p /pgsql/data/archive/%f
unix_socket_directories = /var/lib/postgres/
unix_socket_permissions = 0700
tcp_keepalives_idle = 60
tcp_keepalives_interval = 10
tcp_keepalives_count = 10
vacuum_cost_delay = 10
bgwriter_delay = 10ms
synchronous_commit = off
wal_writer_delay = 10ms
log_destination = csvlog
logging_collector = on
log_directory = pg_log
log_filename =postgresql-%Y-%m-%d_%H%M%S.log
log_file_mode = 0600
log_truncate_on_rotation = on
log_rotation_age = 1d
log_rotation_size = 10MB
log_timezone = PRC
datestyle = iso, mdy
timezone = PRC
default_text_search_config = pg_catalog.english
max_worker_processes = 16
max_wal_senders = 8
wal_keep_segments = 1024
基础备份
$ psql
psql.bin (10.12)
Type "help" for help.
$ cp pg_hba.conf pg_hba.conf.bak20200920
$ vi pg_hba.conf
SELECT pg_start_backup(label, true);
pg_basebackup -h ***.***.223.128 -D /pgsql/data/backup
模拟数据库恢复
$ pg_ctl -D /pgsql/data start
postgres=# select txid_current();
ERROR: cannot execute txid_current() during recovery
postgres=#
postgres=# select pg_wal_replay_resume();
pg_wal_replay_resume
----------------------
(1 row)
postgres=# select count(*) from ttt;
文章版权归作者所有,未经允许请勿转载,若此文章存在违规行为,您可以联系管理员删除。
转载请注明本文地址:https://www.ucloud.cn/yun/129592.html
摘要:作者谭峰张文升出版日期年月页数页定价元本书特色中国开源软件推进联盟分会特聘专家撰写,国内多位开源数据库专家鼎力推荐。张文升中国开源软件推进联盟分会核心成员之一。 很高兴《PostgreSQL实战》一书终于出版,本书大体上系统总结了笔者 PostgreSQL DBA 职业生涯的经验总结,本书的另一位作者张文升拥有丰富的PostgreSQL运维经验,目前就职于探探科技任首席PostgreS...
摘要:指定要用于查找的口令文件的名称。前四个字段可以是确定的字面值,也可以使用通配符匹配所有。利用环境变量引用的文件权限也要满足这个要求,否则同样会被忽略。在上,该文件被假定存储在一个安全的目录中,因此不会进行特别的权限检查。 pg_dump pg_dump 把一个数据库转储为纯文本文件或者是其它格式. 用法: pg_dump [选项]... [数据库名字] 一般选项: -f, --fi...
阅读 1346·2023-01-11 13:20
阅读 1684·2023-01-11 13:20
阅读 1132·2023-01-11 13:20
阅读 1858·2023-01-11 13:20
阅读 4100·2023-01-11 13:20
阅读 2704·2023-01-11 13:20
阅读 1385·2023-01-11 13:20
阅读 3597·2023-01-11 13:20