首页 > 数据库 > > 配置运行参数-重设参数
GaussDB 200提供了多种修改GUC参数的方法,用户可以方便的针对数据库、用户、会话进行设置。
具体参数说明请参见GUC参数说明。
GaussDB 200提供了六类GUC参数,具体分类和设置方式请参考表1:
参数类型 | 说明 | 设置方式 |
|---|---|---|
INTERNAL | 固定参数,在创建数据库的时候确定,用户无法修改,只能通过show语法或者pg_settings视图进行查看。 | 无 |
POSTMASTER | 数据库服务端参数,在数据库启动时确定,可以通过配置文件指定。 | 支持表2中的方式一。 |
SIGHUP | 数据库全局参数,可在数据库启动时设置或者在数据库启动后,发送指令重新加载。 | 支持表2中的方式一、方式二。 |
BACKEND | 会话连接参数。在创建会话连接时指定,连接建立后无法修改。连接断掉后参数失效。内部使用参数,不推荐用户设置。 | 支持表2中的方式一、方式二。 说明: 设置该参数后,下一次建立会话连接时生效。 |
SUSET | 数据库管理员参数。可在数据库启动时、数据库启动后或者数据库管理员通过SQL进行设置。 | 支持表2中的方式一、方式二或由数据库管理员通过方式三设置。 |
USERSET | 普通用户参数。可被任何用户在任何时刻设置。 | 支持表2中的方式一、方式二或方式三设置。 |
序号 | 设置方法 |
|---|---|
方式一 |
|
方式二 | 说明: 使用以下命令在CN和DN上同时设置某个参数。 |
方式三 | 修改指定数据库,用户,会话级别的参数。
|
使用方式一设置数据库参数,以在CN设置archive_mode参数为例。
cat ${BIGDATA_DATA_HOME}/mppdb/data1/coordinator/postgresql.conf | grep archive_modearchive_mode = onon表示日志要进行归档操作。
gs_guc set -Z coordinator -D ${BIGDATA_DATA_HOME}/mppdb/data1/coordinator -c "archive_mode=off"说明:
可以使用以下命令在所有CN和DN上设置archive_mode参数为off。
gs_guc set -Z coordinator -Z datanode -N all -I all -c "archive_mode=off"重启数据库使参数生效。
gs_om -t stop && gs_om -t start使用如下命令连接数据库。
gsql -d postgres -p 25308postgres为需要连接的数据库名称,25308为CN的端口号。
连接成功后,系统显示类似如下信息:
gsql ((GaussDB Kernel V300R002C00 build 50dc16a6) compiled at 2019-01-29 05:49:21 commit 1071 last mr 1373)
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
postgres=#
SHOW archive_mode;
archive_mode
--------------
off
(1 row)
使用方式二设置参数,以在CN设置authentication_timeout参数为例。
cat ${BIGDATA_DATA_HOME}/mppdb/data1/coordinator/postgresql.conf | grep authentication_timeoutauthentication_timeout = 1min设置authentication_timeout参数为59s。
gs_guc reload -Z coordinator -N all -I all -c "authentication_timeout = 59s"
Total instances: 2. Failed instances: .
Success to perform gs_guc!
说明:可以使用以下命令在所有CN和DN上设置authentication_timeout参数为59s。
gs_guc reload -Z coordinator -Z datanode -N all -I all -c "authentication_timeout = 59s"使用如下命令连接数据库。
gsql -d postgres -p 25308postgres为需要连接的数据库名称,25308为CN的端口号。
连接成功后,系统显示类似如下信息:
gsql ((GaussDB Kernel V300R002C00 build 50dc16a6) compiled at 2019-01-29 05:49:21 commit 1071 last mr 1373)
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
postgres=#
SHOW authentication_timeout;
authentication_timeout
------------------------
59s
(1 row)
使用方式三设置参数,以设置explain_perf_mode参数为例。
gsql -d postgres -p 25308postgres为需要连接的数据库名称,25308为CN的端口号。
连接成功后,系统显示类似如下信息:
gsql ((GaussDB Kernel V300R002C00 build 50dc16a6) compiled at 2019-01-29 05:49:21 commit 1071 last mr 1373)
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
postgres=#
SHOW explain_perf_mode;
explain_perf_mode
-------------------
normal
(1 row)
使用以下任意方式进行设置:
ALTER DATABASE postgres SET explain_perf_mode TO pretty;当结果显示为如下信息,则表示设置成功。
ALTER DATABASE在下次会话中生效。
ALTER USER omm SET explain_perf_mode TO pretty;当结果显示为如下信息,则表示设置成功。
ALTER ROLE在下次会话中生效。
SET explain_perf_mode TO pretty;当结果显示为如下信息,则表示设置成功。
SET检查参数设置的正确性。
SHOW explain_perf_mode;
explain_perf_mode
--------------
pretty
(1 row)
gsql -d postgres -p 25308postgres为需要连接的数据库名称,25308为CN的端口号。
连接成功后,系统显示类似如下信息:
gsql ((GaussDB Kernel V300R002C00 build 50dc16a6) compiled at 2019-01-29 05:49:21 commit 1071 last mr 1373)
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
postgres=#
SHOW max_connections;
max_connections
-----------------
200
(1 row)
\q修改集群所有CN的最大连接数。
gs_guc set -Z coordinator -N all -I all -c "max_connections = 800"重启集群。
gs_om -t stop && gs_om -t start使用如下命令连接数据库。
postgres为需要连接的数据库名称,25308为CN的端口号。连接成功后,系统显示类似如下信息:
gsql ((GaussDB Kernel V300R002C00 build 50dc16a6) compiled at 2019-01-29 05:49:21 commit 1071 last mr 1373)
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
postgres=#
SHOW max_connections;
max_connections
-----------------
800
(1 row)
gsql -d postgres -p 25308postgres为需要连接的数据库名称,25308为CN的端口号。
连接成功后,系统显示类似如下信息:
gsql ((GaussDB Kernel V300R002C00 build 50dc16a6) compiled at 2019-01-29 05:49:21 commit 1071 last mr 1373)
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
postgres=#
SHOW authentication_timeout;
authentication_timeout
------------------------
1min
(1 row)
\q修改集群所有CN的客户端认证最长时间。
gs_guc reload -Z coordinator -N all -I all -c "authentication_timeout = 59s"使用如下命令连接数据库。
gsql -d postgres -p 25308postgres为需要连接的数据库名称,25308为CN的端口号。
连接成功后,系统显示类似如下信息:
gsql ((GaussDB Kernel V300R002C00 build 50dc16a6) compiled at 2019-01-29 05:49:21 commit 1071 last mr 1373)
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
postgres=#
SHOW authentication_timeout;
authentication_timeout
------------------------
59s
(1 row)
gsql -d postgres -p 25308postgres为需要连接的数据库名称,25308为CN的端口号。
连接成功后,系统显示类似如下信息:
gsql ((GaussDB Kernel V300R002C00 build 50dc16a6) compiled at 2019-01-29 05:49:21 commit 1071 last mr 1373)
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
postgres=#
SHOW max_connections;
max_connections
-----------------
200
(1 row)
\q修改集群所有CN和DN的最大连接数。
gs_guc set -Z coordinator -Z datanode -N all -I all -c "max_connections = 500"重启集群。
gs_om -t stop
gs_om -t start
gsql -d postgres -p 25308postgres为需要连接的数据库名称,25308为CN的端口号。
连接成功后,系统显示类似如下信息:
gsql ((GaussDB Kernel V300R002C00 build 50dc16a6) compiled at 2019-01-29 05:49:21 commit 1071 last mr 1373)
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
postgres=#
SHOW max_connections;
max_connections
-----------------
500
(1 row)
gsql -d postgres -p 25308postgres为需要连接的数据库名称,25308为CN的端口号。
连接成功后,系统显示类似如下信息:
gsql ((GaussDB Kernel V300R002C00 build 50dc16a6) compiled at 2019-01-29 05:49:21 commit 1071 last mr 1373)
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
postgres=#
SHOW authentication_timeout;
authentication_timeout
------------------------
1min
(1 row)
\q修改集群所有CN和DN的客户端认证最长时间。
gs_guc reload -Z coordinator -Z datanode -N all -I all -c "authentication_timeout = 30s"使用如下命令连接数据库。
gsql -d postgres -p 25308postgres为需要连接的数据库名称,25308为CN的端口号。
连接成功后,系统显示类似如下信息:
gsql ((GaussDB Kernel V300R002C00 build 50dc16a6) compiled at 2019-01-29 05:49:21 commit 1071 last mr 1373)
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.
postgres=#
SHOW authentication_timeout;
authentication_timeout
------------------------
30s
(1 row)
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69959250/viewspace-3133091/ ,如需转载,请注明出处,否则将追究法律责任。