磨砺技术珠矶,践行数据之道,追求卓越价值
回到上一级页面: 回到顶级页面:
一,从initdb开始,initdb执行结束后,看xlog:
[pgsql@localhost pg_xlog]$ ls -lrt
total 16408drwx------ 2 pgsql pgsql 4096 Aug 6 10:41 archive_status-rw------- 1 pgsql pgsql 16777216 Aug 6 10:41 000000010000000000000001[pgsql@localhost pg_xlog]$
然后,设置参数为这样:
archive_mode = on # allows archiving to be done # (change requires restart) ...archive_command = 'copy %p "/home/pgsql/archive_log/%f"' # command to use to archive a logfile segment#archive_timeout = 0 # force a logfile segment switch after this # number of seconds; 0 disableswal_level = archive # minimal, archive, or hot_standby # (change requires restart)
二,启动PostgreSQL,然后一直等待...
看xlog是否有变化,等了一个小时以上,没有发现变化。
[pgsql@localhost pg_xlog]$ ls -lrttotal 16408drwx------ 2 pgsql pgsql 4096 Aug 6 10:41 archive_status-rw------- 1 pgsql pgsql 16777216 Aug 6 11:04 000000010000000000000001[pgsql@localhost pg_xlog]$ [pgsql@localhost pg_xlog]$ [pgsql@localhost pg_xlog]$ ls ../../archive_log[pgsql@localhost pg_xlog]$
三,关闭PostgreSQL: ./pg_ctl -D ../../DemoDir stop
可以发现,online redo log增加了一个。
[pgsql@localhost ~]$ ls -lrt ./DemoDir/pg_xlog
total 32812-rw------- 1 pgsql pgsql 16777216 Aug 6 12:48 000000010000000000000001drwx------ 2 pgsql pgsql 4096 Aug 6 12:48 archive_status-rw------- 1 pgsql pgsql 16777216 Aug 6 12:48 000000010000000000000002[pgsql@localhost ~]$ ls -lrt ./archive_logtotal 16404-rw------- 1 pgsql pgsql 16777216 Aug 6 12:48 000000010000000000000001[pgsql@localhost ~]$再次开启: ./pg_ctl -D ../../DemoDir start
因为没有什么操作,所以也无变化:
[pgsql@localhost ~]$ ls -lrt ./DemoDir/pg_xlogtotal 32812-rw------- 1 pgsql pgsql 16777216 Aug 6 12:48 000000010000000000000001drwx------ 2 pgsql pgsql 4096 Aug 6 12:48 archive_status-rw------- 1 pgsql pgsql 16777216 Aug 6 12:48 000000010000000000000002[pgsql@localhost ~]$ ls -lrt ./archive_logtotal 16404-rw------- 1 pgsql pgsql 16777216 Aug 6 12:48 000000010000000000000001[pgsql@localhost ~]$
再次关闭:./pg_ctl -D ../../DemoDir stop
[pgsql@localhost ~]$ ls -lrt ./DemoDir/pg_xlogtotal 49216-rw------- 1 pgsql pgsql 16777216 Aug 6 12:48 000000010000000000000004-rw------- 1 pgsql pgsql 16777216 Aug 6 12:51 000000010000000000000002drwx------ 2 pgsql pgsql 4096 Aug 6 12:51 archive_status-rw------- 1 pgsql pgsql 16777216 Aug 6 12:51 000000010000000000000003[pgsql@localhost ~]$ ls -lrt ./archive_logtotal 32808-rw------- 1 pgsql pgsql 16777216 Aug 6 12:48 000000010000000000000001-rw------- 1 pgsql pgsql 16777216 Aug 6 12:51 000000010000000000000002[pgsql@localhost ~]$
四,如果与性中,进行切换log:
postgres=# select pg_switch_xlog(); pg_switch_xlog ---------------- 0/3000098(1 row)postgres=#
[pgsql@localhost ~]$ ls -lrt ./DemoDir/pg_xlogtotal 49216-rw------- 1 pgsql pgsql 16777216 Aug 6 12:48 000000010000000000000004-rw------- 1 pgsql pgsql 16777216 Aug 6 12:51 000000010000000000000002drwx------ 2 pgsql pgsql 4096 Aug 6 12:56 archive_status-rw------- 1 pgsql pgsql 16777216 Aug 6 12:56 000000010000000000000003[pgsql@localhost ~]$ ls -lrt ./archive_logtotal 49212-rw------- 1 pgsql pgsql 16777216 Aug 6 12:48 000000010000000000000001-rw------- 1 pgsql pgsql 16777216 Aug 6 12:51 000000010000000000000002-rw------- 1 pgsql pgsql 16777216 Aug 6 12:56 000000010000000000000003[pgsql@localhost ~]$
回到上一级页面: 回到顶级页面:
磨砺技术珠矶,践行数据之道,追求卓越价值