天天看点

postgres 开启wal归档

1.postgres 开启wal归档:

a.修改wal_level参数:

alter system set wal_level= 'replica';

postgres=# alter system set wal_level= 'replica';

ALTER SYSTEM

b.修改archive_mode参数:

alter system set archive_mode= 'on';

postgres=# alter system set archive_mode= 'on';

c.修改archive_command 参数:

alter system set archive_command = '/bin/cp -i %p /pgdata/10/archive_wal/%f';

postgres=# alter system set archive_command = '/bin/cp -i %p /pgdata/10/archive_wal/%f';

2.PostgreSQL手动切换WAL日志的命令:

PG10之前:

select pg_switch_xlog();

PG10之后:

select pg_switch_wal();