暂无图片
暂无图片
1
暂无图片
暂无图片
暂无图片

opengauss2.0.0备库日志延迟回放验证

1725


 

目录

1.      参数概述

2.      环境准备

3.      测试参数

    3.1 确认影响参数

    3.2 修改参数

    3.3 测试

        3.3.1主库写入数据

        3.3.2 备库查询数据

4.      结论

 

 


 

1.  参数概述

 recovery_min_apply_delay该参数为opengauss2.2.0提供的备库日志延迟回放新特性的控制参数,该参数单位为毫秒,可以使用gs_guc修改。

 

2.  环境准备

至少两台数据库服务器,安装好openGauss2.0.0,调整数据库参数为推荐基线参数。确认两台服务器的时间是否一致,使用如下命令同步时间。

ntpdate ntp1.aliyun.com

3.  测试参数

3.1 确认影响参数

当synchronous_commit被设置为remote_apply时,同步复制会受到这个延时的影响,每一个COMMIT都需要等待备机回放结束后才会返回。故参数synchronous_commit先设置为off

gsql -p 9832 -d postgres -r -c "show synchronous_commit"

 synchronous_commit

--------------------

 off

(1 row)

 

 

3.2 修改参数

为了使效果更明显,此处设置recovery_min_apply_delay的值较大一点。这里设置为2分钟,该参数单位为毫秒。该参数属于SIGHUP类型参数,无需重启。

[omm@kvm-yl1 ~]$ gs_guc reload -I all -N all -c "recovery_min_apply_delay = 120000" 

Begin to perform the total nodes: 2.

Popen count is 2, Popen success count is 2, Popen failure count is 0.

Begin to perform gs_guc for datanodes.

Command count is 2, Command success count is 2, Command failure count is 0.

 

Total instances: 2. Failed instances: 0.

ALL: Success to perform gs_guc!

 

检查备库参数是否生效

[omm@kvm-yl2 ~]$ gsql -p 9832 -d postgres -r -c "show recovery_min_apply_delay"

 recovery_min_apply_delay

--------------------------

 2min

(1 row)

 

3.3 测试

3.3.1主库写入数据

postgres=# select now();

              now             

-------------------------------

 2021-04-25 16:25:43.759699+08

(1 row)

 

postgres=# begin;

BEGIN

postgres=# create table test_1 (id int);

CREATE TABLE

postgres=# insert into test_1 values(1);

INSERT 0 1

postgres=# commit;

COMMIT

postgres=# end;

WARNING:  there is no transaction in progress

COMMIT

postgres=# select now();

              now             

-------------------------------

 2021-04-25 16:25:43.771321+08

(1 row)

 

3.3.2 备库查询数据

postgres=# select now();select * from test_1;

              now             

-------------------------------

 2021-04-25 16:27:21.190967+08

(1 row)

 

ERROR:  relation "test_1" does not exist on dn_6001_6002

LINE 1: select * from test_1;

                      ^

postgres=# select now();select * from test_1;

              now             

-------------------------------

 2021-04-25 16:27:53.432107+08

(1 row)

 

 id

----

  1

(1 row)

两分钟内备库无法查询数据,两分钟后数据查询成功。该参数正常生效。

4.  结论

recovery_min_apply_delay参数正常生效,在设定的时间应用到备机。

最后修改时间:2021-04-26 15:09:55
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论