pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Ron <ronljohnsonjr@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: adding more space to the existing 9.6 cluster
Date: Wed, 20 Feb 2019 14:37:32 -0600
Message-ID: <e2e0a084-57a2-b818-eb14-0476e92d85fb@gmail.com> (raw)
In-Reply-To: <BYAPR08MB5014E1824D4A9515D423EC53AC7C0@BYAPR08MB5014.namprd08.prod.outlook.com>
References: <BYAPR08MB5014E1824D4A9515D423EC53AC7C0@BYAPR08MB5014.namprd08.prod.outlook.com>

On 2/19/19 5:02 PM, Julie Nishimura wrote:
> Hello, we are almost out of space on our main data directory, and about to 
> introduce new directory to our cluster. We cannot use multiple physical 
> disks as a single volume, so we are thinking about creation new tablespace.
> Our current data_directory shows as follows:
> /data/postgresql/9.6/main
> postgres=# SELECT spcname FROM pg_tablespace;
>   spcname
> ------------
>  pg_default
>  pg_global
> (2 rows)
>
> We also have 36 existing databases on this cluster.
> If we add new directory, will it be enough to execute the following 
> commands in order to force new data there:
> CREATE TABLESPACE tablespace01 LOCATION '/data/postgresql/9.6/main01';
> ALTER DATABASE db_name SET TABLESPACE
> tablespace01
>
> Do I need to repeat it for all our existing databases?

Since the command is ALTER DATABASE <your_user_db>, it seems that yes you 
have to do it for all of them.  A simple bash script should knock that out 
quickly.


> Should I change our "template*" dbs as well?

If you want *new* databases to automatically go to tablespace01 then alter 
template1.

> Do I need to do something else?

Maybe, depending on the size of your databases, and how much down time you 
can afford,


https://www.postgresql.org/docs/9.6/sql-alterdatabase.html "This command 
physically moves any tables or indexes in the database's old default 
tablespace to the new tablespace."

For example, our multi-TB databases are so big that moving it all at once is 
unreasonably slow.  And a failure might leave the db is a bad spot.  Thus, 
I'd move one table at a time, a few per outage.

Naturally, YMMV.

> Thank you for your advises.



-- 
Angular momentum makes the world go 'round.

view thread (6+ messages)  latest in thread

Message-ID: <e2e0a084-57a2-b818-eb14-0476e92d85fb@gmail.com>
Permalink:  ../e2e0a084-57a2-b818-eb14-0476e92d85fb@gmail.com/
Also on:    postgresql.org/message-id/e2e0a084-57a2-b818-eb14-0476e92d85fb@gmail.com

 · 

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: ronljohnsonjr@gmail.com
  Subject: Re: adding more space to the existing 9.6 cluster
  In-Reply-To: <e2e0a084-57a2-b818-eb14-0476e92d85fb@gmail.com>
  References: <BYAPR08MB5014E1824D4A9515D423EC53AC7C0@BYAPR08MB5014.namprd08.prod.outlook.com> <e2e0a084-57a2-b818-eb14-0476e92d85fb@gmail.com>

* 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