GaussDB修改表空间占用磁盘使用率阈值

GaussDB数据库表空间占用磁盘使用率达到了你所设定的值后数据库会进入只读模式

执行非只读SQL时报错如下:

ERROR: cannot execute %s in a read-only transaction.
或者运行中部分非只读SQL(insert、update、create table as、create index、alter table 及copy from等)时报错。
canceling statement due to default_transaction_read_only is on

原因分析
磁盘空间达到阈值后,设置数据库只读,只允许只读语句执行。

处理办法:
步骤 1 使用maintenance模式连接数据库,以下两种方法均可。


方式一:
gsql -d postgres -p 8000 -r -m
方式二:
gsql -d postgres -p 8000 -r

连接成功后,执行如下命令:
set xc_maintenance_mode=on;此命令不建议使用,可以跳过,最后实在不行再做这一步

步骤 2 使用DROP/TRUNCATE语句删除当前不再使用的用户表,直至磁盘空间使用率小于设定的阈值。删除大文件,基本上只需要操作这步即可,把磁盘使用率降下来,数据库自动恢复状态
删除用户表只能暂时缓解磁盘空间不足的问题,建议尽早通过扩容解决磁盘空间不足的问题。
步骤 3 使用系统用户omm设置数据库只读模式关闭。
gs_guc reload -D /gaussdb/data/dbnode -c “default_transaction_read_only=off”

提前提高阈值方法
可以先去cm_server下看下当前的阈值是多少,可以看出为85%

[root@gaussdb01 cm_server]# cat cm_server.conf | grep datastorage_threshold_value_check
datastorage_threshold_value_check = 85

在这里插入图片描述

修改为95%

gs_guc reload -Z cmserver -N all -I all -c "datastorage_threshold_value_check=95"

在这里插入图片描述
再次查看已修改为95%
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/m0_46400195/article/details/127984109