简体   繁体   English

在服务器上运行的Postgres实例列表

[英]List of Postgres Instances running on a Server

I am working as a Postgres DBA at my organization. 我在我的组织中担任Postgres DBA。 We are currently working on Postgres 9.5 on SUSE Linux servers. 我们目前正在SUSE Linux服务器上使用Postgres 9.5。 I wanted a specific solution. 我想要一个特定的解决方案。 We have multiple SUSE Linux servers and each server can host one or more Postgres database. 我们有多台SUSE Linux服务器,每台服务器可以托管一个或多个Postgres数据库。 My requirement is I need to find the list of all the database available on a particular server irrespective of the database is up and running or its shut down. 我的要求是,我需要查找特定服务器上所有可用数据库的列表,而不管数据库是否已启动,正在运行或已关闭。

Is there any file or any location where Postgres keeps note of all the databases that is created on a server. Postgres是否在其中记录了在服务器上创建的所有数据库的任何文件或任何位置。 Is there a way I can get the required details without connecting to the Postgres instance and without running any PSQL commands? 有没有一种方法可以获取所需的详细信息,而无需连接到Postgres实例并且不运行任何PSQL命令?

If not what would be the best way to get the list. 如果不是,那将是获取列表的最佳方法。 Any hints, solutions and thoughts would help me to resolve this issue. 任何提示,解决方案和想法都将帮助我解决此问题。

Thanks a lot for the help in advance. 非常感谢您的事先帮助。

In PostgreSQL, a server process serves a database cluster , which physically resides in a data directory . 在PostgreSQL中,服务器进程为数据库集群提供服务,该集群实际上位于数据目录中

A PostgreSQL cluster contains several databases , all of which are shut down when the server process is shut down. PostgreSQL集群包含多个数据库 ,当服务器进程关闭时,所有数据库都将关闭。

So your question can be split into two parts: 因此,您的问题可以分为两部分:

  1. How to find out which database clusters are on a machine, regardless if they are started or not? 如何确定计算机上哪些数据库群集,无论它们是否已启动?

  2. How to find out all databases inside a cluster even if the cluster is shut down? 即使关闭群集,如何查找群集内的所有数据库?

There is no generic answer to the first question, since a data directory could in principle be everywhere and could belong to any user. 第一个问题没有通用答案,因为数据目录原则上可以在任何地方,并且可以属于任何用户。

You could get an approximation with 你可以得到一个近似值

find / -name PG_VERSION

but it is probably better to find a special solution that fits your setup (about which you didn't tell us). 但是最好找到适合您的设置的特殊解决方案(您没有告诉我们)。

The second question is even harder. 第二个问题更加困难。

To even get a list of numeric IDs, you would have to know all tablespace directories. 为了获得数字ID的列表,您必须知道所有表空间目录。 Those in the default tablespace are the names of the subdirectories in the base subdirectory of the data directory. 缺省表空间中的那些是数据目录的base子目录中子目录的名称。

In order to get the names of the databases you have to have the PostgreSQL server started, because it would be very hard to find the file that belongs to pg_database and parse it. 为了获得数据库的名称 ,你必须有PostgreSQL服务器启动,因为这将是很难找到属于文件pg_database并解析它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 同一台服务器上运行的2个MongoDB实例可以指向同一数据文件夹吗? - Can 2 MongoDB instances running on the same server point to the same data folder ? 在Linux中运行多个megasync实例 - Running Multiple Instances of megasync in Linux 在移动类型的服务器上安装postgres - postgres installation on server with Movable Type 同时运行的多个Python实例限制为35个 - Multiple instances of Python running simultaneously limited to 35 Linux Shell在运行一个应用程序的多个实例时挂起 - Linux shell hangs on running multiple instances of an application 在一台机器上运行两个 Pentaho 实例 - Running two Pentaho instances on one machine 一个内核上运行的进程的多个实例 - Multiple instances of a process running on single core 建议运行多个casperjs实例的环境是什么? - What is the recommended environment for running multiple casperjs instances? 使用Silverlight访问在Linux下运行的postgres数据库? - Access with Silverlight to a postgres database running under Linux? Postgres无法连接到数据库postgres:无法连接到服务器:没有这样的文件或目录? - Postgres could not connect to database postgres: could not connect to server: No such file or directory?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM