instance-mariadb.cfg.in 9.5 KB
Newer Older
1
{% if software_type == slap_software_type -%}
2
{% set json = json_module.loads(slapparameter_dict.get('mariadb-json', '{}')) -%}
3 4 5
{% set backup_periodicity = json.get('backup-periodicity', '0 22 * * *') -%}
{% set bin_directory = parameter_dict['buildout-bin-directory'] -%}

6 7 8 9 10 11 12 13 14
[buildout]
parts =
  publish-mariadb-url
  mariadb-instance
  logrotate
  logrotate-entry-mariadb
  cron
  cron-entry-logrotate
  cron-entry-mariadb-backup
15
  cron-entry-mariadb-backup-expire
16
  binary-link
17
  resiliency-exclude-file
18
  resiliency-after-import-script
19
  promise
20 21 22 23 24 25

eggs-directory = {{ eggs_directory }}
develop-eggs-directory = {{ develop_eggs_directory }}
offline = true

[publish-mariadb-url]
26
recipe = slapos.cookbook:publishurl
27
url = mysql://${mariadb-instance:user}:${mariadb-instance:password}@${mariadb-instance:ip}:${mariadb-instance:port}/${mariadb-instance:database}
28

29 30 31 32 33 34 35 36 37 38 39 40
[binary-wrap-base]
recipe = slapos.cookbook:wrapper
# Note: --defaults-file must be the first argument, otherwise wrapped binary
# will reject it.
command-line = "{{ mariadb_location }}/bin/${:command}" --defaults-file="${mariadb-instance:conf-file}"
wrapper-path = ${rootdirectory:bin}/${:command}
parameters-extra = true

[binary-wrap-mysqldump]
< = binary-wrap-base
command = mysqldump

