PostgreSQL 9.3 Have pg_basebackup --write-recovery-conf output a minimal recovery.conf

简介:
Have pg_basebackup --write-recovery-conf output a minimal recovery.conf (Zoltán B?sz?rményi, Magnus Hagander)
This simplifies setting up a standby server.

个人感觉没有太大的意义.

[测试]
-- 命令行帮助
pg93@db-172-16-3-33-> pg_basebackup --help
pg_basebackup takes a base backup of a running PostgreSQL server.

Usage:
  pg_basebackup [OPTION]...

Options controlling the output:
  -D, --pgdata=DIRECTORY receive base backup into directory
  -F, --format=p|t       output format (plain (default), tar)
  -R, --write-recovery-conf
                         write recovery.conf after backup
  -x, --xlog             include required WAL files in backup (fetch mode)
  -X, --xlog-method=fetch|stream
                         include required WAL files with specified method
  -z, --gzip             compress tar output
  -Z, --compress=0-9     compress tar output with given compression level

General options:
  -c, --checkpoint=fast|spread
                         set fast or spread checkpointing
  -l, --label=LABEL      set backup label
  -P, --progress         show progress information
  -v, --verbose          output verbose messages
  -V, --version          output version information, then exit
  -?, --help             show this help, then exit

Connection options:
  -d, --dbname=CONNSTR   connection string
  -h, --host=HOSTNAME    database server host or socket directory
  -p, --port=PORT        database server port number
  -s, --status-interval=INTERVAL
                         time between status packets sent to server (in seconds)
  -U, --username=NAME    connect as specified database user
  -w, --no-password      never prompt for password
  -W, --password         force password prompt (should happen automatically)

-- 使用pg_basebackup并使用-R选项
pg93@db-172-16-3-33-> pg_basebackup -D /pgdata/digoal/1921/data03/test -F p --write-recovery-conf 
WARNING:  skipping special file "./.s.PGSQL.1999"
NOTICE:  pg_stop_backup complete, all required WAL segments have been archived
pg93@db-172-16-3-33-> cd /pgdata/digoal/1921/data03/test/

-- 自动生成的recovery.conf文件.
pg93@db-172-16-3-33-> cat recovery.conf
standby_mode = 'on'
primary_conninfo = 'user=''postgres'' port=''1999'' sslmode=''prefer'' sslcompression=''1'' '


[参考]
1. src/bin/pg_basebackup/pg_basebackup.c
00071 /* Contents of recovery.conf to be generated */
00072 static PQExpBuffer recoveryconfcontents = NULL;
...
00680             if (basetablespace && writerecoveryconf)
00681             {
00682                 char        header[512];
00683                 int         padding;
00684 
00685                 tarCreateHeader(header, "recovery.conf", NULL,
00686                                 recoveryconfcontents->len,
00687                                 0600, 04000, 02000,
00688                                 time(NULL));
00689 
00690                 padding = ((recoveryconfcontents->len + 511) & ~511) - recoveryconfcontents->len;
00691 
00692                 WRITE_TAR_DATA(header, sizeof(header));
00693                 WRITE_TAR_DATA(recoveryconfcontents->data, recoveryconfcontents->len);
00694                 if (padding)
00695                     WRITE_TAR_DATA(zerobuf, padding);
00696             }
...
01190 /*
01191  * Write a recovery.conf file into the directory specified in basedir,
01192  * with the contents already collected in memory.
01193  */
01194 static void
01195 WriteRecoveryConf(void)
01196 {
01197     char        filename[MAXPGPATH];
01198     FILE       *cf;
01199 
01200     sprintf(filename, "%s/recovery.conf", basedir);
01201 
01202     cf = fopen(filename, "w");
01203     if (cf == NULL)
01204     {
01205         fprintf(stderr, _("%s: could not create file \"%s\": %s\n"), progname, filename, strerror(errno));
01206         disconnect_and_exit(1);
01207     }
01208 
01209     if (fwrite(recoveryconfcontents->data, recoveryconfcontents->len, 1, cf) != 1)
01210     {
01211         fprintf(stderr,
01212                 _("%s: could not write to file \"%s\": %s\n"),
01213                 progname, filename, strerror(errno));
01214         disconnect_and_exit(1);
01215     }
01216 
01217     fclose(cf);
01218 }

