Currenly my postgresql service running with
/usr/local/psql/bin/postmaster -d /usr/local/pgsql/data
Due to insufficient disk space (data directory having 10GB of data), I planned to do the following steps:
Step1:
service postgresql stop
Step2:
mkdir -p /newdisk/newdata
chown postgres:postgres /newdisk/newdata
Step 3:
Change PGDATA path in /etc/rc.d/init.d/postgresql file
From
PGDATA=/usr/local/pgsql/data
To
PGDATA=/newdisk/newdata
Step 4:
initdb -D /newdisk/newdata
service postgresql start
If I do above steps, expecting 10GB data will be moved to /newdisk/newdata path and henceforth, new transactions will be stored in /newdisk/newdata path.
This approach is fine to proceed? or do I need to consider anything else?
(Using Postgresql 9.1)
1 Answer 1
in Your way, also EXPORT PGDATA=/newdisk/newdata
but also You can move all files to the new disk, and mount this disk to old PGDATA path (if all disk for PGSQL only)
Edit your /etc/fstab:
/dev/disk_name /usr/local/psql/data auto defaults 1 2
-
thanks for the replay. I will try yours. can I move the /usr/local/psql/data to /data (will do the startup parameter change accordingly in /etc/rc.d/init.d/postgresql). Will it impact anything?RBB– RBB2015年11月16日 17:58:17 +00:00Commented Nov 16, 2015 at 17:58