Git Product home page Git Product logo

mysql-cgroup-plugin's Introduction

What is this?

This is a MariaDB plugin that allows to limit all connections of a user to certain CPU and/or I/O BW.

To achieve that, the plugin is built as an audit plugin.

It will check if /sys/fs/cgroup/{cpu,memory,blkio}/mysql cgroups exist and if so, it will create new cgroups per-user under them.

This will allow administrators to control the CPU and I/O utilization per-user by imposing proper limits for all of their connections.

In the future it may also include network BW limits.

Build

The current version is prepared to be build against MariaDB. Future versions would be compatible with MySQL and Percona.

cd mysql-cgroup-plugin
make

Setup

After install of MySQL/MariaDB you need to run the setup_cgroups.sh script. It will create the cgroup_limits database and the limits table inside of it.

You should then move the mysql_init_cgroups.sh to /usr/local/sbin.

In order to have automatic initialization of the cgroups you can either setup mysql slice in systemd or use the provided mysql_init_cgroups.sh script. If you want to use the provided script, simply copy systemd/cgroups.conf to:

/etc/systemd/system/mariadb.service.d/

This will add execution of the script, before each start of MariaDB. The important part is that the script chowns the newly created mysql cgroups, so the mysql daemon can create new groups and update current values.

Next you need to copy the audit_cgroup.so to the plugin directory of your mysql installation.

Finally, you need to load the plugin:

MariaDB [(none)]> INSTALL PLUGIN audit_cgroup SONAME 'audit_cgroup.so';

Verify that the plugin is loaded and enabled:

MariaDB [(none)]> SHOW VARIABLES LIKE 'audit_cgroup_enabled';
+----------------------+-------+
| Variable_name        | Value |
+----------------------+-------+
| audit_cgroup_enabled | ON    |
+----------------------+-------+
1 row in set (0.003 sec)

Maintance

You can temporary disable the plugin:

MariaDB [(none)]> set global audit_cgroup_enabled=OFF;
Query OK, 0 rows affected (0.000 sec)

MariaDB [(none)]> show variables like 'audit_cgroup_enabled';
+----------------------+-------+
| Variable_name        | Value |
+----------------------+-------+
| audit_cgroup_enabled | OFF   |
+----------------------+-------+
1 row in set (0.001 sec)

and then reenable it:

MariaDB [(none)]> set global audit_cgroup_enabled=ON;
Query OK, 0 rows affected (0.000 sec)

Removing the plugin completely:

UNINSTALL SONAME 'audit_cgroup.so';

mysql-cgroup-plugin's People

Contributors

hackman avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.