PostgreSQL 9.2.3 Documentation文档

本文详细介绍了数据库中流复制的相关设置,包括发送服务器、主服务器及备用服务器的各项参数配置及其作用,帮助读者理解如何通过调整这些参数来优化流复制过程。
18.6. Replication
These settings control the behavior of the built-in streaming replication feature (see Section 25.2.5). Servers will be either a Master or a Standby server. Masters can send data, while Standby(s) are always receivers of replicated data. When cascading replication (see Section 25.2.6) is used, Standby server(s) can also be senders, as well as receivers. Parameters are mainly for Sending and Standby servers, though some parameters have meaning only on the Master server. Settings may vary across the cluster without problems if that is required.

18.6.1. Sending Server(s)

These parameters can be set on any server that is to send replication data to one or more standby servers. The master is always a sending server, so these parameters must always be set on the master. The role and meaning of these parameters does not change after a standby becomes the master.

max_wal_senders (integer)
Specifies the maximum number of concurrent connections from standby servers or streaming base backup clients (i.e., the maximum number of simultaneously running WAL sender processes). The default is zero, meaning replication is disabled. WAL sender processes count towards the total number of connections, so the parameter cannot be set higher than max_connections. This parameter can only be set at server start. wal_level must be set to archive or hot_standby to allow connections from standby servers.

wal_keep_segments (integer)
Specifies the minimum number of past log file segments kept in the pg_xlog directory, in case a standby server needs to fetch them for streaming replication. Each segment is normally 16 megabytes. If a standby server connected to the sending server falls behind by more than wal_keep_segments segments, the sending server might remove a WAL segment still needed by the standby, in which case the replication connection will be terminated. Downstream connections will also eventually fail as a result. (However, the standby server can recover by fetching the segment from archive, if WAL archiving is in use.)

This sets only the minimum number of segments retained in pg_xlog; the system might need to retain more segments for WAL archival or to recover from a checkpoint. If wal_keep_segments is zero (the default), the system doesn't keep any extra segments for standby purposes, so the number of old WAL segments available to standby servers is a function of the location of the previous checkpoint and status of WAL archiving. This parameter can only be set in the postgresql.conf file or on the server command line.

replication_timeout (integer)
Terminate replication connections that are inactive longer than the specified number of milliseconds. This is useful for the sending server to detect a standby crash or network outage. A value of zero disables the timeout mechanism. This parameter can only be set in the postgresql.conf file or on the server command line. The default value is 60 seconds.

To prevent connections from being terminated prematurely, wal_receiver_status_interval must be enabled on the standby, and its value must be less than the value of replication_timeout.

18.6.2. Master Server

These parameters can be set on the master/primary server that is to send replication data to one or more standby servers. Note that in addition to these parameters, wal_level must be set appropriately on the master server, and optionally WAL archiving can be enabled as well (see Section 18.5.3). The values of these parameters on standby servers are irrelevant, although you may wish to set them there in preparation for the possibility of a standby becoming the master.

synchronous_standby_names (string)
Specifies a comma-separated list of standby names that can support synchronous replication, as described in Section 25.2.7. At any one time there will be at most one active synchronous standby; transactions waiting for commit will be allowed to proceed after this standby server confirms receipt of their data. The synchronous standby will be the first standby named in this list that is both currently connected and streaming data in real-time (as shown by a state of streaming in the pg_stat_replication view). Other standby servers appearing later in this list represent potential synchronous standbys. If the current synchronous standby disconnects for whatever reason, it will be replaced immediately with the next-highest-priority standby. Specifying more than one standby name can allow very high availability.

The name of a standby server for this purpose is the application_name setting of the standby, as set in the primary_conninfo of the standby's walreceiver. There is no mechanism to enforce uniqueness. In case of duplicates one of the matching standbys will be chosen to be the synchronous standby, though exactly which one is indeterminate. The special entry * matches any application_name, including the default application name of walreceiver.

If no synchronous standby names are specified here, then synchronous replication is not enabled and transaction commits will not wait for replication. This is the default configuration. Even when synchronous replication is enabled, individual transactions can be configured not to wait for replication by setting the synchronous_commit parameter to local or off.

This parameter can only be set in the postgresql.conf file or on the server command line.

vacuum_defer_cleanup_age (integer)
Specifies the number of transactions by which VACUUM and HOT updates will defer cleanup of dead row versions. The default is zero transactions, meaning that dead row versions can be removed as soon as possible, that is, as soon as they are no longer visible to any open transaction. You may wish to set this to a non-zero value on a primary server that is supporting hot standby servers, as described in Section 25.5. This allows more time for queries on the standby to complete without incurring conflicts due to early cleanup of rows. However, since the value is measured in terms of number of write transactions occurring on the primary server, it is difficult to predict just how much additional grace time will be made available to standby queries. This parameter can only be set in the postgresql.conf file or on the server command line.

You should also consider setting hot_standby_feedback on standby server(s) as an alternative to using this parameter.

18.6.3. Standby Servers

These settings control the behavior of a standby server that is to receive replication data. Their values on the master server are irrelevant.

