-
Notifications
You must be signed in to change notification settings - Fork 12
/
proxysql.cnf.j2
226 lines (214 loc) · 7.72 KB
/
proxysql.cnf.j2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
# {{ ansible_managed }}
# file proxysql.cfg
# proxysql.cfg in GitHub: https://github.com/sysown/proxysql/blob/master/etc/proxysql.cnf
########################################################################################
# This config file is parsed using libconfig , and its grammar is described in:
# http://www.hyperrealm.com/libconfig/libconfig_manual.html#Configuration-File-Grammar
# Grammar is also copied at the end of this file
########################################################################################
########################################################################################
# IMPORTANT INFORMATION REGARDING THIS CONFIGURATION FILE:
########################################################################################
# On startup, ProxySQL reads its config file (if present) to determine its datadir.
# What happens next depends on if the database file (disk) is present in the defined
# datadir (i.e. "/var/lib/proxysql/proxysql.db").
#
# If the database file is found, ProxySQL initializes its in-memory configuration from
# the persisted on-disk database. So, disk configuration gets loaded into memory and
# then propagated towards the runtime configuration.
#
# If the database file is not found and a config file exists, the config file is parsed
# and its content is loaded into the in-memory database, to then be both saved on-disk
# database and loaded at runtime.
#
# IMPORTANT: If a database file is found, the config file is NOT parsed. In this case
# ProxySQL initializes its in-memory configuration from the persisted on-disk
# database ONLY. In other words, the configuration found in the proxysql.cnf
# file is only used to initial the on-disk database read on the first startup.
#
# In order to FORCE a re-initialise of the on-disk database from the configuration file
# the ProxySQL service should be started with "service proxysql initial".
#
########################################################################################
datadir = "{{ proxysql_datadir | default('/var/lib/proxysql') }}"
# defines all admin variables
admin_variables =
{
{% if proxysql_global_variables_kv is defined %}
{% for key, value in proxysql_global_variables_kv.items() %}
{% if key.startswith("admin-") %}
{% if value is number %}
{{ key|replace("admin-", "") }} = {{ value }}
{% else %}
{{ key|replace("admin-", "") }} = "{{ value }}"
{% endif %}
{% endif %}
{% endfor %}
{% endif %}
}
# defines all MySQL variables
mysql_variables =
{
{% if proxysql_global_variables_kv is defined %}
{% for key, value in proxysql_global_variables_kv.items() %}
{% if key.startswith("mysql-") %}
{% if value is number %}
{{ key|replace("mysql-", "") }} = {{ value }}
{% else %}
{{ key|replace("mysql-", "") }} = "{{ value }}"
{% endif %}
{% endif %}
{% endfor %}
{% endif %}
}
# defines all MySQL servers
mysql_servers =
(
{% if proxysql_backend_servers is defined %}
{% for server in proxysql_backend_servers %}
{
{% if ("state" in proxysql_backend_servers[server] and proxysql_backend_servers[server].state != "absent") or ("state" not in proxysql_backend_servers[server]) %}
{% for key, value in proxysql_backend_servers[server].items() %}
{% if key not in proxysql_ignore_template_keys %}
{% if value is number %}
{{ key }} = {{ value }}
{% else %}
{{ key }} = "{{ value }}"
{% endif %}
{% endif %}
{% endfor %}
{% endif %}
}
{% if not loop.last %},{% endif %}
{% endfor %}
{% endif %}
)
# defines all MySQL users
mysql_users:
(
{% if proxysql_mysql_users is defined %}
{% for user in proxysql_mysql_users %}
{
{% if ("state" in proxysql_mysql_users[user] and proxysql_mysql_users[user].state != "absent") or ("state" not in proxysql_mysql_users[user]) %}
{% for key, value in proxysql_mysql_users[user].items() %}
{% if key not in proxysql_ignore_template_keys %}
{% if value is number %}
{{ key }} = {{ value }}
{% else %}
{{ key }} = "{{ value }}"
{% endif %}
{% endif %}
{% endfor %}
{% endif %}
}
{% if not loop.last %},{% endif %}
{% endfor %}
{% endif %}
)
# defines MySQL query rules
mysql_query_rules:
(
{% if proxysql_query_rules is defined %}
{% for query_rule in proxysql_query_rules %}
{
{% if ("state" in proxysql_query_rules[query_rule] and proxysql_query_rules[query_rule].state != "absent") or ("state" not in proxysql_query_rules[query_rule]) %}
{% for key, value in proxysql_query_rules[query_rule].items() %}
{% if key not in proxysql_ignore_template_keys %}
{% if value is number %}
{{ key }} = {{ value }}
{% else %}
{{ key }} = "{{ value }}"
{% endif %}
{% endif %}
{% endfor %}
{% endif %}
}
{% if not loop.last %},{% endif %}
{% endfor %}
{% endif %}
)
# defines all replication hostgroups
mysql_replication_hostgroups =
(
{% if proxysql_replication_hostgroups is defined %}
{% for replication_hostgroup in proxysql_replication_hostgroups %}
{
{% if ("state" in proxysql_replication_hostgroups[replication_hostgroup] and proxysql_replication_hostgroups[replication_hostgroup].state != "absent") or ("state" not in proxysql_replication_hostgroups[replication_hostgroup]) %}
{% for key, value in proxysql_replication_hostgroups[replication_hostgroup].items() %}
{% if key not in proxysql_ignore_template_keys %}
{% if value is number %}
{{ key }} = {{ value }}
{% else %}
{{ key }} = "{{ value }}"
{% endif %}
{% endif %}
{% endfor %}
{% endif %}
}
{% if not loop.last %},{% endif %}
{% endfor %}
{% endif %}
)
# defines all proxysql servers
proxysql_servers =
(
{% if proxysql_proxysql_servers is defined %}
{% for proxysql_server in proxysql_proxysql_servers %}
{
{% if ("state" in proxysql_proxysql_servers[proxysql_server] and proxysql_proxysql_servers[proxysql_server].state != "absent") or ("state" not in proxysql_proxysql_servers[proxysql_server]) %}
{% for key, value in proxysql_proxysql_servers[proxysql_server].items() %}
{% if key not in proxysql_ignore_template_keys %}
{% if value is number %}
{{ key }} = {{ value }}
{% else %}
{{ key }} = "{{ value }}"
{% endif %}
{% endif %}
{% endfor %}
{% endif %}
}
{% if not loop.last %},{% endif %}
{% endfor %}
{% endif %}
)
# defines schedulers
scheduler =
(
# {
# id = 1
# active = 0
# interval_ms = 10000
# filename = "/var/lib/proxysql/proxysql_galera_checker.sh"
# arg1 = "0"
# arg2 = "0"
# arg3 = "0"
# arg4 = "1"
# arg5 = "/var/lib/proxysql/proxysql_galera_checker.log"
# }
)
# http://www.hyperrealm.com/libconfig/libconfig_manual.html#Configuration-File-Grammar
#
# Below is the BNF grammar for configuration files. Comments and include directives are not part of the grammar, so they are not included here.
#
# configuration = setting-list | empty
#
# setting-list = setting | setting-list setting
#
# setting = name (":" | "=") value (";" | "," | empty)
#
# value = scalar-value | array | list | group
#
# value-list = value | value-list "," value
#
# scalar-value = boolean | integer | integer64 | hex | hex64 | float
# | string
#
# scalar-value-list = scalar-value | scalar-value-list "," scalar-value
#
# array = "[" (scalar-value-list | empty) "]"
#
# list = "(" (value-list | empty) ")"
#
# group = "{" (setting-list | empty) "}"
#
# empty =