postgresql.conf 文件在 TimescaleDB 官方 Docker 镜像中全部被注释了,为什么?

huangapple go评论132阅读模式
英文:

postgresql.conf file on TimescaleDB official Docker image is all commented, why?

问题

The postgresql.conf文件位于/var/lib/postgresql/data中,全部都是注释的(我已经检查过)

但是当我尝试使用以下方式获取一些配置信息时:SELECT current_setting('autovacuum')

为什么会这样?我可以编辑这个文件吗,还是TimescaleDB插件中有另一个文件?

英文:

The postgresql.conf file found in /var/lib/postgresql/data is all commented (I checked)
like this:

postgresql.conf 文件在 TimescaleDB 官方 Docker 镜像中全部被注释了,为什么?

but when I try to get some configurations using: SELECT current_setting('autovacuum')

postgresql.conf 文件在 TimescaleDB 官方 Docker 镜像中全部被注释了,为什么?

why is that? Can I edit the file or there is another file on the TimescaleDB plugin?

答案1

得分: 1

这是正常行为,因为每个配置已经有一个默认值。要覆盖特定行为,您需要挂载您的配置文件。

如果您只是在测试一个配置,您可以通过 bash 进入容器:

docker exec -it your-timescale-container bash

然后,您可以重新启动服务:

service postgresql restart

如果您想要同步配置文件从您的机器,可以使用以下方法:

要在使用 TimescaleDB-HA Docker 镜像时设置 PostgreSQL 配置,您可以按照以下步骤操作:

在您的主机上创建一个新目录以存储 PostgreSQL 配置文件。例如,您可以在您的主目录下创建一个名为 pg_conf 的目录:

mkdir ~/pg_conf

将您的 postgresql.conf 文件复制到 pg_conf 目录。

启动 timescaledb-ha 容器并将 pg_conf 目录挂载到容器中。您可以使用 -v 选项将目录挂载为一个卷。例如:

docker run --name my-timescaledb-ha -v ~/pg_conf:/etc/postgresql/postgresql.conf.d -p 5432:5432 -e POSTGRES_PASSWORD=mysecretpassword timescale/timescaledb-ha

此命令将启动一个名为 my-timescaledb-ha 的新 TimescaleDB-HA 容器,并将主机上的 pg_conf 目录挂载到容器内的 /etc/postgresql/postgresql.conf.d 目录。

您的 PostgreSQL 配置现在应该应用在容器内。您可以通过检查容器内的 postgresql.conf 文件来确认这一点:

docker exec -it my-timescaledb-ha cat /etc/postgresql/postgresql.conf.d/postgresql.conf

这个命令将显示容器内 postgresql.conf 文件的内容。

就是这样!您现在可以根据需要启动和停止容器,您的 PostgreSQL 配置将在容器重新启动时保留。

英文:

This is the regular behavior as every configuration has already a default. To override some specific behavior, you'll need to mount your config file.

If you're just testing a configuration, you can join the container via bash:

docker exec -it your-timescale-container bash

Then, you can restart the service:

service postgresql restart

If you want to sync a configuration from your machine, use the following:

To set the PostgreSQL configuration when using the TimescaleDB-HA Docker image, you can follow these steps:

Create a new directory on your host machine to store the PostgreSQL configuration file. For example, you can create a directory named pg_conf in your home directory:

mkdir ~/pg_conf

Copy your postgresql.conf file to the pg_conf directory.

Start the timescaledb-ha container and mount the pg_conf directory to the container. You can use the -v option to mount the directory as a volume. For example:

docker run --name my-timescaledb-ha -v ~/pg_conf:/etc/postgresql/postgresql.conf.d -p 5432:5432 -e POSTGRES_PASSWORD=mysecretpassword timescale/timescaledb-ha

This command will start a new TimescaleDB-HA container named my-timescaledb-ha and mount the pg_conf directory on the host machine to the /etc/postgresql/postgresql.conf.d directory inside the container.

Your PostgreSQL configuration should now be applied inside the container. You can confirm this by checking the postgresql.conf file inside the container:

docker exec -it my-timescaledb-ha cat /etc/postgresql/postgresql.conf.d/postgresql.conf

This command will display the contents of the postgresql.conf file inside the container.

That's it! You can now start and stop the container as needed, and your PostgreSQL configuration will persist across container restarts.

答案2

得分: 1

PostgreSQL配置文件postgresql.conf包含了PostgreSQL服务器的默认设置和用户自定义设置。如果某个设置被注释掉,这意味着该特定设置正在使用默认值。

然而,被注释掉的事实很奇怪,请仔细检查。

在您的情况下,postgresql.conf文件中的所有行都被注释掉,这意味着PostgreSQL正在使用默认设置来配置所有内容。autovacuum的默认值是true,所以即使在postgresql.conf文件中被注释掉,服务器仍然会默认启用自动清理。

英文:

The PostgreSQL configuration file postgresql.conf contains default settings and user-defined settings for the PostgreSQL server. If a setting is commented out, it means that the default value for that particular setting is being used.

Still, the fact that is commented is strange, check it thoroughly.

In your case, all the lines in the postgresql.conf file are commented, which means PostgreSQL is using the default settings for all configurations. The default value for autovacuum is true, so even if it's commented out in the postgresql.conf file, the server will still have autovacuum enabled by default.

huangapple
  • 本文由 发表于 2023年3月7日 19:06:03
  • 转载请务必保留本文链接:https://go.coder-hub.com/75661188.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定