Tuesday, July 5, 2011

Moving Postgresql data

So the volume attached to the EC2 instance where I was running a test instance of Squiz Matrix ran out of room.
Luckily this proved to be pretty straight forward:

  1. using AWS web console, create a new volume and attach it to my instance (while instance is shutdown) - the new volume is attached as /dev/sdb
  2. start up the instance, ssh in and format new volume: mkfs.ext3 /dev/sdb
  3. mkdir mount point, eg /pgdata
  4. vim /etc/fstab, adding:
    /dev/sdb        /pgdata         ext3    defaults        1 1
  5. mount /pgdata
  6. chown postgres:postgres /pgdata/
  7. refer to this handy blog post
  8. service postgresql stop
  9. cp -R /var/lib/pgsql/data /pgdata/
  10. Wait...
  11. vim /etc/init.d/postgresql  and setting PGDATA to /pgdata
  12. service postgresql start

No comments:

Post a Comment