免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2317 | 回复: 0
打印 上一主题 下一主题

[Hive] master-slave一对一的情况下清除archive wal的范例 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2011-02-22 18:18 |只看该作者 |倒序浏览
on master
postgres=# create table tbl_checkpoint (chkpoint text,chk_time timestamp without time zone default now());
CREATE TABLE
postgres=# begin;
BEGIN
postgres=# insert into tbl_checkpoint (chkpoint,chk_time) select pg_xlogfile_name(pg_current_xlog_location()),now();
INSERT 0 1
postgres=# checkpoint;
CHECKPOINT
postgres=# commit;
COMMIT
postgres=# select * from tbl_checkpoint ;
         chkpoint         |          chk_time         
--------------------------+----------------------------
000000010000000400000038 | 2011-01-04 16:40:05.821066
000000010000000400000038 | 2011-01-04 16:41:30.54769
000000010000000400000038 | 2011-01-04 16:52:55.549503
000000010000000400000039 | 2011-01-04 16:54:29.153623
[root@db-172-16-3-39 pg_arch]# ll
total 65616
-rw------- 1 postgres postgres      254 Dec 30 15:17 000000010000000000000004.00000020.backup
-rw------- 1 postgres postgres      254 Jan  4 14:37 00000001000000020000003E.00000020.backup
-rw------- 1 postgres postgres 67108864 Jan  4 16:54 000000010000000400000038
-rw------- 1 postgres postgres       56 Dec 30 15:35 00000002.history

on slave
postgres=# select chkpoint from tbl_checkpoint where chk_time=(select max(chk_time) from tbl_checkpoint);
         chkpoint         
--------------------------
000000010000000400000039
(1 row)
postgres@db-172-16-3-39-> pg_archivecleanup $PGARCHIVE 000000010000000400000039
postgres@db-172-16-3-39-> cd $PGARCHIVE
[root@db-172-16-3-39 pg_arch]# ll
total 12
-rw------- 1 postgres postgres 254 Dec 30 15:17 000000010000000000000004.00000020.backup
-rw------- 1 postgres postgres 254 Jan  4 14:37 00000001000000020000003E.00000020.backup
-rw------- 1 postgres postgres  56 Dec 30 15:35 00000002.history

缩写:
pg_archivecleanup $PGARCHIVE `psql -h 127.0.0.1 postgres postgres -q -t -A -c "select chkpoint from tbl_checkpoint where chk_time=(select max(chk_time) from tbl_checkpoint)"`

on slave验证
重启slave,
postgres: startup process   waiting for 000000010000000400000039
可以登录postgresql,验证正常.
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP