wal_level (enum)
wal_level决定有多少信息被写入到WAL中。 默认值是最小的,其中写入唯一从崩溃或立即关机中恢复的所需信息。 archive补充WAL归档需要的日志记录,
以及 hot_standby进一步增加在备用服务器上运行只读查询所需的信息 。这个参数只能在服务器启动时设置。
在最小级别中,安全地忽略一些批量操作的WAL-日志, 这可以使那些操作快很多(参阅第 14.4.7 节)。 这种优化可以应用到:
CREATE TABLE AS
CREATE INDEX
CLUSTER
COPY into tables that were created or truncated in the same transaction
但是最小的WAL不包含从基本的备份和WAL日志中重建数据的足够信息, 所以archive或者hot_standby级别必须用来启动 WAL归档(archive_mode)和流复制。
在hot_standby级别,相同的信息被记录为archive, 加上需要重建从WAL运行的事务状态信息。 为了在备用服务器上启用只读查询,主库上wal_level必须设置为hot_standby,
必须启动备库上的hot_standby。 使用hot_standby和archive级别之间的性能几乎没有可测量的差异 ,如果任何生产的影响是明显的,则是值得欢迎的。
[postgres@zhaopin-200-43 /data/postgresql/rdrc_94/data/pg_log]$ more postgresql-2015-11-25_02.log
[ 2015-11-25 02:37:35.583 UTC 115397 56551eef.1c2c5 1 0]LOG: database system was shut down at 2015-11-25 02:37:34 UTC
[ 2015-11-25 02:37:35.594 UTC 115397 56551eef.1c2c5 2 0]LOG: MultiXact member wraparound protections are now enabled
[ 2015-11-25 02:37:35.597 UTC 115395 56551eef.1c2c3 3 0]LOG: database system is ready to accept connections
[ 2015-11-25 02:37:35.597 UTC 115401 56551eef.1c2c9 1 0]LOG: autovacuum launcher started
postgres=# select * from pg_
postgres-# ^C
postgres=# insert into test_logical(id) values (2),(3),(4);
INSERT 0 3
postgres=# select * from test_logical;
id
----
1
2
3
4
(4 rows)
postgres=# select * from pg_logical_slot_get_changes('log_slot1',null,null);
location | xid | data
-------------+------+--------------------------------------------------
71/99000028 | 2000 | BEGIN 2000
71/99000028 | 2000 | table public.test_logical: INSERT: id[integer]:2
71/99000068 | 2000 | table public.test_logical: INSERT: id[integer]:3
71/990000A8 | 2000 | table public.test_logical: INSERT: id[integer]:4
71/99000128 | 2000 | COMMIT 2000
(5 rows)
postgres=# insert into test_logical (id) values (7);
INSERT 0 1
postgres=# select * from pg_logical_slot_peek_changes('log_slot1',null,null);
location | xid | data
-------------+------+--------------------------------------------------
71/A5000028 | 2001 | BEGIN 2001
71/A5000028 | 2001 | table public.test_logical: INSERT: id[integer]:7
71/A50000A8 | 2001 | COMMIT 2001
(3 rows)
postgres=# select * from pg_logical_slot_peek_changes('log_slot1',null,null);
location | xid | data
-------------+------+--------------------------------------------------
71/A5000028 | 2001 | BEGIN 2001
71/A5000028 | 2001 | table public.test_logical: INSERT: id[integer]:7
71/A50000A8 | 2001 | COMMIT 2001
(3 rows)
postgres=# select * from pg_logical_slot_peek_changes('log_slot1',null,null);
location | xid | data
-------------+------+--------------------------------------------------
71/A5000028 | 2001 | BEGIN 2001
71/A5000028 | 2001 | table public.test_logical: INSERT: id[integer]:7
71/A50000A8 | 2001 | COMMIT 2001
(3 rows)
postgres=# select * from pg_logical_slot_peek_changes('log_slot1',null,null);
location | xid | data
-------------+------+--------------------------------------------------
71/A5000028 | 2001 | BEGIN 2001
71/A5000028 | 2001 | table public.test_logical: INSERT: id[integer]:7
71/A50000A8 | 2001 | COMMIT 2001
(3 rows)
postgres=# create table test_1(id int4);
CREATE TABLE
postgres=# insert into test_1 values (1);
INSERT 0 1
postgres=# insert into test_1 values (2);
INSERT 0 1
postgres=# delete from test_1 where id=1;
COMMIT 2003
BEGIN 2004
table public.test_1: INSERT: id[integer]:2
COMMIT 2004
BEGIN 2005
table public.test_1: DELETE: (no-tuple-data)
COMMIT 2005
pg_recvlogical: could not receive data from WAL stream: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
pg_recvlogical: disconnected; waiting 5 seconds to try again
BEGIN 2001
table public.test_logical: INSERT: id[integer]:7
COMMIT 2001
BEGIN 2002
COMMIT 2002
BEGIN 2003
table public.test_1: INSERT: id[integer]:1
COMMIT 2003
BEGIN 2004
table public.test_1: INSERT: id[integer]:2
COMMIT 2004
BEGIN 2005
table public.test_1: DELETE: (no-tuple-data)
COMMIT 2005
pg_recvlogical: could not receive data from WAL stream: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
pg_recvlogical: disconnected; waiting 5 seconds to try again
BEGIN 2001
table public.test_logical: INSERT: id[integer]:7
COMMIT 2001
BEGIN 2002
COMMIT 2002
BEGIN 2003
table public.test_1: INSERT: id[integer]:1
COMMIT 2003
BEGIN 2004
table public.test_1: INSERT: id[integer]:2
COMMIT 2004
BEGIN 2005
table public.test_1: DELETE: (no-tuple-data)
COMMIT 2005
pg_recvlogical: could not receive data from WAL stream: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
pg_recvlogical: disconnected; waiting 5 seconds to try again
BEGIN 2001
table public.test_logical: INSERT: id[integer]:7
COMMIT 2001
BEGIN 2002
COMMIT 2002
BEGIN 2003
table public.test_1: INSERT: id[integer]:1
COMMIT 2003
BEGIN 2004
table public.test_1: INSERT: id[integer]:2
COMMIT 2004
BEGIN 2005
table public.test_1: DELETE: (no-tuple-data)
COMMIT 2005
pg_recvlogical: could not receive data from WAL stream: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29898569/viewspace-1846201/
,如需转载,请注明出处,否则将追究法律责任。