41 42
[cron-entry-mariadb-backup]
recipe = slapos.cookbook:cron.d
43
cron-entries = ${cron:cron-entries}
44
name = mariadb-backup
45
frequency = {{ backup_periodicity }}
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
{# When binlogs are enabled:
# flush-logs: used so no manipulation on binlogs is needed to restore from
#   full + binlogs. The first binlog after a dump starts from dump snapshot and
#   can be fully restored.
# master-data: use value "2" as we are not in a replication case
#}
command = "${binary-wrap-mysqldump:wrapper-path}" -u root --all-databases --single-transaction --flush-logs --master-data=2 --socket=${mariadb-instance:socket} | {{ gzip_location }}/bin/gzip > "${directory:mariadb-backup-full}/$({{ coreutils_location }}/bin/date "+%Y%m%d%H%M%S").sql.gz"
{# KEEP GLOB PATTERN IN SYNC with generated filenames above
#           YYYYmmddHHMMSS -#}
file-glob = ??????????????.sql.gz

[cron-entry-mariadb-backup-expire]
recipe = slapos.cookbook:cron.d
cron-entries = ${cron:cron-entries}
name = mariadb-backup-expire
61
frequency = {{ backup_periodicity }}
62
command = {{ findutils_location }}/bin/find "${directory:mariadb-backup-full}" -maxdepth 1 -name "${cron-entry-mariadb-backup:file-glob}" -daystart -mtime +7 -delete
63 64

[mariadb-instance]
65 66
# XXX: remove backup part of this recipe. Backup part is now done in previous sections.
# Keeping it is harmless because it is supposed to be launched by cron entry, which has been removed.
67 68 69 70
recipe = slapos.cookbook:generic.mysql

# Options
user = user
71
parallel-test-database-amount = ${slap-parameter:test-database-amount}
72
port = 45678
73
ip = ${slap-network-information:local-ipv4}
74 75 76 77 78 79
database = erp5
test-user = erp5_test
test-database = erp5_test
mysql-test-database-base = testdb
mysql-test-user-base = testuser

80 81 82 83 84
# Backup
binlog-path = ${directory:mariadb-backup-incremental}/binlog
# XXX: binlog rotation happens along with other log's rotation
binlog-expire-days = 7

85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
# Paths
wrapper = ${basedirectory:services}/mariadb
update-wrapper = ${basedirectory:services}/mariadb_update
backup-script = ${rootdirectory:bin}/innobackupex-controller
full-backup-directory = ${directory:mariadb-backup-full}
incremental-backup-directory = ${directory:mariadb-backup-incremental}
data-directory = ${directory:mariadb-data}
pid-file = ${basedirectory:run}/mariadb.pid
socket = ${basedirectory:run}/mariadb.sock
error-log = ${basedirectory:log}/mariadb_error.log
slow-query-log = ${basedirectory:log}/mariadb_slowquery.log
conf-file = ${rootdirectory:etc}/mariadb.cnf
bin-directory = ${rootdirectory:bin}
innobackupex-incremental = ${rootdirectory:bin}/innobackupex-incremental
innobackupex-full = ${rootdirectory:bin}/innobackupex-full

# Binary information
102 103 104 105 106 107
innobackupex-binary = {{ xtrabackup_location }}/bin/innobackupex
mysql-base-directory = {{ mariadb_location }}
mysql-binary = {{ mariadb_location }}/bin/mysql
mysql-install-binary = {{ mariadb_location }}/scripts/mysql_install_db
mysql-upgrade-binary = {{ mariadb_location }}/bin/mysql_upgrade
mysqld-binary = {{ mariadb_location }}/bin/mysqld
108
pt-align-binary = {{ perl_siteprefix }}/bin/pt-align
109 110 111
pt-archiver-binary = {{ perl_siteprefix }}/bin/pt-archiver
pt-config-diff-binary = {{ perl_siteprefix }}/bin/pt-config-diff
pt-deadlock-logger-binary = {{ perl_siteprefix }}/bin/pt-deadlock-logger
112
pt-diskstats-binary = {{ perl_siteprefix }}/bin/pt-diskstats
113 114 115
pt-duplicate-key-checker-binary = {{ perl_siteprefix }}/bin/pt-duplicate-key-checker
pt-fifo-split-binary = {{ perl_siteprefix }}/bin/pt-fifo-split
pt-find-binary = {{ perl_siteprefix }}/bin/pt-find
116
pt-fingerprint-binary = {{ perl_siteprefix }}/bin/pt-fingerprint
117 118 119
pt-fk-error-logger-binary = {{ perl_siteprefix }}/bin/pt-fk-error-logger
pt-heartbeat-binary = {{ perl_siteprefix }}/bin/pt-heartbeat
pt-index-usage-binary = {{ perl_siteprefix }}/bin/pt-index-usage
120
pt-ioprofile-binary = {{ perl_siteprefix }}/bin/pt-ioprofile
121
pt-kill-binary = {{ perl_siteprefix }}/bin/pt-kill
122 123
pt-mext-binary = {{ perl_siteprefix }}/bin/pt-mext
pt-mysql-summary-binary = {{ perl_siteprefix }}/bin/pt-mysql-summary
124
pt-online-schema-change-binary = {{ perl_siteprefix }}/bin/pt-online-schema-change
125
pt-pmp-binary = {{ perl_siteprefix }}/bin/pt-pmp
126 127
pt-query-digest-binary = {{ perl_siteprefix }}/bin/pt-query-digest
pt-show-grants-binary = {{ perl_siteprefix }}/bin/pt-show-grants
128
pt-sift-binary = {{ perl_siteprefix }}/bin/pt-sift
129 130 131
pt-slave-delay-binary = {{ perl_siteprefix }}/bin/pt-slave-delay
pt-slave-find-binary = {{ perl_siteprefix }}/bin/pt-slave-find
pt-slave-restart-binary = {{ perl_siteprefix }}/bin/pt-slave-restart
132 133
pt-stalk-binary = {{ perl_siteprefix }}/bin/pt-stalk
pt-summary-binary = {{ perl_siteprefix }}/bin/pt-summary
134 135
pt-table-checksum-binary = {{ perl_siteprefix }}/bin/pt-table-checksum
pt-table-sync-binary = {{ perl_siteprefix }}/bin/pt-table-sync
136
pt-table-usage-binary = {{ perl_siteprefix }}/bin/pt-table-usage
137 138 139 140 141
pt-upgrade-binary = {{ perl_siteprefix }}/bin/pt-upgrade
pt-variable-advisor-binary = {{ perl_siteprefix }}/bin/pt-variable-advisor
pt-visual-explain-binary = {{ perl_siteprefix }}/bin/pt-visual-explain
xtrabackup-binary = {{ xtrabackup_location }}/bin/xtrabackup_51
perl-binary = {{ perl_location }}/bin/perl
142 143 144 145

[logrotate]
recipe = slapos.cookbook:logrotate
# Binaries
146 147 148
logrotate-binary = {{ logrotate_location }}/usr/sbin/logrotate
gzip-binary = {{ gzip_location }}/bin/gzip
gunzip-binary = {{ gzip_location }}/bin/gunzip
149 150 151 152 153 154 155 156 157 158 159 160
# Directories
wrapper = ${rootdirectory:bin}/logrotate
conf = ${rootdirectory:etc}/logrotate.conf
logrotate-entries = ${directory:logrotate-entries}
backup = ${directory:logrotate-backup}
state-file = ${rootdirectory:srv}/logrotate.status

[logrotate-entry-mariadb]
<= logrotate
recipe = slapos.cookbook:logrotate.d
name = mariadb
log = ${mariadb-instance:error-log} ${mariadb-instance:slow-query-log}
161
post = ${mariadb-instance:mysql-binary} --no-defaults -B --socket=${mariadb-instance:socket} -e "FLUSH LOGS"
162 163 164

[cron]
recipe = slapos.cookbook:cron
165
dcrond-binary = {{ dcron_location }}/sbin/crond
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186
cron-entries = ${directory:cron-entries}
crontabs = ${directory:crontabs}
cronstamps = ${directory:cronstamps}
catcher = ${cron-simplelogger:wrapper}
binary = ${basedirectory:services}/crond

[cron-simplelogger]
recipe = slapos.cookbook:simplelogger
wrapper = ${rootdirectory:bin}/cron_simplelogger
log = ${basedirectory:log}/cron.log

[cron-entry-logrotate]
<= cron
recipe = slapos.cookbook:cron.d
name = logrotate
frequency = 0 0 * * *
command = ${logrotate:wrapper}

[binary-link]
recipe = slapos.cookbook:symbolic.link
target-directory = ${rootdirectory:bin}
187
link-binary =
188 189 190 191 192 193 194 195 196 197
  {{ coreutils_location }}/bin/basename
  {{ coreutils_location }}/bin/cat
  {{ coreutils_location }}/bin/cp
  {{ coreutils_location }}/bin/ls
  {{ coreutils_location }}/bin/tr
  {{ coreutils_location }}/bin/uname
  {{ gettext_location }}/lib/gettext/hostname
  {{ grep_location }}/bin/grep
  {{ sed_location }}/bin/sed
  {{ mariadb_location }}/bin/mysql
198

199 200 201 202 203 204 205

[resiliency-exclude-file]
# Generate rdiff exclude file in case of resiliency
recipe = collective.recipe.template
input = inline: srv/mariadb/**
output = ${rootdirectory:srv}/exporter.exclude

206 207 208 209 210 211
[resiliency-after-import-script]
# Generate after import script used by importer instance of webrunner
recipe = collective.recipe.template
input = {{ mariadb_resiliency_after_import_script }}
output = ${rootdirectory:srv}/runner-import-restore
mode = 755
212
dash = {{ dash_location }}/bin/dash
213

214 215 216 217 218 219 220 221 222 223 224
[rootdirectory]
recipe = slapos.cookbook:mkdirectory
etc = ${buildout:directory}/etc
var = ${buildout:directory}/var
srv = ${buildout:directory}/srv
bin = ${buildout:directory}/bin

[basedirectory]
recipe = slapos.cookbook:mkdirectory
log = ${rootdirectory:var}/log
services = ${rootdirectory:etc}/run
225
promise = ${rootdirectory:etc}/promise
226 227 228 229 230 231 232 233 234 235 236 237 238 239 240
run = ${rootdirectory:var}/run
backup = ${rootdirectory:srv}/backup

[directory]
recipe = slapos.cookbook:mkdirectory
cron-entries = ${rootdirectory:etc}/cron.d
crontabs = ${rootdirectory:etc}/crontabs
cronstamps = ${rootdirectory:etc}/cronstamps
ca-dir = ${rootdirectory:srv}/ssl
mariadb-backup-full = ${basedirectory:backup}/mariadb-full
mariadb-backup-incremental = ${basedirectory:backup}/mariadb-incremental
mariadb-data = ${rootdirectory:srv}/mariadb
logrotate-backup = ${basedirectory:backup}/logrotate
logrotate-entries = ${rootdirectory:etc}/logrotate.d

241 242 243 244 245
[promise]
recipe = slapos.cookbook:check_port_listening
path = ${basedirectory:promise}/mariadb
hostname = ${mariadb-instance:ip}
port = ${mariadb-instance:port}
246 247 248

[slap-parameter]
test-database-amount = 100
249
{%- endif %}