-
Notifications
You must be signed in to change notification settings - Fork 37
Moving tables to new tablespace
adamhooper edited this page Nov 25, 2014
·
6 revisions
[Adam, 2014-11-25]
- Save space on the "old" database volume
- Zero downtime
- The "old" database volume is filled mostly by file contents, which we'll be removing as we do this migration
- Staging will be up the entire time
- Create a new volume on EC2 and mount it
- Make Postgres aware of the new volume
- Use
pg_repack
to move tables from the old volume to the new one.
I ran all these steps on staging/database first, then on production/database.
# We'll need [email protected], because @9.3 will break
echo "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main 9.1" | sudo tee /etc/apt/sources.list.d/pgdg.list
echo -e "Package: libpq-dev\nPin: version 9.1.*\nPin-Priority: 1001" | sudo tee /etc/apt/preferences.d/libpq-dev
echo -e "Package: libpq5\nPin: version 9.1.*\nPin-Priority: 1001" | sudo tee /etc/apt/preferences.d/libpq5
sudo apt-get updatesudo apt-get install postgresql-server-dev-9.1 build-essential # to compile extension
sudo apt-get install pgxnclient # pgxn installs Postgres extensions