hot_standby (boolean)
Specifies whether or not you can connect and run queries during recovery, as described in Section 25.5. The default value is off. This parameter can only be set at server start. It only has effect during archive recovery or in standby mode.

max_standby_archive_delay (integer)
When Hot Standby is active, this parameter determines how long the standby server should wait before canceling standby queries that conflict with about-to-be-applied WAL entries, as described in Section 25.5.2. max_standby_archive_delay applies when WAL data is being read from WAL archive (and is therefore not current). The default is 30 seconds. Units are milliseconds if not specified. A value of -1 allows the standby to wait forever for conflicting queries to complete. This parameter can only be set in the postgresql.conf file or on the server command line.

Note that max_standby_archive_delay is not the same as the maximum length of time a query can run before cancellation; rather it is the maximum total time allowed to apply any one WAL segment's data. Thus, if one query has resulted in significant delay earlier in the WAL segment, subsequent conflicting queries will have much less grace time.

max_standby_streaming_delay (integer)
When Hot Standby is active, this parameter determines how long the standby server should wait before canceling standby queries that conflict with about-to-be-applied WAL entries, as described in Section 25.5.2. max_standby_streaming_delay applies when WAL data is being received via streaming replication. The default is 30 seconds. Units are milliseconds if not specified. A value of -1 allows the standby to wait forever for conflicting queries to complete. This parameter can only be set in the postgresql.conf file or on the server command line.

Note that max_standby_streaming_delay is not the same as the maximum length of time a query can run before cancellation; rather it is the maximum total time allowed to apply WAL data once it has been received from the primary server. Thus, if one query has resulted in significant delay, subsequent conflicting queries will have much less grace time until the standby server has caught up again.

wal_receiver_status_interval (integer)
Specifies the minimum frequency for the WAL receiver process on the standby to send information about replication progress to the primary or upstream standby, where it can be seen using the pg_stat_replication view. The standby will report the last transaction log position it has written, the last position it has flushed to disk, and the last position it has applied. This parameter's value is the maximum interval, in seconds, between reports. Updates are sent each time the write or flush positions change, or at least as often as specified by this parameter. Thus, the apply position may lag slightly behind the true position. Setting this parameter to zero disables status updates completely. This parameter can only be set in the postgresql.conf file or on the server command line. The default value is 10 seconds.

When replication_timeout is enabled on a sending server, wal_receiver_status_interval must be enabled, and its value must be less than the value of replication_timeout.

hot_standby_feedback (boolean)
Specifies whether or not a hot standby will send feedback to the primary or upstream standby about queries currently executing on the standby. This parameter can be used to eliminate query cancels caused by cleanup records, but can cause database bloat on the primary for some workloads. Feedback messages will not be sent more frequently than once per wal_receiver_status_interval. The default value is off. This parameter can only be set in the postgresql.conf file or on the server command line.

