Thread: Preferred Installation/Data Directories
Seems to me that the preferred filesystem for postgres has varied over the years from /var/lib/ to /usr/local/ and back again. When I upgraded from 7.4.3 to 8.1.4 the move was from /usr/local/ to /var/lib/. Now, as I prepare to upgrade and migrate data from 8.1.4 to 8.2.4, I see that the docs all refer to an installation in /usr/local/. Is there a preference? Does it matter? On my system /usr/local/ is 20 times the size of /var/, so it makes more sense to store data where there's more room. Rich -- Richard B. Shepard, Ph.D. | The Environmental Permitting Applied Ecosystem Services, Inc. | Accelerator(TM) <http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863
Rich Shepard <rshepard@appl-ecosys.com> writes: > Seems to me that the preferred filesystem for postgres has varied over the > years from /var/lib/ to /usr/local/ and back again. No, it hasn't. The PG code itself doesn't make any assumptions about the location of $PGDATA AFAIR, but there are a large number of packagings that assume specific places like /var/lib/pgsql/. If you've changed platforms or changed between installing from source and installing a prebuilt package, you might notice some variability. In any case you're certainly welcome to put $PGDATA anywhere you want. [ Thinks for a bit ... ] Note that "packaging" might extend further than meets the eye. For instance, if you want to move $PGDATA on a recent Red Hat system, you need to tweak not only the initscript but the SELinux policy, which by default will constrain the postmaster to write only under /var/lib/pgsql/. regards, tom lane
On Fri, 27 Apr 2007, Tom Lane wrote: > No, it hasn't. The PG code itself doesn't make any assumptions about the > location of $PGDATA AFAIR, but there are a large number of packagings that > assume specific places like /var/lib/pgsql/. If you've changed platforms > or changed between installing from source and installing a prebuilt > package, you might notice some variability. In any case you're certainly > welcome to put $PGDATA anywhere you want. Thanks, Tom. That does clear up what I've seen over the years. The executables go in /usr/bin/ (at least they do with Slackware), but $PGDATA is what I've seen changed between building from source and installing packages. > [ Thinks for a bit ... ] Note that "packaging" might extend further than > meets the eye. For instance, if you want to move $PGDATA on a recent Red > Hat system, you need to tweak not only the initscript but the SELinux > policy, which by default will constrain the postmaster to write only under > /var/lib/pgsql/. I see in postgresql.SlackBuild where the data directories are specified. I'll change that from /var/lib/pgsql/data to /usr/local/pgsql/data and rebuild the package. Very much appreciated, Rich -- Richard B. Shepard, Ph.D. | The Environmental Permitting Applied Ecosystem Services, Inc. | Accelerator(TM) <http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 On 04/27/07 09:50, Rich Shepard wrote: [snip] > > I see in postgresql.SlackBuild where the data directories are specified. > I'll change that from /var/lib/pgsql/data to /usr/local/pgsql/data and > rebuild the package. (Explicitly noting that this is a serious question, not an attempt to start a flame war.) Why put "active" data under /usr? Ever since user data was moved to /home, /usr has only had system stuff in it. Or is that still a viable BSDism? - -- Ron Johnson, Jr. Jefferson LA USA Give a man a fish, and he eats for a day. Hit him with a fish, and he goes away for good! -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.6 (GNU/Linux) iD8DBQFGMjmRS9HxQb37XmcRAhAHAJ9Z0s8BOmQuaXTR6QsGXz+NISQvqACeN9g1 Hww/Z37CCfiqhDsHxuvpzaA= =0nk1 -----END PGP SIGNATURE-----
On Fri, 27 Apr 2007, Ron Johnson wrote: > Why put "active" data under /usr? Ever since user data was moved to home, > /usr has only had system stuff in it. Or is that still a viable BSDism? Good question, Ron! But, in a multiuser system with many users of the database, in whose /home directory will you put the data? Since /usr/local, /opt, and similar filesystems are for local interest stuff, they make ideal data storage areas. Neither is affected by distribution upgrades so the data are safe there. Rich -- Richard B. Shepard, Ph.D. | The Environmental Permitting Applied Ecosystem Services, Inc. | Accelerator(TM) <http://www.appl-ecosys.com> Voice: 503-667-4517 Fax: 503-667-8863
Rich Shepard wrote: > On Fri, 27 Apr 2007, Ron Johnson wrote: > >> Why put "active" data under /usr? Ever since user data was moved to >> home, >> /usr has only had system stuff in it. Or is that still a viable BSDism? > > Good question, Ron! But, in a multiuser system with many users of the > database, in whose /home directory will you put the data? > > Since /usr/local, /opt, and similar filesystems are for local interest > stuff, they make ideal data storage areas. Neither is affected by > distribution upgrades so the data are safe there. > According to the FHS (http://www.pathname.com/fhs/pub/fhs-2.3.html): "/usr is shareable, read-only data. That means that /usr should be shareable between various FHS-compliant hosts and must not be written to. Any information that is host-specific or varies with time is stored elsewhere." "/var contains variable data files. This includes spool directories and files, administrative and logging data, and transient and temporary files." This suggests that var is a 'better' place for the database files from this perspective, since /usr should be mountable read-only when not doing system administration. Interestingly, I just noticed that the FHS also specifies a different top-level directory that I'd never heard of before that could be even more suitable (again, in this perspective): "/srv contains site-specific data which is served by this system." > Rich >