Skip to content

Instantly share code, notes, and snippets.

@jeroenvandijk
Forked from dstroot/install_postgresql.sh
Last active December 14, 2015 21:49
Show Gist options
  • Save jeroenvandijk/5153462 to your computer and use it in GitHub Desktop.
Save jeroenvandijk/5153462 to your computer and use it in GitHub Desktop.
#!/bin/bash
###############################################
# To use:
# https://raw.github.com/gist/2776351/???
# chmod 777 install_postgresql.sh
# ./install_postgresql.sh
###############################################
echo "*****************************************"
echo " Installing PostgreSQL"
echo "*****************************************"
sudo yum -y install postgresql postgresql-server postgresql-devel postgresql-contrib postgresql-docs
sudo service postgresql initdb
# Use MD5 Authentication
sudo sed -i.bak -e 's/local all all peer/local all all trust/' /var/lib/pgsql9/data/pg_hba.conf
#start
sudo /sbin/chkconfig --levels 235 postgresql on
sudo service postgresql start
# Copy data directory and move the directory to ephemeral disk, and symlink it on the original location
psql -c 'SHOW data_directory'
sudo cp -r /var/lib/pgsql9/data postgres_data_dir
sudo mv /var/lib/pgsql9/data/ /media/ephemeral0/postgres_data_dir
ln -s /var/lib/pgsql9/data/ /media/ephemeral0/postgres_data_dir
sudo chown -R postgres /var/lib/pgsql9/data/*
# Add the current as database user
sudo -u postgres createuser --superuser $(whoami)
sudo -u postgres psql -c "\password $(whoami)"
createdb $(whoami)
# http://imperialwicket.com/aws-install-postgresql-on-amazon-linux-quick-and-dirty
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment