重庆思庄Oracle、Redhat认证学习论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 701|回复: 0
打印 上一主题 下一主题

openGauss如何修改数据库参数

[复制链接]
跳转到指定楼层
楼主
发表于 2022-11-17 16:10:18 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 郑全 于 2022-11-17 16:23 编辑


我们知道ORACLE修改参数,可以使用命令修改:
alter system set parameter=valuescope=memory|spfile|both;
那么,OPENGAUSS呢,

答案是肯定的,一样可以修改参数,只是使用的一个单独的一个工具gs_guc来实现,见下面例子:

1.语法
   gs_guc 同时修改配置文件中参数(postgresql.conf)

只是修改参数值
   gs_guc set [-N NODE-NAME] [-I INSTANCE-NAME | -D DATADIR] -c "parameter =value"

将已设置的参数值修改为默认值
   gs_guc [ set | reload ] [-N NODE-NAME] [-I INSTANCE-NAME | -D DATADIR] -c "parameter"

2.命令参考
  • set
       表示只修改配置文件中的参数。
  • reload
       表示修改配置文件中的参数,同时发送信号量给数据库进程,使其重新加载配置文件。
  • -N
      需要设置的主机名称。
      取值范围:已有主机名称。
      当参数取值为ALL时,表示设置openGauss中所有的主机。
  • -I INSTANCE-NAME
      需要设置的实例名称。
      取值范围:已有实例名称。
      当参数取值为ALL时,表示设置主机中所有的实例。
  • -D
      需要执行命令的openGauss实例路径。使用encrypt命令时,此参数表示指定的密码文件生成的路径。
      备注:-D 与"-I" 不能一块使用
  • -c parameter=value
   要设定的openGauss配置参数的名称和参数值。
       说明:
      如果参数是一个字符串变量,则使用-c parameter="'value'" 或者 使用 -c "parameter = 'value'"。
      当使用gs_guc      set/reload为"log_directory” 恢复默认值时,其默认值会被置为具体的data目录。
   取值范围:postgresql.conf中的所有参数。
  • -U, –keyuser=USER

3.例子
修改数据库允许的最大连接数为800注意:修改后需要重启数据库才能生效。

[omm@dbserver1 ~]$ gs_guc set  -I all -N all -c "max_connections=800"

--使用set

[omm@dbserver1 ~]$ gs_guc set  -I all -N all -c "enable_wdr_snapshot=on"
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!

--使用reload
[omm@dbserver1 ~]$ gs_guc reload  -I all -N all -c "max_connections=800"
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!

--修改后,查看postgresql.conf配置文件,发现参数值修改了。

[omm@dbserver1 db1]$ grep -i '^max_connection' postgresql.conf
max_connections = 800                   # (change requires restart)

--未重启前,进入数据库看看,还是以前的值,可以说明使用set,reload,都一样。
postgres=# show max_connections;
max_connections
-----------------
5000
(1 row)

--重启:

[omm@dbserver1 ~]$ gs_om -t restart
Stopping cluster.
=========================================
Successfully stopped cluster.
=========================================
End stop cluster.
Starting cluster.
=========================================
[SUCCESS] dbserver1
2022-11-17 15:04:59.534 6375dd1b.1 [unknown] 139759725995776 [unknown] 0 dn_6001_6002 01000  0 [BACKEND] WARNING:  Failed to initialize the memory protect for g_instance.attr.attr_storage.cstore_buffers (1024 Mbytes) or shared memory (3648 Mbytes) is larger.
[SUCCESS] dbserver2
2022-11-17 15:05:01.783 6375dd1d.1 [unknown] 140125177128704 [unknown] 0 dn_6001_6002 01000  0 [BACKEND] WARNING:  Failed to initialize the memory protect for g_instance.attr.attr_storage.cstore_buffers (1024 Mbytes) or shared memory (3648 Mbytes) is larger.
Waiting for check cluster state...
=========================================
Successfully started.

--重启后,修改值已经生效。
[omm@dbserver1 ~]$ gsql -d postgres -p 26000 -r
gsql ((openGauss 2.0.0 build 78689da9) compiled at 2021-03-31 21:04:03 commit 0 last mr  )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.

postgres=# show max_connections;
max_connections
-----------------
800
(1 row)
分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友
收藏收藏 支持支持 反对反对
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|手机版|小黑屋|重庆思庄Oracle、Redhat认证学习论坛 ( 渝ICP备12004239号-4 )

GMT+8, 2024-4-27 12:49 , Processed in 0.087670 second(s), 20 queries .

重庆思庄学习中心论坛-重庆思庄科技有限公司论坛

© 2001-2020

快速回复 返回顶部 返回列表