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

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 端口。

https://stackoverflow.com/questions/3004523/

相关文章:

python - 如何从外部访问本地 Django 网络服务器

python - 检查数字是 int 还是 float

python - 设置 Django 以使用 MySQL

linux - 如何管道或重定向 curl -v 的输出?

Python 请求 - 无连接适配器

python - Django 的嵌套 Meta 类是如何工作的?

c - 在 Linux 中启动 GDB 时如何传递命令行参数?

c - DESTDIR 和 PREFIX 的 make

linux - 如何在 vi 编辑器中删除选定的文本

linux - 如何将 AWS CLI 升级到最新版本?