相关实践学习
使用PolarDB和ECS搭建门户网站
本场景主要介绍如何基于PolarDB和ECS实现搭建门户网站。
阿里云数据库产品家族及特性
阿里云智能数据库产品团队一直致力于不断健全产品体系,提升产品性能,打磨产品功能,从而帮助客户实现更加极致的弹性能力、具备更强的扩展能力、并利用云设施进一步降低企业成本。以云原生+分布式为核心技术抓手,打造以自研的在线事务型(OLTP)数据库Polar DB和在线分析型(OLAP)数据库Analytic DB为代表的新一代企业级云原生数据库产品体系, 结合NoSQL数据库、数据库生态工具、云原生智能化数据库管控平台,为阿里巴巴经济体以及各个行业的企业客户和开发者提供从公共云到混合云再到私有云的完整解决方案,提供基于云基础设施进行数据从处理、到存储、再到计算与分析的一体化解决方案。本节课带你了解阿里云数据库产品家族及特性。
目录
相关文章
|
弹性计算 网络协议 容灾
PostgreSQL 时间点恢复(PITR)在异步流复制主从模式下,如何避免主备切换后PITR恢复(备库、容灾节点、只读节点)走错时间线(timeline , history , partial , restore_command , recovery.conf)
标签 PostgreSQL , 恢复 , 时间点恢复 , PITR , restore_command , recovery.conf , partial , history , 任意时间点恢复 , timeline , 时间线 背景 政治正确非常重要,对于数据库来说亦如此,一个基于流复制的HA架构的集群,如果还有一堆只读节点,当HA集群发生了主备切换后,这些只读节点能否与新的主节点保持
2171 0
|
关系型数据库 数据库 PostgreSQL
PostgreSQL 12: Recovery.conf 文件参数合并到 postgresql.conf
PostgreSQL 12 的一个重要变化是 recovery.conf 配置文件中的参数合并到 postgresql.conf,recovery.conf 不再使用,我们看看手册的说明,如下: 发行说明 Move recovery.
5260 0
LXJ
|
关系型数据库 Shell PostgreSQL
PostgreSQL recovery.conf恢复配置
PostgreSQL recovery.conf恢复配置
LXJ
750 0
|
Web App开发 关系型数据库 数据库
PostgreSQL recovery.conf 配置文件整合到 postgresql.conf
标签 PostgreSQL , recovery.conf , postgresql.conf 背景 PostgreSQL 12版本以前,配置PostgreSQL数据库恢复、流复制STANDBY,都需要配置recovery.conf,如果要修改配置,需要重启数据库。
3436 0
|
10月前
|
存储 关系型数据库 测试技术
拯救海量数据:PostgreSQL分区表性能优化实战手册(附压测对比)
本文深入解析PostgreSQL分区表的核心原理与优化策略,涵盖性能痛点、实战案例及压测对比。首先阐述分区表作为继承表+路由规则的逻辑封装,分析分区裁剪失效、全局索引膨胀和VACUUM堆积三大性能杀手,并通过电商订单表崩溃事件说明旧分区维护的重要性。接着提出四维设计法优化分区策略,包括时间范围分区黄金法则与自动化维护体系。同时对比局部索引与全局索引性能,展示后者在特定场景下的优势。进一步探讨并行查询优化、冷热数据分层存储及故障复盘,解决分区锁竞争问题。
1351 2
|
关系型数据库 分布式数据库 数据库
|
关系型数据库 分布式数据库 PolarDB
《阿里云产品手册2022-2023 版》——PolarDB for PostgreSQL
《阿里云产品手册2022-2023 版》——PolarDB for PostgreSQL
615 0
|
存储 缓存 关系型数据库
|
存储 SQL 并行计算
PolarDB for PostgreSQL 开源必读手册-开源PolarDB for PostgreSQL架构介绍(中)
PolarDB for PostgreSQL 开源必读手册-开源PolarDB for PostgreSQL架构介绍
786 0

推荐镜像

更多