How to oversell KVM Memory KSM
Oversell KSM Memory
Firstly, before we proceed you cannot oversell KVM space on KVM nodes, it’s just not possible. However, you can oversell memory by using a little program called KSM (kernel same-page merging). KSM was originally developed by Red Hat and it’s been included since Kernel version 2.6.32. You can save between 30% to 60% of your memory resources by activating KSM. After an hour look at your resource usage. You should see a vast improvement in the resources that you have available to use.
Start KSM
To start KSM login to the host node as the root user and issue the below command to start KSM. Note, this should also start the ksmtuned service.
CentOS 7
systemctl start ksm
CentOS 6
service ksm start
Ensure KSM is running by issuing the status commands
CentOS 7
systemctl status ksm
systemctl status ksmtuned
CentOS 6
service status ksm
service status ksmtuned
To automatically start KSM on boot turn it on using the chkconfig script or systemctl
CentOS 7
systemctl enable ksm
CentOS 6
chkconfig ksm on
You can use other switches with this script. Just swap start for the one required.
start stop restart force-reload condrestart try-restart status retune help
Extreme care should be taken when using KSM. If you overcommit to much your dedicated server / host will suffer problems. Only use KSM if you absolutely need it.
------------------------------------------------------------------------