Postgresql где установлен linux

default location of postgresql when installing through apt-get

Now I can understand why postgresql.conf and other configuration files are stored in /etc/postgresql/9.3/main. After all, /etc is where configuration files are stored in a linux system. However, why place the database storage area in /var/lib? I can understand /var, since that is the place for nonstatic data and databases are nonstatic. But why /var/lib in particular? Further, I believe that /bin is for programs required for boot. /usr/bin is for programs included in the distribution. and /usr/local/bin should be for programs not included in the distribution but available for system-wide use. And thus since postgresql is intended for system-wide use, it should be available in /usr/local/bin. Yet, they place it in /usr/lib, which I have no idea why. Why do I ask this question? Because without order and structure, it is difficult to remember the location of programs you use everyday.

1 Answer 1

In the Filesystem Hierarchy Standard, `/var/lib/ is stated as (in italic the most important part):

5.8.1 Purpose

This hierarchy holds state information pertaining to an application or the system. State information is data that programs modify while they run, and that pertains to one specific host. Users must never need to modify files in /var/lib to configure a package’s operation.

State information is generally used to preserve the condition of an application (or a group of inter-related applications) between invocations and between different instances of the same application. State information should generally remain valid after a reboot, should not be logging output, and should not be spooled data.

An application (or a group of inter-related applications) must use a subdirectory of /var/lib for its data. There is one required subdirectory, /var/lib/misc, which is intended for state files that don’t need a subdirectory; the other subdirectories should only be present if the application in question is included in the distribution.

/var/lib/ is the location that must be used for all distribution packaging support. Different distributions may use different names, of course.

In short: /var/lib/ is for data that is used locally.

Читайте также:  Служба adl astra linux

So it makes perfect sense to put a database’s data into /var/lib// directory but. the FHS is a standard created mostly for use by distributions. As a user you are free to put your data wherever you want and it is mostly a matter of opinion.

You are misunderstanding the word «local». /usr/local/bin/ is not for system software but for your own software (basically anything with «local» in must never be touched by the system. As explained by FHS:

4.9.1 Purpose

The /usr/local hierarchy is for use by the system administrator when installing software locally. It needs to be safe from being overwritten when the system software is updated. It may be used for programs and data that are shareable amongst a group of hosts, but not found in /usr. Locally installed software must be placed within /usr/local rather than /usr unless it is being installed to replace or upgrade software in /usr.

An executable installed from system software should never go to anything local.

4.7.1 Purpose

/usr/lib includes object files, libraries, and internal binaries that are not intended to be executed directly by users or shell scripts. Applications may use a single subdirectory under /usr/lib. If an application uses a subdirectory, all architecture-dependent data exclusively used by the application must be placed within that subdirectory.

postgressql is probably a daemon started at boot? If so it makes sense to put it here. You are not suppose to use the command yourself but start a service. The files in /usr/lib/ tend to have their own user and group and/or a daemon that restricts access to /var/lib (only mysqld can access /var/lib/mysql/ for instance; this will be the same for postgressql)

Читайте также:  Linux red hat system administration

Источник

PostgreSQL database default location on Linux

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.

The location of the data directory depends on the distribution. If you install from source, the default is /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)

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 

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.

Источник

Оцените статью
Adblock
detector