Last active
October 26, 2018 19:11
-
-
Save adriancb/394075c21f0e5a5ff624 to your computer and use it in GitHub Desktop.
Create separate partition for Postgres
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# create a separate partition and initialize with ext4 | |
sudo mkfs.ext4 /dev/xvdb | |
# turn off journaling | |
sudo tune2fs -o journal_data_writeback /dev/xvdb | |
sudo tune2fs -O ^has_journal /dev/xvdb | |
# add to fstab | |
echo '/dev/xvdb /mnt/databases ext4 defaults,auto,noatime,nodiratime,noexec 0 0' | sudo tee -a /etc/fstab | |
# create the db mount point | |
sudo mkdir /mnt/databases | |
# mount the db with settings from fstab | |
sudo mount /mnt/databases | |
# move your existing postgres onto the new mount (as of the time of this gist we're using 9.3) | |
sudo mkdir -p /mnt/databases/postgresql/9.3 | |
sudo chown -R postgres:postgres /mnt/databases/postgresql | |
sudo service postgresql stop | |
sudo mv /var/lib/postgresql/9.3/main /mnt/databases/postgresql/9.3 | |
# tweak postgres settings | |
# change fsync = on -> fsync = off | |
# change full_page_writes = on -> full_page_writes = off |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment