- Overview
- Setup - The basics of getting started with proxysql
- Usage - Configuration options and additional functionality
- Reference - An under-the-hood peek at what the module is doing and how
- Limitations - OS compatibility, etc.
- Development - Guide for contributing to the module
The proxysql module installs, configures and manages the ProxySQL service.
This module will install the ProxySQL and manage it's configuration. It also extends Puppet to be able to manage mysql_users
, mysql_servers
, mysql_replication_hostgroups
, mysql_query_rules
, scheduler
and global_variables
.
The module requires Puppet 4.x and currently supports only Debian 8 "Jessie" (and possibly Debian 7 "Wheezy").
Note: the ProxySQL-package is currently not in any public upstream package manager. So you should consider uploading it to a private package manager and manage that before calling the proxysql-class.
To install the ProxySQL software with all the default options:
include ::proxysql
You can customize options such as (but not limited to) listen_port
, admin_password
, monitor_password
, ...
class { '::proxysql':
listen_port => 3306,
admin_password => '654321',
monitor_password => '123456',
override_config_settings => $override_settings,
repo => {
'debs_proxysql_repo' => {
comment => 'ProxySQL repo',
location => 'http://debs.example.tld/debian',
repos => 'proxsql',
},
},
}
On Yum
based systems you can do and the module will install ProxySQL from the Percona repo's.
class { '::proxysql':
listen_port => 3306,
admin_password => '654321',
monitor_password => '123456',
manage_rpm => true,
}
Configuration is done by the proxysql
class.
You can override any configuration setting by using the override_config_settings
hash. This hash resembles the structure of the proxysql.cnf
file
{
admin_variables => {
refresh_interval => 2000,
...
},
mysql_variables => {
monitor_writer_is_also_reader => false,
...
},
mysql_servers => {
'mysql1' => {
'address' => '127.0.0.1',
    'port' => 33061,
   },
'mysql2' => {
'address' => '127.0.0.1',
    'port' => 33062,
   },
...
},
mysql_users => { ... },
mysql_query_rules => { ... },
scheduler => { ... },
mysql_replication_hostgroups => { ... },
}
proxysql
: Installs and configures ProxySQL
proxysql::install
: Installs the package(s)proxysql::config
: Manages the configuration files andglobal_variables
proxysql::repo
: Manages the repo's where ProxySQL might be in.proxysql::service
: Manages the service
The name of the ProxySQL package in your package manager. Defaults to 'proxysql'
The ensure of the ProxySQL package resource. Defaults to 'latest'
The name of the ProxySQL service resource. Defaults to 'proxysql'
The ensure of the ProxySQL service resource. Defaults to 'running'
The directory where ProxySQL will store it's data. defaults to '/var/lib/proxysql'
The ip where the ProxySQL service will listen on. Defaults to '0.0.0.0' aka all configured IP's on the machine
The port where the ProxySQL service will listen on. Defaults to '6033'
The socket where the ProxySQL service will listen on. Defaults to '/tmp/proxysql.sock'
The username to connect to the ProxySQL admin interface. Defaults to 'admin'
The password to connect to the ProxySQL admin interface. Defaults to 'admin'
The ip where the ProxySQL admin interface will listen on. Defaults to '127.0.0.1'
The port where the ProxySQL admin interface will listen on. Defaults to '6032'
The socket where the ProxySQL admin interface will listen on. Defaults to '/tmp/proxysql_admin.sock'
The username ProxySQL will use to connect to the configured mysql_servers. Defaults to 'monitor'
The password ProxySQL will use to connect to the configured mysql_servers. Defaults to 'monitor'
The file where the ProxySQL configuration is saved. This will only be configured if manage_config_file
is set to true
.
Defaults to '/etc/proxysql.cnf'
Determines wheter this module will configure the ProxySQL configuration file. Defaults to 'true'
Path of the my.cnf file where the connections details for the admin interface is save. This is required for the providers to work.
This will only be configured if manage_mycnf_file
is set to true
. Defaults to '/root/.my.cnf'
Determines wheter this module will configure the my.cnf file to connect to the admin interface. Defaults to 'true'
Determines wheter this module will restart ProxySQL after reconfiguring the config file. Defaults to 'false'
Specifies wheter te managed ProxySQL resources should be immediately loaded to the active runtime. Boolean, defaults to 'true'.
Specifies wheter te managed ProxySQL resources should be immediately save to disk. Boolean, defaults to 'true'.
These are the repo's we will configure. Currently only Debian is supported. This hash will be passed on to apt::source
. Defaults to {}.
Determines wheter this module will manage the repositories where ProxySQL might be. Defaults to 'true'
These are the repo's we will configure. Currently only Debian is supported. This hash will be passed on to apt::source
. Defaults to {}.
Determines wheter this module will use local provider instead of the repo to install ProxySQL, defaults to false,
location ot the proxysql package for the package_provider
. Default to 'https://www.percona.com/redir/downloads/proxysql/proxysql-1.3.2/binary/redhat/6/x86_64/proxysql-1.3.2-1.1.x86_64.rpm'
provider for package-resource. defaults to dpkg
for debian-based, rpm
for redhat base or undef
for others
owner of the datadir and config_file, defaults to 'root' on most systems, to 'proxysql' on redhat-based
group of the datadir and config_file, defaults to 'root' on most systems, to 'proxysql' on redhat-based
title for the yumrepo-resource in RedHat-based systems, defaults to 'percona_repo'
description for the yumrepo-resource in RedHat-based systems, defaults to 'percona_repo_contains_proxysql'
repo url for the yumrepo-resource in RedHat-based systems, defaults to 'http://repo.percona.com/release/$releasever/RPMS/$basearch'
key utl for the yumrepo-resource in RedHat-based systems, defaults to 'https://www.percona.com/downloads/RPM-GPG-KEY-percona'
Which configuration variables should be overriden. Hash, defaults to {} (empty hash).
proxy_global_variable
manages a variable in the ProxySQL global_variables
admin table.
The name of the variable.
Specifies wheter the resource should be immediately loaded to the active runtime. Boolean, defaults to 'true'.
Specifies wheter the resource should be immediately save to disk. Boolean, defaults to 'true'.
The value of the variable.
proxy_mysql_replication_hostgroup
manages an entry in the ProxySQL mysql_replication_hostgroups
admin table.
Whether the resource is present. Valid values are 'present', 'absent'. Defaults to 'present'.
Name to describe the hostgroup config. Must be in a 'writer_hostgroup
-reader_hostgroup
' format.
Specifies wheter the resource should be immediately loaded to the active runtime. Boolean, defaults to 'true'.
Specifies wheter the resource should be immediately save to disk. Boolean, defaults to 'true'.
Id of the writer hostgroup. Required.
Id of the reader hostgroup. Required.
Optional comment.
proxy_mysql_server
manages an entry in the ProxySQL mysql_servers
admin table.
Whether the resource is present. Valid values are 'present', 'absent'. Defaults to 'present'.
Name to describe the hostgroup config. Must be in a 'hostname
:port
-hostgroup_id
' format.
Specifies wheter the resource should be immediately loaded to the active runtime. Boolean, defaults to 'true'.
Specifies wheter the resource should be immediately save to disk. Boolean, defaults to 'true'.
Id of the hostgroup this server wil be configured to be part of. Integer value, required.
Hostname of the server. Required.
Port of the server. Required. Defaults to 3306.
Status of the server. Should be one of the following values: 'ONLINE', 'OFFLINE_SOFT', 'OFFLINE_HARD', 'SHUNNED'. Defaults to 'ONLINE'.
Weight value of the server. The higher the value, the higher the probability this server will be chosen from the hostgroup. Integer, defaults to 0.
Compression value of the serer. If the value is greater than 0, new connections to that server will use compression. Integer, defaults to 0.
The maximum number of connections ProxySQL will open to this backend server. Even though this server will have the highest weight, no new connections will be opened to it once this limit is hit. Please ensure that the backend is configured with a correct value of max_connections to avoid that ProxySQL will try to go beyond that limit. Integer, defaults to 1000.
If greater and 0, ProxySQL will reguarly monitor replication lag and if it goes beyond such threshold it will temporary shun the host until replication catch ups. Integer, defaults to 0.
If set to 1, connections to the backend will use SSL. Values 0 or 1. Defaults to 0.
Ping time is regularly monitored. If a host has a ping time greater than max_latency_ms it is excluded from the connection pool (although the server stays ONLINE. Integer, defaults to 0.
Optional comment.
proxy_mysql_user
manages an entry in the ProxySQL mysql_users
admin table.
Whether the resource is present. Valid values are 'present', 'absent'. Defaults to 'present'.
Username for the user. Required.
Specifies wheter the resource should be immediately loaded to the active runtime. Boolean, defaults to 'true'.
Specifies wheter the resource should be immediately save to disk. Boolean, defaults to 'true'.
Specifies wheter the user password should be encrypted (requires ProxySQL setting admin-hash_password
= true
). Boolean, defaults to 'true'.
Password for the user. Required.
Note: you should make sure that the global variable admin-hashed_passwords
is set to true
and then encrypt this password using the mysql_password()
function.
Flag to determine if this user is active or not. Values 0 or 1. Defaults to 1.
Flag to determine if this user uses SSL or not. Values 0 or 1. Defaults to 0.
Default hostgroup for the user. Integer, defaults to 0.
Default schema for the user. String, defaults to ''.
Is the user locked in the default_schema
or not. Values 0 or 1. Defaults to 0.
Disable routing across hostgroups once a transaction has started for a specific user. Values 0 or 1. Defaults to 0.
Flag to determine fast forward or not. Values 0 or 1. Defaults to 0.
Is this a backend user. Values 0 or 1. Defaults to 1.
Is this a frontend user. Values 0 or 1. Defaults to 1.
proxy_mysql_query_rule
manages an entry in the ProxySQL mysql_query_rules
admin table.
Whether the resource is present. Valid values are 'present', 'absent'. Defaults to 'present'.
The name of the query rule entry, Must be in a 'mysql_query_rule-rule_id
' format.
Specifies wheter the resource should be immediately loaded to the active runtime. Boolean, defaults to 'true'.
Specifies wheter the resource should be immediately save to disk. Boolean, defaults to 'true'.
Id of the scheduler entry. Integer value, required.
Is the rule active or not. Boolean value 0 or 1, defaults to 0.
Username to apply this rule to. String, defaults to NULL.
Schema to apply this rule to. String, defaults to NULL.
Used to chain rules. This is the id of the previous rule to apply. Integer, defaults to 0.
Used to chain rules. This is the id of the next rule to apply, Integer, defaults to NULL
Used to chain rules.
Match traffic from a certain address. String, defaults to NULL.
Match incoming traffic on a specific local address. String, defaults to NULL.
Match incoming traffic on a specific local port. Integer, defaults to NULL.
match queries with a specific digest, as returned by stats_mysql_query_digest
.digest
. String, defaults to NULL.
regular expression that matches the query digest. String, defaults to NULL.
regular expression that matches the query text. String, defaults to NULL.
this is the pattern with which to replace the matched pattern. String, defaults to NULL.
if this is set to 1, only queries not matching the query text will be considered as a match. This acts as a NOT operator in front of the regular expression matching against match_pattern or match_digest. Boolean value 0 or 1, defaults to 0.
The hostgroup to send this query to. Integer, defaults to NULL.
The amount of miliseconds to cache the result of this query. Integer, defaults to NULL.
feature currently not in use.
The maximum amount of miliseconds in which the matched or rewritten query should be executed. Integer, defaults to NULL.
The maximum number of times a query needs to be re-executed in case of detected failure during the execution of the query. Integer, defaults to NULL.
The number of milliseconds to delay the execution of the query. Integer, defaults to NULL.
The query will be blocked, and the specified error_msg will be returned to the client. String, defaults to NULL.
The query will be logged. Boolean value 0 or 1, defaults to NULL.
see https://github.com/sysown/proxysql/blob/master/doc/mirroring.md. Integer, defaults to NULL.
see https://github.com/sysown/proxysql/blob/master/doc/mirroring.md. Integer, defaults to NULL.
Optional free form text field, usable for a descriptive comment of the query rule.
proxy_scheduler
manages an entry in the ProxySQL scheduler
admin table.
Whether the resource is present. Valid values are 'present', 'absent'. Defaults to 'present'.
The name of the scheduler entry, Must be in a 'scheduler-scheduler_id
' format.
Specifies wheter the resource should be immediately loaded to the active runtime. Boolean, defaults to 'true'.
Specifies wheter the resource should be immediately save to disk. Boolean, defaults to 'true'.
Id of the scheduler entry. Integer value, required.
The filename of the scheduler script to run. Required.
Interval in which to run this scheduler. In miliseconds, Integer, defaults to 10000 (10sec).
The 1st argument for the scheduler script to run. Optional, defaults to NULL.
The 2nd argument for the scheduler script to run. Optional, defaults to NULL.
The 3rd argument for the scheduler script to run. Optional, defaults to NULL.
The 4th argument for the scheduler script to run. Optional, defaults to NULL.
The 5th argument for the scheduler script to run. Optional, defaults to NULL.
Optional comment.
The module requires Puppet 4.x and currently supports only Debian 8 "Jessie" (and possibly Debian 7 "Wheezy"). It depends on the puppetlabs/mysql module (>= 3.x)
This module is originally developed by Matthias Crauwels for use at Ghent University, Belgium. This module is published under the Apache 2.0 license.
We are open to feature requests, bug reports, contributions, etc...
Original author: Matthias Crauwels