Change data folder and log folder path of vPostgres

Just tried out how to change the data folder of vPostgres. We all know that separate data folder and log folder is one of the deployment best practice, for better performance. It is not difficult to do this for native PostgreSQL, just run the initdb command, or change the PostgreSQL.conf. But it’s not the same story for vPostgres, which is a distribution from VMware, part of its vFabric ecosystem.

Short version of the new storage: you must change a variable called “PG_DATA_DIR” in pgvm.conf, instead of postgresql.conf. You can find the pgvm.conf at /opt/vmware/vpostgres/current/etc/.

So if you want install vPostgres in your own machine, with the package downloaded from VMware, and you want separate the data folder and log folder. You need use following steps:

  1. Mount your disks for data folder and log folder, e.g. /pgdata/9.2/data and /pgdata/9.2/log. Be sure you added the mounted path to /etc/fstab.
  2. Install the vPostgres package with rpm command.
  3. Change owner of the folders you created in 1st step.
  4. Run initdb with postgres user, with -D and -X switch to change the data folder and log folder path. You will find the initdb command from /opt/vmware/vpostgres/current/bin/.
  5. Modify the pgvm.conf we mentioned before. Change the variable PG_DATA_DIR.
    BE CAUTIOUS, there are two sections in the con figuration file. PG_DATA_DIR is in the first section. The second section is for virtual appliance (vApp you downloaded from VMware).
  6. Restart the server and by default the vpostgres service will start up automatically. Now you can delete the /var/vmware/vpostgres/current/pgdata.

Have to say I don’t like this change, especially the official document never mentioned it. Tried several times then found this pgvm.conf.

And if you are using a virtual appliance. The steps shall be very close. Just try the value in second section, of course with

Post a comment or leave a trackback: Trackback URL.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: