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

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

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

相关文章:

linux - epoll的实现有没有rfc?

linux - 如何在 Bash 中增加循环中的日期

regex - grep 可以删除上下文,但不能删除整行吗?

mongodb - 社交网络 : Hadoop, HBase、Spark over MongoDB 还是 Postgres?

java - dspace 导入元数据确认更改不应用它们

postgresql - PostGIS 不能与 psql 一起使用吗?

php - 如何在 centOS 6 中为 ffmpeg 设置一个 cron 作业

c - 信号中断 read()

java - Spring data JPA 不删除实体

angular - ASP.NET Core UTC 时间转本地时间