nee*_*zer 6 postgresql logging docker
如果你跑
docker run --rm postgres
Run Code Online (Sandbox Code Playgroud)
你得到:
The files belonging to this database system will be owned by user "postgres".
This user must also own the server process.
The database cluster will be initialized with locale "en_US.utf8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".
Data page checksums are disabled.
fixing permissions on existing directory /var/lib/postgresql/data ... ok
creating subdirectories ... ok
selecting default max_connections ... 100
selecting default shared_buffers ... 128MB
selecting dynamic shared memory implementation ... posix
creating configuration files ... ok
running bootstrap script ... ok
performing post-bootstrap initialization ... ok
syncing data to disk ... ok
WARNING: enabling "trust" authentication for local connections
You can change this by editing pg_hba.conf or using the option -A, or
--auth-local and --auth-host, the next time you run initdb.
Success. You can now start the database server using:
pg_ctl -D /var/lib/postgresql/data -l logfile start
****************************************************
WARNING: No password has been set for the database.
This will allow anyone with access to the
Postgres port to access your database. In
Docker's default configuration, this is
effectively any other container on the same
system.
Use "-e POSTGRES_PASSWORD=password" to set
it in "docker run".
****************************************************
waiting for server to start....2018-06-09 06:11:42.530 UTC [39] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2018-06-09 06:11:42.543 UTC [40] LOG: database system was shut down at 2018-06-09 06:11:42 UTC
2018-06-09 06:11:42.552 UTC [39] LOG: database system is ready to accept connections
done
server started
ALTER ROLE
/usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
2018-06-09 06:11:42.665 UTC [39] LOG: received fast shutdown request
waiting for server to shut down....2018-06-09 06:11:42.668 UTC [39] LOG: aborting any active transactions
2018-06-09 06:11:42.669 UTC [39] LOG: worker process: logical replication launcher (PID 46) exited with exit code 1
2018-06-09 06:11:42.672 UTC [41] LOG: shutting down
2018-06-09 06:11:42.687 UTC [39] LOG: database system is shut down
done
server stopped
PostgreSQL init process complete; ready for start up.
2018-06-09 06:11:42.776 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
2018-06-09 06:11:42.776 UTC [1] LOG: listening on IPv6 address "::", port 5432
2018-06-09 06:11:42.780 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2018-06-09 06:11:42.791 UTC [57] LOG: database system was shut down at 2018-06-09 06:11:42 UTC
2018-06-09 06:11:42.800 UTC [1] LOG: database system is ready to accept connections
Run Code Online (Sandbox Code Playgroud)
63 行启动信息日志,更不用说当您开始对其执行查询时的所有额外冗长内容。这是很好的信息,但是当您在本地开发中不断地一遍又一遍地启动和销毁相同的容器时,就会产生噪音。
我怎样才能“安静”这些日志?我不想完全摆脱它们......我仍然希望看到严重错误或严重警告。我还仍然希望它们定向到stdout
和stderr
,而不是一个单独的文件或作为一个独立的进程。
理想情况下,我正在寻找一个可以配置的环境变量,但我没有很幸运地在图像文档中找到一个环境变量。我在使用官方 RabbitMQ 镜像时遇到了类似的问题,并且能够通过以下方法让它变得更加安静:
RABBITMQ_SERVER_ADDITIONAL_ERL_ARGS=-rabbit log [{console,[{level,warning}]}]
Run Code Online (Sandbox Code Playgroud)
我正在寻找类似的东西,我可以用官方Postgres 图像来做。
我没有找到环境变量,但您可以使用配置文件来设置日志记录选项。
docker run -i --rm postgres:12.1 cat /usr/share/postgresql/postgresql.conf.sample > my-postgres.conf
echo "log_min_messages = error" >> my-postgres.conf
docker run --rm postgres -v "$PWD/my-postgres.conf":/etc/postgresql/postgresql.conf postgres -c 'config_file=/etc/postgresql/postgresql.conf'
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
2635 次 |
最近记录: |