If cascaded replication is in use the feedback is passed upstream until it eventually reaches the primary. Standbys make no other use of feedback they receive other than to pass upstream.
[url]http://www.xyzlady.com[/url]
PostgreSQL中文学习手册 PostgreSQL PostgreSQL PostgreSQL学习手册 学习手册 学习手册 (数据表 数据表 ) 4 一、表的定义: 一、表的定义: 一、表的定义: . 4 PostgreSQL PostgreSQL PostgreSQL学习手册 学习手册 学习手册 (模式 Schema) Schema) .9 PostgreSQL PostgreSQL PostgreSQL学习手册 学习手册 学习手册 (表的继承和分区 表的继承和分区 表的继承和分区 表的继承和分区 ) 10 一、表的继承: 一、表的继承: 一、表的继承: .10 PostgreSQL PostgreSQL PostgreSQL学习手册 学习手册 学习手册 (常用数据类型 常用数据类型 常用数据类型 ) 16 一、数值类型: 一、数值类型: 一、数值类型: .16 六、数组: 六、数组: .22 PostgreSQL PostgreSQL PostgreSQL学习手册 学习手册 学习手册 (函数和操作符 函数和操作符 函数和操作符 <一>) 25 一、逻辑操作符: 一、逻辑操作符: 一、逻辑操作符: 一、逻辑操作符: .25 四、字符串函数和操作: 四、字符串函数和操作: 四、字符串函数和操作: 四、字符串函数和操作: 四、字符串函数和操作: 四、字符串函数和操作: .27 五、位串函数和操作符: 五、位串函数和操作符: 五、位串函数和操作符: 五、位串函数和操作符: 五、位串函数和操作符: .29 PostgreSQL PostgreSQL PostgreSQL学习手册 学习手册 学习手册 (函数和操作符 函数和操作符 函数和操作符 <二>) 30 六、模式匹配: 六、模式匹配: 六、模式匹配: .30 八、时间 八、时间 /日期函数和操作符: 日期函数和操作符: 日期函数和操作符: 日期函数和操作符: 日期函数和操作符: 33 PostgreSQL PostgreSQL PostgreSQL学习手册 学习手册 学习手册 (函数和操作符 函数和操作符 函数和操作符 <三>) 35 九、序列操作函数: 九、序列操作函数: 九、序列操作函数: 九、序列操作函数: . 35 十二、系统信息 十二、系统信息 十二、系统信息 函数: 函数: .38 PostgreSQL PostgreSQL PostgreSQL学习手册 学习手册 学习手册 (索引 ) 42 一、索引的类型: 一、索引的类型: 一、索引的类型: 一、索引的类型: .42 四、唯一索引: 四、唯一索引: 四、唯一索引: .43 PostgreSQL PostgreSQL PostgreSQL学习手册 学习手册 学习手册 (事物隔离 事物隔离 ) 45 PostgreSQL PostgreSQL PostgreSQL学习手册 学习手册 学习手册 (性能提升技巧 性能提升技巧 性能提升技巧 ) 46 一、使用 一、使用 EXPLAINEXPLAINEXPLAINEXPLAIN EXPLAIN: 46 PostgreSQL PostgreSQL PostgreSQL学习手册 学习手册 学习手册 (服务器配置 服务器配置 服务器配置 ) 50 一、服务器进程的启动和关闭: 一、服务器进程的启动和关闭: 一、服务器进程的启动和关闭: 一、服务器进程的启动和关闭: 一、服务器进程的启动和关闭: 一、服务器进程的启动和关闭: . 50 PostgreSQL PostgreSQL PostgreSQL学习手册 学习手册 学习手册 (角色和权限 角色和权限 角色和权限 ) 52 PostgreSQL PostgreSQL PostgreSQL学习手册 学习手册 学习手册 (数据库管理 数据库管理 数据库管理 ) 54 一、概述: 一、概述: .54 PostgreSQL PostgreSQL PostgreSQL学习手册 学习手册 学习手册 (数据库维护 数据库维护 数据库维护 ) 56 一、恢复磁盘空间: 一、恢复磁盘空间: 一、恢复磁盘空间: 一、恢复磁盘空间: . 56 二、更新规划器统计: 二、更新规划器统计: 二、更新规划器统计: 二、更新规划器统计: 二、更新规划器统计: .57 四、定期重建索引: 四、定期重建索引: 四、定期重建索引: 四、定期重建索引: . 59 PostgreSQL PostgreSQL PostgreSQL学习手册 学习手册 学习手册 (系统表 系统表 ) 61 一、 pg_class: pg_class: pg_class: pg_class:pg_class: 61 三、 pg_attrdef: pg_attrdef: pg_attrdef:pg_attrdef:pg_attrdef:pg_attrdef:pg_attrdef:pg_attrdef:pg_attrdef: . 63 四、 pg_authid: pg_authid: pg_authid: pg_authid:pg_authid: 64 五、 pg_auth_members: pg_auth_members: pg_auth_members: pg_auth_members:pg_auth_members: pg_auth_members:pg_auth_members:pg_auth_members:pg_auth_members: .64 七、 pg_tablespace: pg_tablespace: pg_tablespace: pg_tablespace: pg_tablespace: pg_tablespace:pg_tablespace: .65 十、 pg_index: pg_index: pg_index:pg_index:pg_index:pg_index: . 67 PostgreSQL PostgreSQL PostgreSQL学习手册 学习手册 学习手册 (系统视图 系统视图 ) 68 一、 pg_tables: pg_tables: pg_tables: pg_tables: pg_tables: 68 二、 pg_indexes: pg_indexes: pg_indexes:pg_indexes:pg_indexes:pg_indexes: 68 三、 pg_views: pg_views:pg_views: pg_views: pg_views:pg_views: . 68 四、 pg_user: pg_user: pg_user:pg_user:pg_user: .69 五、 pg _roles:_roles:_roles:_roles: _roles: 69 六、 pg_rules: pg_rules:pg_rules:pg_rules: pg_rules: 69 七、 pg_settings: pg_settings: pg_settings: pg_settings:pg_settings: pg_settings:pg_settings:pg_settings: .70 PostgreSQL PostgreSQL PostgreSQL学习手册 学习手册 学习手册 (客户端命令 客户端命令 客户端命令 <一>) 70 零、口令文件: 零、口令文件: 零、口令文件: .70 PostgreSQL PostgreSQL PostgreSQL学习手册 学习手册 学习手册 (客户端命令 客户端命令 客户端命令 <二>) 75 七、 pg_dump: pg_dump: pg_dump:pg_dump:. 75 八、 pg_restore: pg_restore:pg_restore:pg_restore: pg_restore:pg_restore:pg_restore:pg_restore: 77 PostgreSQL PostgreSQL PostgreSQL学习手册 学习手册 学习手册 (SQL (SQL语言函数 语言函数 ) . 83 一、基本概念: 一、基本概念: 一、基本概念: .83 PostgreSQL PostgreSQL PostgreSQL学习手册 学习手册 学习手册 (PL/pgSQL (PL/pgSQL(PL/pgSQL 过程语言 过程语言 ) .86 一、概述: 一、概述:
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值