Share the Vserver cache

Share the vserver cache By default, in debian Lenny, the vserver cache is located in "/var/cache/vservers". Here is where any disk limits, etc. that you set up will be saved between stopping and starting your servers. In these situations, the cache is very helpful because it makes for faster start-ups. Information like disk usage does not have to be computed. It it merely loaded from the cache. Unfortunately, in our present HA setup, the cache directory is not shared between our two host machines. So when we switch over from one host to another, we lose all the cached information and it needs to be re-computed. This leads to start-up delays. In the case of disk limits for vservers with hundreds of GB of data, it can lead to quite lengthy delays as the "du" program has to be run over the entire vserver directory to compute the space used. To fix this, we'll move the directory to a shared disk so it's available on both hosts. In this case, we'll move it to the "/var/lib/vserver" directory which is, of course, shared between the host machines because it's located on our shared DRBD drive. To move the cache, you'll need to run the following commands on the PRIMARY host: mv /var/cache/vservers /var/lib/vservers/.cache ln -s /var/lib/vservers/.cache /var/cache/vservers rm /etc/vservers/.defaults/cachebase ln -s /var/lib/vservers/.cache /etc/vservers/.defaults/cachebase Then on the SECONDARY host, run: rm -rf /var/cache/vservers ln -s /var/lib/vservers/.cache /var/cache/vservers On the PRIMARY host, the first two lines move the existing cache directory to the "/var/lib/vservers/" shared drive, renaming it ".cache". Then we link that directory back to its previous location so that any programs, scripts, etc. that expect the "/var/cache/vservers" directory to be present will still work properly. The last two lines remove the existing symlink to the cache directory in the "/etc/vservers/.defaults" and then add it back, this time pointing to our new cache directory. This isn't strictly necessary since the existing symlink points to "/var/cache/vservers", which itself points to the new cache directory. But this way even if we don't have the "/var/cache/vservers" symlink, all the vserver programs should still work properly. On the SECONDARY host, all we need do is remove the existing cache directory and then symlink it to the location where the shared cache will be mounted when this host becomes PRIMARY. That's it. Now the vserver cache is on a shared drive and when we shut down on one host, the cached information is available on the other host when it starts our vservers.