pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Kris Deugau <kdeugau@vianet.ca>
To: pgsql-general@postgresql.org
Subject: Re: Tablespace setup issue
Date: Thu, 21 Nov 2019 10:32:48 -0500
Message-ID: <7063b82b-820c-61d0-ffb1-9cbbc1958ab5@vianet.ca> (raw)
In-Reply-To: <CABR8ZvrdNH9HyzjKpvxaiM4bdYZhXo2tXhbD5ni78UsWNB7-EQ@mail.gmail.com>
References: <CABR8ZvrdNH9HyzjKpvxaiM4bdYZhXo2tXhbD5ni78UsWNB7-EQ@mail.gmail.com>

Sébastien Bihorel wrote:
> Hi,
> 
> I am new to this list and reaching out because I am having troubles 
> setting up a local PostgreSQL database on my laptop. Maybe, as a 
> preamble, I should say that I am pretty much a novice trying to teach 
> myself and get practical experience about database and SQL queries (I 
> have some general idea about relational DB structure and operation but 
> no actual experience creating a DB or writing SQL queries).
> 
> Some background about my setup:
> - OS: my laptop runs Linux Mint 19.1 (a flavor of ubuntu 18.04); psql 
> 12.1 was installed along with pgadmin 4. There is a single user (ie, 
> sebastien) on this machine and the group postgres exists.

> I have also successfully created a database (sebastien) for the new 
> superuser sebastien, and a schema (test) within this database.
> 
> Now, I would like to assign a particular disk location for the 
> tablespace used by this database but I am getting all kinds of errors 
> apparently linked to folder permissions.
> 
> The location is /home/sebastien/data/pgdata96_sebastien

This is probably not what going to do what you want.  At best it will be 
a spaghetti pile of mixed up permissions, working against several sets 
of common practice and security restrictions, to get it to work.  I 
wouldn't be surprised if you ran into SELinux or AppArmor restrictions 
too (or another similar system, I think there are a couple more).


> has the following properties:
> 
> /home/sebastien/data $ ls -l
> drwxr-xr-x 2 sebastien postgres 4096 Nov 19 09:14 pgdata96_sebastien

> The manual states "The location must be an existing, empty directory 
> that is owned by the PostgreSQL operating system user." So, I am not 
> sure what I am doing wrong. Web searches ran on these error messages did 
> not enlighten me more...

The files and directories that the Postgres server manages MUST be owned 
by the OS user "postgres".  This directory is still owned by your OS 
user sebastien.  You will probably also have to play games with the 
permissions on /home/sebastien and /home/sebastien/data to get this to 
work at all.

Your OS user will not be able to usefully read any files that Postgres 
creates directly, so there's not much value in putting them outside of 
the default directory tree under /var/lib/postgres.

Postgres is pretty good about managing its own data files;  unless you 
need to quickly glue on more storage without disturbing an active 
production server, or need to put a particular table or database on 
expensive-but-faster (or possibly slower-but-much-larger-and-cheaper) 
storage, you probably don't need to use tablespaces.

For experimenting with them it would be a lot simpler to create a 
directory (or two, or three) under /var/lib/postgres for them, owned by 
the postgres OS user.

-kgd





view thread (10+ messages)  latest in thread

Message-ID: <7063b82b-820c-61d0-ffb1-9cbbc1958ab5@vianet.ca>
Permalink:  ../7063b82b-820c-61d0-ffb1-9cbbc1958ab5@vianet.ca/
Also on:    postgresql.org/message-id/7063b82b-820c-61d0-ffb1-9cbbc1958ab5@vianet.ca

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-general@postgresql.org
  Cc: kdeugau@vianet.ca
  Subject: Re: Tablespace setup issue
  In-Reply-To: <7063b82b-820c-61d0-ffb1-9cbbc1958ab5@vianet.ca>
  References: <CABR8ZvrdNH9HyzjKpvxaiM4bdYZhXo2tXhbD5ni78UsWNB7-EQ@mail.gmail.com> <7063b82b-820c-61d0-ffb1-9cbbc1958ab5@vianet.ca>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox