gpt4 book ai didi

linux - Linux 上的 PostgreSQL 数据库默认位置

转载 作者:IT老高 更新时间:2023-10-28 12:23:48 30 4
gpt4 key购买 nike

PostgreSQL 在 Linux 上保存所有数据库的默认目录是什么?

最佳答案

postgresql 将保存所有数据库的目录”(和配置)称为“数据目录”,对应于 PostgreSQL 所称的(有点困惑)“database cluster”,即与分布式计算无关,它只是指由 PostgreSQL 服务器管理的一组数据库和相关对象。

数据目录的位置取决于分布。如果从源安装,默认为 /usr/local/pgsql/data:

In file system terms, a database cluster will be a single directory under which all data will be stored. We call this the data directory or data area. It is completely up to you where you choose to store your data. There is no default, although locations such as /usr/local/pgsql/data or /var/lib/pgsql/data are popular. (ref)

此外,一个正在运行的 PostgreSQL 服务器实例与一个集群相关联;其数据目录的位置可以通过 -D 命令行选项或通过 PGDATA 环境变量(通常在运行用户的范围内,通常是 postgres)。您通常可以通过以下方式查看正在运行的服务器:

[root@server1 ~]# ps auxw |  grep postgres | grep -- -D
postgres 1535 0.0 0.1 39768 1584 ? S May17 0:23 /usr/local/pgsql/bin/postgres -D /usr/local/pgsql/data

请注意,虽然不是很频繁,但可以运行同一 PostgreSQL 服务器的两个实例(相同的二进制文件,不同的进程),它们服务于不同的“集群”(数据目录)。当然,每个实例都会监听自己的 TCP/IP 端口。

关于linux - Linux 上的 PostgreSQL 数据库默认位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3004523/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com