英文:
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:
but when I try to get some configurations using: SELECT current_setting('autovacuum')
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论