1 问题现象
一主两从的 openGauss 5.0 集群,节点 1 会自动变成Standby ReadOnly:
[dave@www.cndba.cn dn]$ gs_om -t status --detail
[ CMServer State ]
node node_ip instance state
----------------------------------------------------------------------
1 gbase01 192.168.56.109 1 /data/gbase/cmserver/cm_server Standby
2 gbase02 192.168.56.110 2 /data/gbase/cmserver/cm_server Primary
3 gbase03 192.168.56.111 3 /data/gbase/cmserver/cm_server Standby
[ Cluster State ]
cluster_state : Degraded
redistributing : No
balanced : No
current_az : AZ_ALL
[ Datanode State ]
node node_ip instance state
---------------------------------------------------------------------
1 gbase01 192.168.56.109 6001 /data/gbase/data/dn P Standby ReadOnly
2 gbase02 192.168.56.110 6002 /data/gbase/data/dn S Primary Normal
3 gbase03 192.168.56.111 6003 /data/gbase/data/dn S Standby Normal
重启后会短暂的显示Standby Normal,然后又变成Standby ReadOnly。
该状态是由default_transaction_read_only 参数控制,但是修改后,重启 DN 后,状态又变了:
gs_guc reload -N all -I all -c “default_transaction_read_only=off”
log 日志有记录修改的过程:
2024-05-06 00:09:42.324 66378511.1 [unknown] 139731731067328 [unknown] 0 dn_6001_6002_6003 00000 0 [BACKEND] LOG: parameter “default_transaction_read_only” changed to “on”
2 分析过程
这里改变状态包括修改参数,实际上是 CM 来操作的,在 CMServer 中有个参数:
datastorage_threshold_value_check
- 参数说明: 设置数据库只读模式的磁盘占用阈值,当某个节点的数据目录所在磁盘占用阈值超过这个阈值,如果该节点为备机,自动将该节点设置为只读,如果该节点为主机,则会自动将主机切换到一个合适的主机上。如果所有节点的阈值均达到阈值,则会将集群设置为只读。
- 取值范围: 整型,[1, 99]。修改后可以reload生效,参数修改请参考表 set cm参数进行设置。
- 默认值: 85
因为该参数的原因,当磁盘空间使用率超过 85% 的时候,节点会自动变成 readonly。
我们这里恰好是 86%:
[dave@www.cndba.cn dn]$ df -lh
文件系统 容量 已用 可用 已用% 挂载点
devtmpfs 3.8G 0 3.8G 0% /dev
tmpfs 3.8G 16K 3.8G 1% /dev/shm
tmpfs 3.8G 360M 3.4G 10% /run
tmpfs 3.8G 0 3.8G 0% /sys/fs/cgroup
/dev/mapper/centos-root 74G 64G 11G 86% /
/dev/sda1 1014M 185M 830M 19% /boot
tmpfs 764M 0 764M 0% /run/user/54324
tmpfs 764M 32K 764M 1% /run/user/0
[dave@www.cndba.cn dn]$
3 解决方法
修改该参数值,或者释放更多的磁盘空间,我们这里是测试环境,直接改成 99.
[dave@www.cndba.cn dn_6001]$ gs_guc reload -Z cmserver -N all -I all -c "datastorage_threshold_value_check = 99"
The gs_guc run with the following arguments: [gs_guc -Z cmserver -N all -I all -c datastorage_threshold_value_check = 99 reload ].
Begin to perform the total nodes: 3.
Popen count is 3, Popen success count is 3, Popen failure count is 0.
Begin to perform gs_guc for cm_servers.
Command count is 3, Command success count is 3, Command failure count is 0.
Total instances: 3. Failed instances: 0.
ALL: Success to perform gs_guc!
再次查看,节点就变成Standby Normal 状态了:
[dave@www.cndba.cn dn]$ gs_om -t status --detail
[ CMServer State ]
node node_ip instance state
----------------------------------------------------------------------
1 gbase01 192.168.56.109 1 /data/gbase/cmserver/cm_server Standby
2 gbase02 192.168.56.110 2 /data/gbase/cmserver/cm_server Primary
3 gbase03 192.168.56.111 3 /data/gbase/cmserver/cm_server Standby
[ Cluster State ]
cluster_state : Normal
redistributing : No
balanced : No
current_az : AZ_ALL
[ Datanode State ]
node node_ip instance state
---------------------------------------------------------------------
1 gbase01 192.168.56.109 6001 /data/gbase/data/dn P Standby Normal
2 gbase02 192.168.56.110 6002 /data/gbase/data/dn S Primary Normal
3 gbase03 192.168.56.111 6003 /data/gbase/data/dn S Standby Normal
[dave@www.cndba.cn dn]$
版权声明:本文为博主原创文章,未经博主允许不得转载。