1

primary-standby我有一个遵循架构以高可用性模式运行的多节点 Postgres 集群。

postgres-0                                               5/5     Running            0          111s
postgres-1                                               5/5     Running            0          3m4s
postgres-monitor-0                                       4/4     Running            0          13m

其中一个primarypod 处于模式,另一个 pod 处于从某种方式standby复制的模式下,而待机保持在该模式下。primarysynchronousread-only

我正在运行以下 CRUD 命令来更新本地文件:

-- Update pg_config to allow access to the users
create table hba ( lines text );
copy hba from '/pgsql/data/pg_hba.conf';

insert into hba (lines) values ('host     all              all       0.0.0.0/0    md5');
insert into hba (lines) values ('host     all              all       ::/0         md5');

copy hba to '/pgsql/data/pg_hba.conf';

-- reload the config
select pg_reload_conf();

问题是,文件在节点上而不是在节点上/pgsql/data/pg_hba.conf更新(因为所有查询都转到主节点),这意味着当节点关闭时,配置更改将重置为原始值。primarystandbyprimary

4

1 回答 1

0

我必须补充一点,这种方法对我来说看起来不太安全。

您不能在备用服务器上使用表(甚至是临时表)。我认为解决这个问题的最简单方法是编写PL/PerlUPL/PythonU来进行必要的文件修改。您还必须调用该函数pg_reload_comf()来激活修改。

于 2022-02-04T05:12:20.097 回答