精品课程网站建设开题报告,公众号页面设计模板,网络规划设计师教程2021版,做网站如何推销文章目录 openGauss学习笔记-130 openGauss 数据库管理-参数设置-重设参数130.1 背景信息130.2 GUC参数设置130.3 操作步骤130.4 示例 openGauss学习笔记-130 openGauss 数据库管理-参数设置-重设参数
130.1 背景信息
openGauss提供了多种修改GUC参数的方法#xff0c;用户可… 文章目录 openGauss学习笔记-130 openGauss 数据库管理-参数设置-重设参数130.1 背景信息130.2 GUC参数设置130.3 操作步骤130.4 示例 openGauss学习笔记-130 openGauss 数据库管理-参数设置-重设参数
130.1 背景信息
openGauss提供了多种修改GUC参数的方法用户可以方便的针对数据库、用户、会话进行设置。
参数名称不区分大小写。参数取值有整型、浮点型、字符串、布尔型和枚举型五类。 布尔值可以是onoff、truefalse、yesno或者10且不区分大小写。枚举类型的取值是在系统表pg_settings的enumvals字段取值定义的。 对于有单位的参数在设置时请指定单位否则将使用默认的单位。 参数的默认单位在系统表pg_settings的unit字段定义的。内存单位有KB千字节、MB兆字节和GB吉字节。时间单位ms毫秒、s秒、min分钟、h小时和d天。
具体参数说明请参见GUC参数说明。
130.2 GUC参数设置
openGauss提供了六类GUC参数具体分类和设置方式请参考表1
表 1 GUC参数分类
参数类型说明设置方式INTERNAL固定参数在创建数据库的时候确定用户无法修改只能通过show语法或者pg_settings视图进行查看。无POSTMASTER数据库服务端参数在数据库启动时确定可以通过配置文件指定。支持方式一、方式四。SIGHUP数据库全局参数可在数据库启动时设置或者在数据库启动后发送指令重新加载。支持方式一、方式二、方式四。BACKEND会话连接参数。在创建会话连接时指定连接建立后无法修改。连接断掉后参数失效。内部使用参数不推荐用户设置。支持方式一、方式二、方式四。说明设置该参数后下一次建立会话连接时生效。SUSET数据库管理员参数。可在数据库启动时、数据库启动后或者数据库管理员通过SQL进行设置。支持方式一、方式二或由数据库管理员通过方式三设置。USERSET普通用户参数。可被任何用户在任何时刻设置。支持方式一、方式二或方式三设置。
openGauss提供了四种方式来修改GUC参数具体操作如下
表 2 GUC参数设置方式
方式一
使用如下命令修改参数。
gs_guc set -D datadir -c paranamevalue说明
如果参数是一个字符串变量则使用-c parameter‘value’或者使用-c “parameter ‘value’”。
使用以下命令在数据库节点上同时设置某个参数。
gs_guc set -N all -I all -c paranamevalue使用以下命令在数据库节点上设置cm_agent某个参数。
gs_guc set -Z cmagent -c paranamevalue
gs_guc set -Z cmagent -N all -I all -c paranamevalue 使用以下命令在数据库节点上设置cm_server某个参数。
gs_guc set -Z cmserver -c paranamevalue
gs_guc set -Z cmserver -N all -I all -c paranamevalue 重启数据库使参数生效。
说明
重启openGauss操作会导致用户执行操作中断请在操作之前规划好合适的执行窗口。
gs_om -t stop gs_om -t start方式二
gs_guc reload -D datadir -c paranamevalue说明
使用以下命令在数据库节点上同时设置某个参数。
gs_guc reload -N all -I all -c paranamevalue方式三
修改指定数据库、用户、会话级别的参数。 设置数据库级别的参数 openGauss# ALTER DATABASE dbname SET paraname TO value;在下次会话中生效。 设置用户级别的参数 openGauss# ALTER USER username SET paraname TO value;在下次会话中生效。 设置会话级别的参数 openGauss# SET paraname TO value;修改本次会话中的取值。退出会话后设置将失效。 说明 SET设置的会话级参数优先级最高其次是ALTER设置的其中ALTER DATABASE设置的参数值优先级高于ALTER USER设置这三种设置方式设置的优先级都高于gs_guc设置方式。
方式四
使用ALTER SYSTEM SET修改数据库参数。 设置POSTMASERT级别的参数 openGauss# ALTER SYSTEM SET paraname TO value;重启后生效。 设置SIGHUP级别的参数 openGauss# ALTER SYSTEM SET paraname TO value;立刻生效(实际等待线程重新加载参数略有延迟)。 设置BACKEND级别的参数 openGauss# ALTER SYSTEM SET paraname TO value;在下次会话中生效。 注意 使用方式一和方式二设置参数时若所设参数不属于当前环境数据库会提示参数不在支持范围内的相关信息。 130.3 操作步骤
使用方式一设置数据库参数以在数据库主节点设置archive_mode参数为例。 以操作系统用户omm登录数据库主节点。 查看archive_mode参数。 cat /gaussdb/data/dbnode/postgresql.conf | grep archive_modearchive_mode onon表示日志要进行归档操作。 设置archive_mode参数为off关闭日志的归档操作。 gs_guc set -D /gaussdb/data/dbnode -c archive_modeoff说明 可以使用以下命令在数据库节点上设置archive_mode参数为off。 gs_guc set -N all -I all -c archive_modeoff重启数据库使参数生效。 gs_om -t stop gs_om -t start使用如下命令连接数据库。 gsql -d postgres -p 8000postgres为需要连接的数据库名称8000为数据库主节点的端口号。 连接成功后系统显示类似如下信息 gsql((openGauss x.x.x build f521c606) compiled at 2021-09-16 14:55:22 commit 2935 last mr 6385 release)
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type help for help.openGauss# 检查参数设置的正确性。 openGauss# SHOW archive_mode;archive_mode
--------------off
(1 row)使用方式二设置参数以在数据库主节点设置authentication_timeout参数为例。 以操作系统用户omm登录数据库主节点。 查看authentication_timeout参数。 cat /gaussdb/data/dbnode/postgresql.conf | grep authentication_timeoutauthentication_timeout 1min设置authentication_timeout参数为59s。 gs_guc reload -N all -I all -c authentication_timeout 59sTotal instances: 2. Failed instances: 0.
Success to perform gs_guc!说明 可以使用以下命令在数据库节点上设置authentication_timeout参数为59s。 gs_guc reload -N all -I all -c authentication_timeout 59s使用如下命令连接数据库。 gsql -d postgres -p 8000postgres为需要连接的数据库名称8000为数据库主节点的端口号。 连接成功后系统显示类似如下信息 gsql((openGauss x.x.x build f521c606) compiled at 2021-09-16 14:55:22 commit 2935 last mr 6385 release)
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type help for help.openGauss# 检查参数设置的正确性。 openGauss# SHOW authentication_timeout;authentication_timeout
------------------------59s
(1 row)使用方式三设置参数以设置explain_perf_mode参数为例。 以操作系统用户omm登录数据库主节点。 使用如下命令连接数据库。 gsql -d postgres -p 8000postgres为需要连接的数据库名称8000为数据库主节点的端口号。 连接成功后系统显示类似如下信息 gsql((openGauss x.x.x build f521c606) compiled at 2021-09-16 14:55:22 commit 2935 last mr 6385 release)
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type help for help.openGauss# 查看explain_perf_mode参数。 openGauss# SHOW explain_perf_mode;explain_perf_mode
-------------------normal
(1 row)设置explain_perf_mode参数。 使用以下任意方式进行设置 设置数据库级别的参数 openGauss# ALTER DATABASE postgres SET explain_perf_mode TO pretty;当结果显示为如下信息则表示设置成功。 ALTER DATABASE在下次会话中生效。 设置用户级别的参数 openGauss# ALTER USER omm SET explain_perf_mode TO pretty;当结果显示为如下信息则表示设置成功。 ALTER ROLE在下次会话中生效。 设置会话级别的参数 openGauss# SET explain_perf_mode TO pretty;当结果显示为如下信息则表示设置成功。 SET检查参数设置的正确性。 openGauss# SHOW explain_perf_mode;explain_perf_mode
--------------pretty
(1 row)130.4 示例 示例1使用方式一修改openGauss数据库主节点的最大连接数。 以操作系统用户omm登录数据库主节点。 使用如下命令连接数据库。 gsql -d postgres -p 8000postgres为需要连接的数据库名称8000为数据库主节点的端口号。 连接成功后系统显示类似如下信息 gsql((openGauss x.x.x build f521c606) compiled at 2021-09-16 14:55:22 commit 2935 last mr 6385 release)
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type help for help.openGauss# 查看最大连接数。 openGauss# SHOW max_connections;max_connections
-----------------200
(1 row)使用如下命令退出数据库。 openGauss# \q修改openGauss数据库主节点的最大连接数。 gs_guc set -N all -I all -c max_connections 800重启openGauss。 gs_om -t stop gs_om -t start使用如下命令连接数据库。 gsql -d postgres -p 8000postgres为需要连接的数据库名称8000为数据库主节点的端口号。 连接成功后系统显示类似如下信息 gsql((openGauss x.x.x build f521c606) compiled at 2021-09-16 14:55:22 commit 2935 last mr 6385 release)
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type help for help.openGauss# 查看最大连接数。 openGauss# SHOW max_connections;max_connections
-----------------800
(1 row)示例2使用方式二设置数据库主节点的客户端认证最长时间参数“authentication_timeout” 以操作系统用户omm登录数据库主节点。 使用如下命令连接数据库。 gsql -d postgres -p 8000postgres为需要连接的数据库名称8000为数据库主节点的端口号。 连接成功后系统显示类似如下信息 gsql((openGauss x.x.x build f521c606) compiled at 2021-09-16 14:55:22 commit 2935 last mr 6385 release)
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type help for help.openGauss# 查看客户端认证的最长时间。 openGauss# SHOW authentication_timeout;authentication_timeout
------------------------1min
(1 row)使用如下命令退出数据库。 openGauss# \q修改数据库主节点的客户端认证最长时间。 gs_guc reload -N all -I all -c authentication_timeout 59s使用如下命令连接数据库。 gsql -d postgres -p 8000postgres为需要连接的数据库名称8000为数据库主节点的端口号。 连接成功后系统显示类似如下信息 gsql((openGauss x.x.x build f521c606) compiled at 2021-09-16 14:55:22 commit 2935 last mr 6385 release)
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type help for help.openGauss# 查看客户端认证的最长时间。 openGauss# SHOW authentication_timeout;authentication_timeout
------------------------59s
(1 row)示例3修改openGauss数据库节点的最大连接数。 以操作系统用户omm登录数据库主节点。 使用如下命令连接数据库。 gsql -d postgres -p 8000postgres为需要连接的数据库名称8000为数据库主节点的端口号。 连接成功后系统显示类似如下信息 gsql((openGauss x.x.x build f521c606) compiled at 2021-09-16 14:55:22 commit 2935 last mr 6385 release)
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type help for help.openGauss# 查看最大连接数。 openGauss# SHOW max_connections;max_connections
-----------------200
(1 row)使用如下命令退出数据库。 openGauss# \q修改openGauss数据库节点的最大连接数。 gs_guc set -N all -I all -c max_connections 500重启openGauss。 gs_om -t stop
gs_om -t start使用如下命令连接数据库。 gsql -d postgres -p 8000postgres为需要连接的数据库名称8000为数据库主节点的端口号。 连接成功后系统显示类似如下信息 gsql((openGauss x.x.x build f521c606) compiled at 2021-09-16 14:55:22 commit 2935 last mr 6385 release)
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type help for help.openGauss# 查看最大连接数。 openGauss# SHOW max_connections;max_connections
-----------------500
(1 row)示例4设置数据库节点的客户端认证最长时间参数“authentication_timeout” 以操作系统用户omm登录数据库主节点。 使用如下命令连接数据库。 gsql -d postgres -p 8000postgres为需要连接的数据库名称8000为数据库主节点的端口号。 连接成功后系统显示类似如下信息 gsql((openGauss x.x.x build f521c606) compiled at 2021-09-16 14:55:22 commit 2935 last mr 6385 release)
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type help for help.openGauss# 查看客户端认证的最长时间。 openGauss# SHOW authentication_timeout;authentication_timeout
------------------------1min
(1 row)使用如下命令退出数据库。 openGauss# \q修改openGauss数据库节点的客户端认证最长时间。 gs_guc reload -N all -I all -c authentication_timeout 30s使用如下命令连接数据库。 gsql -d postgres -p 8000postgres为需要连接的数据库名称8000为数据库主节点的端口号。 连接成功后系统显示类似如下信息 gsql((openGauss x.x.x build f521c606) compiled at 2021-09-16 14:55:22 commit 2935 last mr 6385 release)
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type help for help.openGauss# 查看客户端认证的最长时间。 openGauss# SHOW authentication_timeout;authentication_timeout
------------------------30s
(1 row)点赞你的认可是我创作的动力 ⭐️ 收藏你的青睐是我努力的方向 ✏️ 评论你的意见是我进步的财富