数据库参数修改
单节点环境
会话级设置
--以deadlock_timeout为列 --设置后仅在当前会话生效 SET deadlock_timeout ='2s';
复制
全局设置
--以deadlock_timeout为列 --设置后全局生效 ALTER system SET deadlock_timeout ='2s'; SELECT pg_reload_conf();
复制
需要重启数据库实例的参数设置
--部分参数设置是需要重启数据库才能生效的,如果在会话级进行设置,会提示有相关ERROR提示 antdb=# SET max_connections=123; ERROR: parameter "max_connections" cannot be changed without restarting the server --对于需要重启数据库才能生效的参数,需要修改数据库目录中postgresql.conf文件,并重启数据库 --这类参数的影响范围是全局
复制
注意:
对于全局设置的参数,请注意主备节点要保持一致。
高可用集群环境
参数的获取有一定的优先级:edit-config 修改(adbhamgrctl -c /etc/adbhamgr.yaml edit-config
) > adbhamgr 的本地配置(/etc/adbhamgr.yaml
) > postgresql.auto.conf > postgresql.conf > postgresql.base.conf。
对于参数的修改,有以下几种情形。
会话级设置
--以deadlock_timeout为列 --设置后仅在当前会话生效 SET deadlock_timeout ='2s';
复制
全局设置
通过 adbhamgrctl edit-config
命令可以更改 adbdcs 中的共享配置,全局修改参数,如果需要重启生效,则修改完成重启集群即可。
--通过edit-config命令会影响集群中所有节点 --执行如下命令进入修改: adbhamgrctl -c /etc/adbhamgr.yml edit-config --执行上述命令后,显示DCS中的共享配置,如下: loop_wait: 5 master_start_timeout: 300 maximum_lag_on_failover: 54023568112 postgresql: parameters: hot_standby: 'on' listen_addresses: '*' log_destination: csvlog log_directory: /data1/antdb/pg_log max_connections: 100000 max_wal_senders: 10 port: 55551 wal_keep_segments: 10 wal_level: logical use_pg_rewind: true retry_timeout: 5 synchronous_mode: true ttl: 15 --此时可在postgresql的parameters下进行修改或者添加相关参数(类似vim编辑器,按i进入修改),如:max_connections: 20000 --修改完毕后,类似vim编辑器,输入:wq! 退出编辑。 --此时界面显示修改项目,根据提示,输入y保存修改: --- +++ @@ -8,7 +8,7 @@ listen_addresses: '*' log_destination: csvlog log_directory: /data1/antdb/pg_log - max_connections: 100000 + max_connections: 20000 max_wal_senders: 10 port: 55551 wal_keep_segments: 10 Apply these changes? [y/N]: --输入Y,会自动reload参数。
复制
对于不需要重启生效的参数,则通过上面的修改即可生效。
对于需要重启的参数,例如 max_connections,会话级设置会提示需要重启,则还需要执行 adbhamgrctl restart
重启集群:
--部分参数设置是需要重启数据库才能生效的,如果在会话级进行设置,会提示有相关ERROR提示 antdb=# SET max_connections=123; ERROR: parameter "max_connections" cannot be changed without restarting the server
复制
执行 adbhamgrctl restart 命令重启集群:
adbhamgrctl -c /etc/adbhamgr.yml restart postgres-cluster --force
复制
AntDB 集中式数据库参数列表请参考附录。
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。