Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/321.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何通过Kubernetes statefulset环境变量更改Postgresql max_连接配置?_Postgresql_Kubernetes_Digital Ocean - Fatal编程技术网

如何通过Kubernetes statefulset环境变量更改Postgresql max_连接配置?

如何通过Kubernetes statefulset环境变量更改Postgresql max_连接配置?,postgresql,kubernetes,digital-ocean,Postgresql,Kubernetes,Digital Ocean,在Kubernetes中,ConfigMap中的环境变量不会更改PostgreSql pod中的max_connections属性。如何通过Kubernetes中的环境变量更改Postgres max_连接配置 我尝试了以下参数来配置Postgres 问题是,我可以使用数据库,用户和密码的参数和值设置为预期。但我需要更改max_连接配置。我做了相关研究,看起来PGOPTIONS是发送配置更改的正确选择。即使我尝试了PGOPTIONS和其他变体,对max_连接值也没有影响。我正在连接postgre

在Kubernetes中,ConfigMap中的环境变量不会更改PostgreSql pod中的max_connections属性。如何通过Kubernetes中的环境变量更改Postgres max_连接配置

我尝试了以下参数来配置Postgres

问题是,我可以使用数据库,用户和密码的参数和值设置为预期。但我需要更改max_连接配置。我做了相关研究,看起来PGOPTIONS是发送配置更改的正确选择。即使我尝试了PGOPTIONS和其他变体,对max_连接值也没有影响。我正在连接postgresql并执行SHOW MAX_CONNECTIONS查询,即使我在环境配置值中指定了1000,它也会显示100

我在digitalocean中使用Kubernetes 1.14

配置映射 状态集 我希望得到的最大连接值为1000。 但它看起来像是默认值100


任何日志中都没有错误。

Postgres docker image不允许通过环境变量设置
max\u connections
属性。您必须使用
postgresql.conf
文件来设置此类配置

使用自定义
postgresql.conf
文件创建ConfigMap。然后将ConfigMap装载到
/etc/postgresql/
目录中


您将找到一个示例
postgresql.conf
文件。

您需要扩展基本映像(postgres:latest)。使用自定义更改覆盖默认配置,然后启动postgres。

Postgresql docker image只能支持多个环境参数,
postgres\u PASSWORD
postgres\u USER
postgres\u DB
postgres\u INITDB\u ARGS
postgres\u INITDB\u WALDIR
POSTGRES\u HOST\u AUTH\u方法
PGDATA

如果要修改某些数据库配置参数,可以在kubernetes中使用
args

部署yaml文件部分

  containers:
  - args:
    - -c
    - max_connections=1000
    - -c
    - shared_buffers=1024MB
    envFrom:
    - configMapRef:
        name: postgres-config
    image: postgres
    imagePullPolicy: IfNotPresent
    name: postgres

当PGOPTIONS的环境变量指定max_connections时,会发生以下错误。因此,在args中指定它而不是在PGOPTIONS的环境变量中指定它是正确的

2020-05-27 06:51:55.327 UTC [62] FATAL:  parameter "max_connections" cannot be changed without restarting the server
psql: FATAL:  parameter "max_connections" cannot be changed without restarting the server


你好谢谢你的回答;但将configmap装载为配置会导致只读文件错误;仅供参考。对于只读错误,首先:,然后尝试不将conf文件放入数据装载中,然后“args”解决方案在这里工作…嗨。谢谢你的回答。我不明白他们为什么清楚地分享这些信息;没有通过env选项更改连接限制的权限。您能否分享一个关于我们不能在官方文件中使用env参数更改此信息的示例?我找不到。
  containers:
  - args:
    - -c
    - max_connections=1000
    - -c
    - shared_buffers=1024MB
    envFrom:
    - configMapRef:
        name: postgres-config
    image: postgres
    imagePullPolicy: IfNotPresent
    name: postgres
2020-05-27 06:51:55.327 UTC [62] FATAL:  parameter "max_connections" cannot be changed without restarting the server
psql: FATAL:  parameter "max_connections" cannot be changed without restarting the server
containers:
        - name: postgres
          image: postgres:latest
          args: ["-c", "max_connections=500"]