Обсуждение: Why are data files stored in /var/lib

Поиск
Список
Период
Сортировка

Why are data files stored in /var/lib

От
"Charles Clavadetscher"
Дата:
Hello

I use version 9.5 on Linux Mint 17.3.

I had a discussion yesterday with some friends, who are sysadmins about the location of database files. In a default
installation
from a distribution (apt-get install) PostgreSQL creates a cluster unter /var/lib/. According to my colleagues /var/lib
shouldnot 
contain data that is supposed to last over time. I am aware that the location can be modified to suit the needs of
sysadminsas 
described under these links.

http://www.postgresql.org/docs/current/static/storage-file-layout.html
http://www.postgresql.org/docs/current/static/runtime-config-file-locations.html

In the first link there is a line stating that "A common location for PGDATA is /var/lib/pgsql/data". My question is if
thereis a 
specific reason for choosing /var/lib as the default for database file locations, some kind of best practices or alike.
Iassume 
that there have been discussions on the topic?

Thank you and enjoy the weekend.
Charles




Re: Why are data files stored in /var/lib

От
Manuel Gómez
Дата:
On Fri, Apr 29, 2016 at 11:00 PM, Charles Clavadetscher
<clavadetscher@swisspug.org> wrote:
> I had a discussion yesterday with some friends, who are sysadmins about the location of database files. In a default
installation
> from a distribution (apt-get install) PostgreSQL creates a cluster unter /var/lib/. According to my colleagues
/var/libshould not 
> contain data that is supposed to last over time.

Your sysadmin friends should read the excellent
http://www.pathname.com/fhs/pub/fhs-2.3.html#VARLIBVARIABLESTATEINFORMATION

Filesystem Hierarchy Standard

Chapter 5. The /var Hierarchy

Purpose

/var contains variable data files. This includes spool directories and
files, administrative and logging data, and transient and temporary
files.

Some portions of /var are not shareable between different systems. For
instance, /var/log, /var/lock, and /var/run. Other portions may be
shared, notably /var/mail, /var/cache/man, /var/cache/fonts, and
/var/spool/news.

/var is specified here in order to make it possible to mount /usr
read-only. Everything that once went into /usr that is written to
during system operation (as opposed to installation and software
maintenance) must be in /var.

[…]

/var/lib : Variable state information

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.


Re: Why are data files stored in /var/lib

От
"Charles Clavadetscher"
Дата:
Hello Manuel

> -----Original Message-----
> From: Manuel Gómez [mailto:targen@gmail.com]
> Sent: Samstag, 30. April 2016 05:45
> To: Charles Clavadetscher <clavadetscher@swisspug.org>
> Cc: Postgres General <pgsql-general@postgresql.org>
> Subject: Re: [GENERAL] Why are data files stored in /var/lib
>
> On Fri, Apr 29, 2016 at 11:00 PM, Charles Clavadetscher
> <clavadetscher@swisspug.org> wrote:
> > I had a discussion yesterday with some friends, who are sysadmins about the location of database files. In a
> default installation
> > from a distribution (apt-get install) PostgreSQL creates a cluster unter /var/lib/. According to my colleagues
> /var/lib should not
> > contain data that is supposed to last over time.
>
> Your sysadmin friends should read the excellent
> http://www.pathname.com/fhs/pub/fhs-2.3.html#VARLIBVARIABLESTATEINFORMATION
> Filesystem Hierarchy Standard
>
> Chapter 5. The /var Hierarchy
>
> Purpose
>
> /var contains variable data files. This includes spool directories and
> files, administrative and logging data, and transient and temporary
> files.
>
> Some portions of /var are not shareable between different systems. For
> instance, /var/log, /var/lock, and /var/run. Other portions may be
> shared, notably /var/mail, /var/cache/man, /var/cache/fonts, and
> /var/spool/news.
>
> /var is specified here in order to make it possible to mount /usr
> read-only. Everything that once went into /usr that is written to
> during system operation (as opposed to installation and software
> maintenance) must be in /var.
>
> […]
>
> /var/lib : Variable state information
>
> 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.

Thank you a lot. That (and the additional info in the link) explains it very well.
Bye
Charles




Re: Why are data files stored in /var/lib

От
John R Pierce
Дата:
On 4/29/2016 8:30 PM, Charles Clavadetscher wrote:
I had a discussion yesterday with some friends, who are sysadmins about the location of database files. In a default installation
from a distribution (apt-get install) PostgreSQL creates a cluster unter /var/lib/. According to my colleagues /var/lib should not
contain data that is supposed to last over time. I am aware that the location can be modified to suit the needs of sysadmins as
described under these links.

some random thoughts on this...

apt-get is a debian/ubuntu thing.  the rhel/centos/fedora builds also put postgres in /var/lib, although the details differ.

a default built-from-source postgres puts everything in /usr/local

on centos, I generally mount a dedicated file system as /var/lib/pgsql/x.y/data, or even as /var/lib/pgsql ... or if the data file storage is already mounted somewhere arbitrary like /u01, then I'll symlink /var/lib/pgsql/9.4 to /u01/pgsql/9.4 or whatever.




-- 
john r pierce, recycling bits in santa cruz

Re: Why are data files stored in /var/lib

От
Rafal Pietrak
Дата:

W dniu 30.04.2016 o 05:45, Manuel Gómez pisze:
> On Fri, Apr 29, 2016 at 11:00 PM, Charles Clavadetscher
> <clavadetscher@swisspug.org> wrote:
>> I had a discussion yesterday with some friends, who are sysadmins about the location of database files. In a default
installation
>> from a distribution (apt-get install) PostgreSQL creates a cluster unter /var/lib/. According to my colleagues
/var/libshould not 
>> contain data that is supposed to last over time.
>
> Your sysadmin friends should read the excellent
> http://www.pathname.com/fhs/pub/fhs-2.3.html#VARLIBVARIABLESTATEINFORMATION

I always wandered why /SRV isn't used for that (see:
http://www.pathname.com/fhs/pub/fhs-2.3.html#SRVDATAFORSERVICESPROVIDEDBYSYSTEM)

Personally, (irrespectively of the package/distribution defaults) I
always put my databases in /srv/pgdat - upgrades that disrupt such
initial override are seldom.


-R