Getting started with CloudLinux OS Shared
Restricting MySQL usage resources with MySQL Governor
MySQL governor is software to monitor and restrict MySQL usage in shared hosting environments. The monitoring is done via resource usage statistics per each MySQL thread.
Installation consists of two steps – installing governor-mysql package and switching to MySQL packages provided with CloudLinux OS:
yum install governor-mysql
/usr/share/lve/dbgovernor/mysqlgovernor.py --install
MySQL Governor has multiple modes of operation: monitor only, place all users that have reached their limits into single predefined LVE. Always place mysql queries into users LVE, or place users into their LVE only when MySQL Governor limits have been reached which is the default mode of operation.
Default settings are suitable for most servers so we recommend to leave them as they are. Use dbctl list command to check MySQL Governor limits. From there you can obtain user’s cpu, read and write limits. Each limit consists of four values for different time ranges. By default these are 1 minute, 15 minutes, 1 hour and 1 day.
You can monitor MySQL usage with dbtop utility.
The tool dbctl is used to change mysql-governor configuration, for example changing cpu and read values for cltest3 user could be done with following command:
dbctl set cltest3 --cpu=150,100,70,50 --read=2048,1500,1000,800
Now check the limits with dbctl list:
dbctl list | grep cltest3
Admin can manually force any user to be restricted with dbctl restrict username command.
Users, whose queries exceed the limits set, are restricted by MySQL Governor. The list of such users can be obtained from dbctl list-restricted command. Also, admin can unrestrict any user with dbctl unrestrict command. In addition, you may protect any user from being restricted using dbctl ignore username command.