Linux上的PostgreSQL数据库默认位置 [英] PostgreSQL database default location on Linux

查看:2062
本文介绍了Linux上的PostgreSQL数据库默认位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

What is the default directory where PostgreSQL will keep all databases on Linux?

推荐答案

" postgresql将保存所有数据库的目录"(和配置)称为数据目录",与PostgreSQL所调用的相对应(有点令人困惑)"数据库集群",它是与分布式计算无关,它仅表示由PostgreSQL服务器管理的一组数据库和相关对象.

The "directory where postgresql will keep all databases" (and configuration) is called "data directory" and corresponds to what PostgreSQL calls (a little confusingly) a "database cluster", which is not related to distributed computing, it just means a group of databases and related objects managed by a PostgreSQL server.

数据目录的位置取决于分布.如果您是从源代码安装的,则默认值为/usr/local/pgsql/data:

The location of the data directory depends on the distribution. If you install from source, the default is /usr/local/pgsql/data:

就文件系统而言,数据库 群集将是一个目录 将在其下存储所有数据. 我们称其为数据目录或 数据区.这完全取决于你 您选择存储数据的位置. 尽管没有默认值, 诸如 /usr/local/pgsql/data或 /var/lib/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服务器的实例与一个集群相关联;可以将其数据目录的位置传递到服务器守护程序(" postmaster "或 postgres )) >命令行选项,或通过PGDATA环境变量(通常在运行用户的范围内,通常为postgres).通常,您可以看到正在运行的服务器,如下所示:

Besides, an instance of a running PostgreSQL server is associated to one cluster; the location of its data directory can be passed to the server daemon ("postmaster" or "postgres") in the -D command line option, or by the PGDATA environment variable (usually in the scope of the running user, typically postgres). You can usually see the running server with something like this:

[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端口.

Note that it is possible, though not very frequent, to run two instances of the same PostgreSQL server (same binaries, different processes) that serve different "clusters" (data directories). Of course, each instance would listen on its own TCP/IP port.

这篇关于Linux上的PostgreSQL数据库默认位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