pg归档日志的开启与关闭
来源:互联网 发布:医学论文数据库 编辑:程序博客网 时间:2024/05/07 23:05
postgres.conf文件的配置对所有数据库起作用:
postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+-------------+----------+-------------+-------------+---------------------------------
postgres | postgres9.6 | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres9.6 | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/"postgres9.6" +
| | | | | "postgres9.6"=CTc/"postgres9.6"
template1 | postgres9.6 | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/"postgres9.6" +
| | | | | "postgres9.6"=CTc/"postgres9.6"
test | postgres9.6 | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
(4 rows)
postgres=# \c
You are now connected to database "postgres" as user "postgres9.6".
postgres=# show archive_mode;
archive_mode
--------------
on
(1 row)
postgres=# select pg_switch_xlog();
pg_switch_xlog
----------------
0/C000078
(1 row)
test=# \c
You are now connected to database "test" as user "postgres9.6".
test=# select pg_switch_xlog();
pg_switch_xlog
----------------
0/B02A090
(1 row)
[root@db 20170206]# pwd
/home/postgres9.6/arch/20170206
[root@db 20170206]# ls
00000001000000000000000A 00000001000000000000000B 00000001000000000000000C
============================================================================================================================
开启归档模式:
[postgres9.6@db data]$ pwd
/home/postgres9.6/data
[postgres9.6@db data]$ ll postgresql.conf
-rw------- 1 postgres9.6 postgres 22369 Feb 6 13:35 postgresql.conf
vi postgres.conf修改如下:
wal_level = replica # minimal, replica, or logical
archive_mode = on # enables archiving; off, on, or always
# (change requires restart)
archive_command = 'DATE=`date +%Y%m%d`;DIR="/home/postgres9.6/arch/$DATE";(test -d $DIR || mkdir -p $DIR)&& cp %p $DIR/%f' # command to use to archive a logfile segment
其中: %p表示wal日志文件的路径,%f表示wal日志文件名称。
[postgres9.6@db data]$ pg_ctl stop
waiting for server to shut down.... done
server stopped
[postgres9.6@db data]$ pg_ctl start
server starting
[postgres9.6@db data]$ LOG: database system was shut down at 2017-02-06 13:40:26 CST
LOG: MultiXact member wraparound protections are now enabled
LOG: database system is ready to accept connections
LOG: autovacuum launcher started
postgres=# \c
You are now connected to database "postgres" as user "postgres9.6".
postgres=# select pg_switch_xlog();
pg_switch_xlog
----------------
0/F000120
(1 row)
postgres=# select pg_switch_xlog();
pg_switch_xlog
----------------
0/10000078
(1 row)
postgres=# show archive_mode;
archive_mode
--------------
on
(1 row)
test=# \c
You are now connected to database "test" as user "postgres9.6".
test=# select pg_switch_xlog();
pg_switch_xlog
----------------
0/11000078
(1 row)
test=# show archive_mode;
archive_mode
--------------
on
(1 row)
[root@db 20170206]# pwd
/home/postgres9.6/arch/20170206
[root@db 20170206]# ls
00000001000000000000000F 000000010000000000000010 000000010000000000000011
##### pg里不同数据库之间日志(归档日志或者pc_xlog)(目录)是共享的。####
关闭归档模式:
将以上三个参数注释或者修改即可
postgres=# \l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+-------------+----------+-------------+-------------+---------------------------------
postgres | postgres9.6 | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres9.6 | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/"postgres9.6" +
| | | | | "postgres9.6"=CTc/"postgres9.6"
template1 | postgres9.6 | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/"postgres9.6" +
| | | | | "postgres9.6"=CTc/"postgres9.6"
test | postgres9.6 | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
(4 rows)
postgres=# \c
You are now connected to database "postgres" as user "postgres9.6".
postgres=# show archive_mode;
archive_mode
--------------
on
(1 row)
postgres=# select pg_switch_xlog();
pg_switch_xlog
----------------
0/C000078
(1 row)
test=# \c
You are now connected to database "test" as user "postgres9.6".
test=# select pg_switch_xlog();
pg_switch_xlog
----------------
0/B02A090
(1 row)
[root@db 20170206]# pwd
/home/postgres9.6/arch/20170206
[root@db 20170206]# ls
00000001000000000000000A 00000001000000000000000B 00000001000000000000000C
============================================================================================================================
开启归档模式:
[postgres9.6@db data]$ pwd
/home/postgres9.6/data
[postgres9.6@db data]$ ll postgresql.conf
-rw------- 1 postgres9.6 postgres 22369 Feb 6 13:35 postgresql.conf
vi postgres.conf修改如下:
wal_level = replica # minimal, replica, or logical
archive_mode = on # enables archiving; off, on, or always
# (change requires restart)
archive_command = 'DATE=`date +%Y%m%d`;DIR="/home/postgres9.6/arch/$DATE";(test -d $DIR || mkdir -p $DIR)&& cp %p $DIR/%f' # command to use to archive a logfile segment
其中: %p表示wal日志文件的路径,%f表示wal日志文件名称。
[postgres9.6@db data]$ pg_ctl stop
waiting for server to shut down.... done
server stopped
[postgres9.6@db data]$ pg_ctl start
server starting
[postgres9.6@db data]$ LOG: database system was shut down at 2017-02-06 13:40:26 CST
LOG: MultiXact member wraparound protections are now enabled
LOG: database system is ready to accept connections
LOG: autovacuum launcher started
postgres=# \c
You are now connected to database "postgres" as user "postgres9.6".
postgres=# select pg_switch_xlog();
pg_switch_xlog
----------------
0/F000120
(1 row)
postgres=# select pg_switch_xlog();
pg_switch_xlog
----------------
0/10000078
(1 row)
postgres=# show archive_mode;
archive_mode
--------------
on
(1 row)
test=# \c
You are now connected to database "test" as user "postgres9.6".
test=# select pg_switch_xlog();
pg_switch_xlog
----------------
0/11000078
(1 row)
test=# show archive_mode;
archive_mode
--------------
on
(1 row)
[root@db 20170206]# pwd
/home/postgres9.6/arch/20170206
[root@db 20170206]# ls
00000001000000000000000F 000000010000000000000010 000000010000000000000011
##### pg里不同数据库之间日志(归档日志或者pc_xlog)(目录)是共享的。####
关闭归档模式:
将以上三个参数注释或者修改即可
阅读全文
0 0
- pg归档日志的开启与关闭
- Oralce 归档日志开启与关闭
- oracle归档日志的开启和关闭
- oracle 归档日志开启,关闭
- oracle 开启关闭归档日志
- oracle 开启关闭归档日志
- Oracle 开启归档日志以及关闭归档日志
- Oracle 开启归档日志以及关闭归档日志
- Oracle关闭和开启归档日志
- oracle 关闭和开启归档日志
- Oracle关闭和开启归档日志
- Oracle单节点开启关闭归档日志
- 开启/关闭oracle的归档
- webseald的trace,日志开启与关闭
- 如何开启/关闭oracle的归档
- Oracle 11G RAC开启和关闭归档日志
- 如何开启/关闭归档
- 如何开启/关闭归档 .
- k-Nearest Neighbors(k近邻)
- 使用cifar100,转化lmdb及制作均值文件
- PS第一课,认识Photoshop
- 设计模式之单例模式
- BZOJ 4950 [Wf 2017] 二分图最大匹配 解题报告
- pg归档日志的开启与关闭
- Java 数字中使用下划线
- 顺序查找和二分查找
- 51nod 1584 加权约数和
- [leetcode] 第五周作业
- MongoDB用户管理
- jsp常见的指令总结
- CSS_1_2017_10_9
- 经典进程同步问题(二)——读者、写者问题