目录
1. 参数概述
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参数正常生效,在设定的时间应用到备机。




