Installing pg_repack on EC2 instance with Ubuntu
UPDATED: 10/08/2020
We use pg_repack
on our Postgresql database to clean it up periodically. When I started, I hadn’t used it before and found very little information on the web about it, and how to install it. First, I tried installing it locally, which wasn’t too difficult, and I may create a post for that sometime as well. But I decided that it would be better to run it from an EC2 instance instead of my local machine, to avoid possible issues with losing connectivity while running the process. This was less straight forward and required significant digging to get to work. Below are the steps I took:
- Download the version of
pg_repack
you want to install usingwget
wget 'https://api.pgxn.org/dist/pg_repack/1.4.3/pg_repack-1.4.3.zip'
- Unzip the package and change to the newly created directory:
sudo unzip pg_repack-1.4.3.zip
cd pg_repack-1.4.3
- Next, you will need to install several packages including postgresql:
sudo apt-get install postgresql-server-dev-all
sudo apt-get install postgresql-common
sudo apt-get install postgresql-client
- Once those packages are installed, it’s time to install `pg_repack with the following commands:
sudo make
sudo cp bin/pg_repack /usr/local/bin/
NOTE: The last command may need to copy to /usr/bin/
instead.
That should be it, now you should have pg_repack
installed on your EC2 instance. You can check that it’s installed by running the following command to check the version:
pg_repack --version
I hope that helps anyone looking to do the same. Below are the resources I used to piece this together if you want more info.
RESOURCES: