pg9.1 支持streaming replication
我们设置数据库的时候会遇到这个参数 ,官方文档上关于这个参数的介绍只有一行:
“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. 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”
我们测试下这个参数:
这个参数设置为0 会发生什么?
[code]
我们设置数据库的时候会遇到这个参数 ,官方文档上关于这个参数的介绍只有一行:
“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. 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”
我们测试下这个参数:
这个参数设置为0 会发生什么?
[code]
postgres=# show max_wal_senders; max_wal_senders ----------------- 0 (1 row)
postgres=# set max_wal_senders=1; ERROR: parameter "max_wal_senders" cannot be changed without restarting the server
[/code]
首先这个参数是不能在线修改的,如果预设为0,就失去了为现有库配置从库的能力了。
[code]
%> pg_basebackup -h 10.0.0.1 -D /var/lib/pgsql/9.1/data/ pg_basebackup: could not connect to server: FATAL: number of requested standby connections exceeds max_wal_senders (currently 0)
[/code]
如果设置为0 ,pg_basebackup 也无法制作基础备份集了。
把这个值改为负数会如何呢?
[code]
[postgres@dba-test-11-97 data]$ pg_ctl start
server starting
[postgres@dba-test-11-97 data]$ FATAL: -1 is outside the valid range for parameter "max_wal_senders" (0 .. 8388607)
[/code]
数据库无法启动了, 同时也可以看到这个参数的取值范围为(0 .. 8388607)
设置为8388608
[code]
[postgres@dba-test-11-97 data]$ pg_ctl start
server starting
[postgres@dba-test-11-97 data]$ FATAL: 8388608 is outside the valid range for parameter "max_wal_senders" (0 .. 8388607)
[/code]
数据库也是无法启动的。
那么既然他是向从库发送wal的,那么他跟最大连接数有什么关系呢?
我们设置最大连接数为1,max_wal_senders 为最大值。
postgres=# show max_connections; max_connections ----------------- 1 (1 row) postgres=# show max_wal_senders; max_wal_senders ----------------- 8388607 (1 row)
[postgres@dba-test-11-98 pg_log]$ psql -h ha97
psql: FATAL: sorry, too many clients already
[postgres@dba-test-11-98 pg_log]$
我们再开始从其他机器登录数据库,已经无法登录,连接用完了。
%> pg_basebackup -h 10.0.0.1 -D /var/lib/pgsql/9.1/data/ pg_basebackup: could not connect to server: FATAL: sorry, too many clients already
备份也无法做了。
基本可以总结一下了,max_wal_sender 受max_connection 的约束,这个参数限制主库可以搭建的从库的数目。
具体数值的设定,没有太大意义,给一个基本的数值就可以了,我们设置为10.
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/133735/viewspace-742081/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/133735/viewspace-742081/