mirror of
https://git.lapiole.org/dani/ansible-roles.git
synced 2025-07-26 15:55:56 +02:00
Update to 2021-12-01 19:13
This commit is contained in:
47
roles/mysql_server/templates/my.cnf.j2
Normal file
47
roles/mysql_server/templates/my.cnf.j2
Normal file
@@ -0,0 +1,47 @@
|
||||
[mysqld]
|
||||
datadir=/var/lib/mysql
|
||||
socket=/var/lib/mysql/mysql.sock
|
||||
symbolic-links=0
|
||||
{% if not mysql_networking | default(False) %}
|
||||
skip-networking
|
||||
{% endif %}
|
||||
{% if mysql_innodb_file_per_table | default(True) %}
|
||||
innodb_file_per_table
|
||||
{% endif %}
|
||||
{% if mysql_innodb_buffer_pool_size is defined %}
|
||||
innodb_buffer_pool_size={{ mysql_innodb_buffer_pool_size }}
|
||||
{% endif %}
|
||||
{% if mysql_innodb_buffer_pool_instances is defined %}
|
||||
innodb_buffer_pool_instances={{ mysql_innodb_buffer_pool_instances }}
|
||||
{% endif %}
|
||||
{% if mysql_innodb_log_buffer_size is defined %}
|
||||
innodb_log_buffer_size={{ mysql_innodb_log_buffer_size }}
|
||||
{% endif %}
|
||||
{% if mysql_innodb_flush_log_at_trx_commit is defined %}
|
||||
innodb_flush_log_at_trx_commit={{ mysql_innodb_flush_log_at_trx_commit }}
|
||||
{% endif %}
|
||||
{% if mysql_innodb_flush_method is defined %}
|
||||
innodb_flush_method={{ mysql_innodb_flush_method }}
|
||||
{% endif %}
|
||||
{% if mysql_innodb_log_file_size is defined %}
|
||||
innodb_log_file_size={{ mysql_innodb_log_file_size }}
|
||||
{% endif %}
|
||||
|
||||
{% if mysql_sql_mode | length > 0 %}
|
||||
sql_mode = {{ mysql_sql_mode | join(',') }}
|
||||
{% endif %}
|
||||
|
||||
max_allowed_packet={{ mysql_max_allowed_packet | default('16M') }}
|
||||
open_files_limit={{ mysql_open_files_limit | default('8192') }}
|
||||
max_connections={{ mysql_max_connections | default('300') }}
|
||||
|
||||
[mysqld_safe]
|
||||
{% if mysql_engine == 'mysql' %}
|
||||
log-error=/var/log/mysql/mysqld.log
|
||||
pid-file=/var/run/mysqld/mysqld.pid
|
||||
{% else %}
|
||||
log-error=/var/log/mariadb/mariadb.log
|
||||
pid-file=/var/run/mariadb/mariadb.pid
|
||||
{% endif %}
|
||||
|
||||
!includedir /etc/my.cnf.d
|
7
roles/mysql_server/templates/post-backup.j2
Normal file
7
roles/mysql_server/templates/post-backup.j2
Normal file
@@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
{% if mysql_remove_dump_after_backup | default(True) %}
|
||||
rm -f /home/lbkp/mysql/*.sql*
|
||||
{% endif %}
|
46
roles/mysql_server/templates/pre-backup.j2
Normal file
46
roles/mysql_server/templates/pre-backup.j2
Normal file
@@ -0,0 +1,46 @@
|
||||
#!/bin/sh
|
||||
|
||||
set -eo pipefail
|
||||
|
||||
# Get the .my.cnf from root
|
||||
HOME=/root
|
||||
PATH=/usr/bin:$PATH
|
||||
DEST=/home/lbkp/mysql
|
||||
|
||||
[ -d $DEST ] || mkdir -p $DEST
|
||||
|
||||
for DB in $(/usr/bin/mysqlshow | /bin/awk '{print $2}' | /bin/grep -v Databases)
|
||||
do
|
||||
if [[ "$DB" == "information_schema" ]]; then
|
||||
continue
|
||||
fi
|
||||
{% for db in mysql_skip_backup %}
|
||||
# {{ db }} is configured not to be backed up
|
||||
if [[ "$DB" == "{{ db }}" ]]; then
|
||||
echo "Skiping $DB as per configuration"
|
||||
continue
|
||||
fi
|
||||
{% endfor %}
|
||||
{% if mysql_compress_cmd %}
|
||||
{% if mysql_compress_cmd is search('p?xz') %}
|
||||
{% set compext = 'xz' %}
|
||||
{% elif mysql_compress_cmd is search('p?bzip2') %}
|
||||
{% set compext = 'bz2' %}
|
||||
{% elif mysql_compress_cmd is search('(pi)?gz') %}
|
||||
{% set compext = 'gz' %}
|
||||
{% elif mysql_compress_cmd is search('lzop') %}
|
||||
{% set compext = 'lzo' %}
|
||||
{% elif mysql_compress_cmd is search('lz4') %}
|
||||
{% set compext = 'lz4' %}
|
||||
{% elif mysql_compress_cmd is search('zstd') %}
|
||||
{% set compext = 'zst' %}
|
||||
{% else %}
|
||||
{% set compext = 'z' %}
|
||||
{% endif %}
|
||||
echo "Dumping $DB to $DEST/$DB.sql.{{ compext }}"
|
||||
/usr/bin/mysqldump --ignore-table=mysql.event --single-transaction --add-drop-table $DB | /bin/nice -n 10 {{ mysql_compress_cmd }} > $DEST/$DB.sql.{{ compext }}
|
||||
{% else %}
|
||||
echo "Dumping $DB to $DEST/$DB.sql"
|
||||
/usr/bin/mysqldump --ignore-table=mysql.event --single-transaction --add-drop-table $DB -r $DEST/$DB.sql
|
||||
{% endif %}
|
||||
done
|
2
roles/mysql_server/templates/root_my.cnf.j2
Normal file
2
roles/mysql_server/templates/root_my.cnf.j2
Normal file
@@ -0,0 +1,2 @@
|
||||
[client]
|
||||
password={{ my_root_pass.stdout }}
|
5
roles/mysql_server/templates/systemd_limits.conf.j2
Normal file
5
roles/mysql_server/templates/systemd_limits.conf.j2
Normal file
@@ -0,0 +1,5 @@
|
||||
[Service]
|
||||
LimitNOFILE={{ mysql_open_files_limit | default('8192') }}
|
||||
Restart=on-failure
|
||||
StartLimitInterval=0
|
||||
RestartSec=1
|
Reference in New Issue
Block a user