Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gwpf6-0007zX-4C for pgsql-general@arkaria.postgresql.org; Thu, 21 Feb 2019 14:49:20 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1gwpf4-00068s-PB for pgsql-general@arkaria.postgresql.org; Thu, 21 Feb 2019 14:49:18 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gwpf4-00065q-DM for pgsql-general@lists.postgresql.org; Thu, 21 Feb 2019 14:49:18 +0000 Received: from mail-it1-x133.google.com ([2607:f8b0:4864:20::133]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.89) (envelope-from ) id 1gwpf1-0000vv-Mi for pgsql-general@lists.postgresql.org; Thu, 21 Feb 2019 14:49:18 +0000 Received: by mail-it1-x133.google.com with SMTP id z131so22712204itf.5 for ; Thu, 21 Feb 2019 06:49:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-language; bh=DD8DWx6x3LYlqQ3LNqCB0sihzt8kkC7Y3lzYYwXySX4=; b=Bj8GbLL+KNyq5i9B0rMg2W96lTq/PBdak2g93kpUt2flkPmvw9cz7yP3JQMp68DWGz spGQASTHGPcy1gmNRc0jR98Y60TSYjdUWe0te3Sevxo2IeL3Fa+YPS/CZ+d6ViYiN6bF p8LucgCNQ/U3hyXpIDUHvBGXSgLfe47bkivksk2ZEbWAvApV1vn5p+VLOilgHtKrolK6 zeaizQxaRlN8ICjvMDPjvrOGAZWXozQjBVIwMpvoBMzCjcYjuz7XKRd8VqhnkoABmluo T2YsEvm014pqY9bdCofiuX8bSMvmJ7frA1nIAEtOjwAVjAFPUC983N+W7k4O0lQr6Su7 e6Tg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language; bh=DD8DWx6x3LYlqQ3LNqCB0sihzt8kkC7Y3lzYYwXySX4=; b=izUYG12ECJqhKiBYI0EAdrYZRtBs694RyCxGKW7RVUv0FWWWoxMLXlJ2VNLpaSB4jb 3Nd7MItkPsRlJR4EzLtIgZHFLbeH7Hdaj2mnqh0KVRvBUGGi1LmXX3bmiwPgMf/Q//Y8 /VBjon8RHU0gWw8KC3fdHuD7/hrSasYZ2x8rj0lrFdqwv9XqBg2Mjo1Oev6myYF7a/PO 6UjTjGmlCkzZ7/9F1BfGYKJJWRrEkZV4XicJmKW+WYuu/hdNPsqjphsy2t7gcM9UM5Bi taXjQDzADkMGQ9icwM5kbIxh9g+y7i1G418rYjkU9aoCFzmBowRZU+3PM7o84aA1fX4q Br7g== X-Gm-Message-State: AHQUAuYp1mhnHh+42TTgdzSqJUJ/NpQ8RBJtrIvNfp8GICx5iGJYV7Sx nR3Rp0xfgJUn9l4ecwJvXlyKBnyD X-Google-Smtp-Source: AHgI3IakkNKrzEYmUUoi0uiOD+3teh+PFwUi4bSuxmELcyu/2tWqa2Hc5Oe/q8L7J1U27AQElbSsNQ== X-Received: by 2002:a24:4a4e:: with SMTP id k75mr10296106itb.116.1550760552499; Thu, 21 Feb 2019 06:49:12 -0800 (PST) Received: from [10.22.10.6] ([172.98.67.72]) by smtp.googlemail.com with ESMTPSA id u24sm5344940ior.59.2019.02.21.06.49.11 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Feb 2019 06:49:11 -0800 (PST) Subject: Re: adding more space to the existing 9.6 cluster To: "pgsql-general@lists.postgresql.org" References: From: Ron Message-ID: Date: Thu, 21 Feb 2019 08:49:10 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: multipart/alternative; boundary="------------B64BED16AF209762C6618EFA" Content-Language: en-US List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk This is a multi-part message in MIME format. --------------B64BED16AF209762C6618EFA Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit No doubt it'll take a while... You said you have 36 databases.  Could you move half of them using pg_dump/pg_restore over a few outage windows?  (Doing it in bite-sized pieces reduces risk.) On 2/21/19 2:27 AM, Julie Nishimura wrote: > Thank you for the suggestions! We realized we cannot add more space to the > existing cluster due to the hardware limitations. So, we decided to go the > other route by introducing new standby on a new host with bigger size for > data (with pg_basebackup and putting Master into archive mode), then > promote it to the master. Do you have any idea how long it might take to > run pg_basebackup for 21 tb database? Is there any gotcha we should be > aware of? Thank you for your support and help > > Sent from my iPhone > > On Feb 21, 2019, at 12:18 AM, Thomas Boussekey > wrote: > >> Hello all, >> >> If I were in your situation, I would analyze if it could move only a part >> of the 36 databases to the new disk. >> * Either, I will move some of the databases to the new disk, >> * Either, In the largest databases, I will consider to work in multiple >> tablespace configuration, using the command ALTER TABLE <> SET >> TABLESPACE <>; Link to the documentation: >> https://www.postgresql.org/docs/9.6/sql-altertable.html . to move some >> tables to the new disk. You can analyze (depending on your disk and DB >> configurations, if it's better to move the very large tables or >> intensively used tables. >> >> I hope I'm clear enough! >> Feel free to ask for clarification or add new elements to go further on! >> >> Hope this helps, >> Have a nice day, >> Thomas >> >> Le mer. 20 févr. 2019 à 21:37, Ron > > a écrit : >> >> 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 , 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. >> -- Angular momentum makes the world go 'round. --------------B64BED16AF209762C6618EFA Content-Type: text/html; charset=utf-8 Content-Transfer-Encoding: 8bit No doubt it'll take a while...

You said you have 36 databases.  Could you move half of them using pg_dump/pg_restore over a few outage windows?  (Doing it in bite-sized pieces reduces risk.)

On 2/21/19 2:27 AM, Julie Nishimura wrote:
Thank you for the suggestions! We realized we cannot add more space to the existing cluster due to the hardware limitations. So, we decided to go the other route by introducing new standby on a new host with bigger size for data (with pg_basebackup and putting Master into archive mode), then promote it to the master. Do you have any idea how long it might take to run pg_basebackup for 21 tb database? Is there any gotcha we should be aware of? Thank you for your support and help

Sent from my iPhone

On Feb 21, 2019, at 12:18 AM, Thomas Boussekey <thomas.boussekey@gmail.com> wrote:

Hello all,

If I were in your situation, I would analyze if it could move only a part of the 36 databases to the new disk.
* Either, I will move some of the databases to the new disk,
* Either, In the largest databases, I will consider to work in multiple tablespace configuration, using the command ALTER TABLE <<TableName>> SET TABLESPACE <<TablespaceName>>; Link to the documentation: https://www.postgresql.org/docs/9.6/sql-altertable.html . to move some tables to the new disk. You can analyze (depending on your disk and DB configurations, if it's better to move the very large tables or intensively used tables.

I hope I'm clear enough!
Feel free to ask for clarification or add new elements to go further on!

Hope this helps,
Have a nice day,
Thomas

Le mer. 20 févr. 2019 à 21:37, Ron <ronljohnsonjr@gmail.com> a écrit :
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.

--
Angular momentum makes the world go 'round.
--------------B64BED16AF209762C6618EFA--