diff --git a/ansible/group_vars/all.yml b/ansible/group_vars/all.yml index d5daa6ea3f164a8d3ebd3fd60ab2e2edc4de07c4..cf3e4ca52b34799e88a932a0df3eb997a95ddf53 100644 --- a/ansible/group_vars/all.yml +++ b/ansible/group_vars/all.yml @@ -625,6 +625,9 @@ enable_manila_backend_generic: "no" enable_manila_backend_hnas: "no" enable_manila_backend_cephfs_native: "no" enable_manila_backend_cephfs_nfs: "no" +# TODO(mgoddard): Change this to a plain "no" when support enable_xtrabackup +# has been removed. +enable_mariabackup: "{{ enable_xtrabackup | default('no') }}" enable_masakari: "no" enable_mistral: "no" enable_monasca: "no" @@ -676,7 +679,6 @@ enable_trove_singletenant: "no" enable_vitrage: "no" enable_vmtp: "no" enable_watcher: "no" -enable_xtrabackup: "no" enable_zookeeper: "{{ enable_kafka | bool }}" enable_zun: "no" diff --git a/ansible/mariadb_backup.yml b/ansible/mariadb_backup.yml index 008726bd839f527548fefc8789a4d75735af787d..e143819be2380a4a204529aa331763a9d14d73c7 100644 --- a/ansible/mariadb_backup.yml +++ b/ansible/mariadb_backup.yml @@ -4,4 +4,4 @@ roles: - { role: mariadb, tags: mariadb, - when: enable_xtrabackup | bool } + when: enable_mariabackup | bool } diff --git a/ansible/roles/mariadb/defaults/main.yml b/ansible/roles/mariadb/defaults/main.yml index 054eb9bd59311cc33a113ff4203ffadf058ebfbe..1b822e772d1562b176c190ecea1214e30c665b01 100644 --- a/ansible/roles/mariadb/defaults/main.yml +++ b/ansible/roles/mariadb/defaults/main.yml @@ -72,9 +72,9 @@ mariadb_service: "{{ mariadb_services['mariadb'] }}" #################### # Backups #################### -xtrabackup_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ mariadb_install_type }}-xtrabackup" -xtrabackup_tag: "{{ openstack_release }}" -xtrabackup_image_full: "{{ xtrabackup_image }}:{{ xtrabackup_tag }}" +mariabackup_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ mariadb_install_type }}-mariadb" +mariabackup_tag: "{{ openstack_release }}" +mariabackup_image_full: "{{ mariabackup_image }}:{{ mariabackup_tag }}" mariadb_backup_host: "{{ groups['mariadb'][0] }}" mariadb_backup_database_schema: "PERCONA_SCHEMA" diff --git a/ansible/roles/mariadb/tasks/backup.yml b/ansible/roles/mariadb/tasks/backup.yml index 1895b61cac29026f0c0bdb514ffefc0dd076f500..8923d91f59e9d307e2dc606dedd690f0f634503d 100644 --- a/ansible/roles/mariadb/tasks/backup.yml +++ b/ansible/roles/mariadb/tasks/backup.yml @@ -1,20 +1,22 @@ --- -- name: Taking {{ mariadb_backup_type }} database backup via XtraBackup +- name: Taking {{ mariadb_backup_type }} database backup via Mariabackup become: true kolla_docker: action: "start_container" + command: "bash -c 'sudo -E kolla_set_configs && /usr/local/bin/kolla_mariadb_backup.sh'" common_options: "{{ docker_common_options }}" - image: "{{ xtrabackup_image_full }}" - name: "xtrabackup" + detach: False + image: "{{ mariabackup_image_full }}" + name: "mariabackup" restart_policy: no remove_on_exit: True environment: BACKUP_TYPE: "{{ mariadb_backup_type }}" volumes: - - "{{ node_config_directory }}xtrabackup:/etc/mysql:ro" + - "{{ node_config_directory }}/mariabackup/:{{ container_config_directory }}/:ro" - "/etc/localtime:/etc/localtime:ro" + - "mariadb:/var/lib/mysql" - "mariadb_backup:/backup" - volumes_from: - - "mariadb" + - "kolla_logs:/var/log/kolla/" when: - inventory_hostname == mariadb_backup_host diff --git a/ansible/roles/mariadb/tasks/config.yml b/ansible/roles/mariadb/tasks/config.yml index 1a58767c76f1d437bb37dd29831027afa0130af1..e8eca2db2572d1e52fc40ee27fd853c9cebd77a4 100644 --- a/ansible/roles/mariadb/tasks/config.yml +++ b/ansible/roles/mariadb/tasks/config.yml @@ -14,29 +14,29 @@ - name: Ensuring database backup config directory exists file: - path: "{{ node_config_directory }}xtrabackup" + path: "{{ node_config_directory }}/mariabackup" state: "directory" owner: "{{ config_owner_user }}" group: "{{ config_owner_group }}" mode: "0770" become: true when: - - enable_xtrabackup | bool + - enable_mariabackup | bool - inventory_hostname == mariadb_backup_host -- name: Copying over my.cnf for xtrabackup +- name: Copying over my.cnf for mariabackup merge_configs: sources: - "{{ role_path }}/templates/backup.my.cnf.j2" - "{{ node_custom_config }}/backup.my.cnf" - "{{ node_custom_config }}/mariadb/{{ inventory_hostname }}/backup.my.cnf" - dest: "{{ node_config_directory }}xtrabackup/my.cnf" + dest: "{{ node_config_directory }}/mariabackup/my.cnf" owner: "{{ config_owner_user }}" group: "{{ config_owner_group }}" mode: "0660" become: true when: - - enable_xtrabackup | bool + - enable_mariabackup | bool - inventory_hostname == mariadb_backup_host - name: Copying over config.json files for services @@ -54,6 +54,18 @@ notify: - restart mariadb +- name: Copying over config.json files for mariabackup + vars: + service_name: "mariabackup" + template: + src: "{{ service_name }}.json.j2" + dest: "{{ node_config_directory }}/{{ service_name }}/config.json" + mode: "0660" + become: true + when: + - enable_mariabackup | bool + - inventory_hostname == mariadb_backup_host + - name: Copying over galera.cnf vars: service_name: "mariadb" diff --git a/ansible/roles/mariadb/tasks/register.yml b/ansible/roles/mariadb/tasks/register.yml index 87697e9f82f8d88b04c9600ac2054a03a1d94349..b4b87d97f35626fc9216c3f17e2b3f4b06059bfb 100644 --- a/ansible/roles/mariadb/tasks/register.yml +++ b/ansible/roles/mariadb/tasks/register.yml @@ -16,7 +16,7 @@ - import_tasks: wait_for_loadbalancer.yml -- name: Creating the Percona XtraBackup database +- name: Creating the Mariabackup database become: true kolla_toolbox: module_name: mysql_db @@ -28,7 +28,7 @@ name: "{{ mariadb_backup_database_schema }}" run_once: True when: - - enable_xtrabackup | bool + - enable_mariabackup | bool - name: Creating database backup user and setting permissions become: true @@ -46,9 +46,9 @@ append_privs: True run_once: True when: - - enable_xtrabackup | bool + - enable_mariabackup | bool -- name: Granting permissions on XtraBackup database to backup user +- name: Granting permissions on Mariabackup database to backup user become: true kolla_toolbox: module_name: mysql_user @@ -64,7 +64,7 @@ append_privs: True run_once: True when: - - enable_xtrabackup | bool + - enable_mariabackup | bool - name: Cleaning up facts set_fact: diff --git a/ansible/roles/mariadb/templates/mariabackup.json.j2 b/ansible/roles/mariadb/templates/mariabackup.json.j2 new file mode 100644 index 0000000000000000000000000000000000000000..ff32de2b6763f8e83bd3dfbc1b6c6de6b7ec3cd9 --- /dev/null +++ b/ansible/roles/mariadb/templates/mariabackup.json.j2 @@ -0,0 +1,21 @@ +{ + "command": "false", + "config_files": [ + { + "source": "{{ container_config_directory }}/my.cnf", + "dest": "/etc/mysql/my.cnf", + "owner": "mysql", + "perm": "0600" + } + ], + "permissions": [ + { + "path": "/var/log/kolla/mariadb", + "owner": "mysql:mysql" + }, + { + "path": "/backup", + "owner": "mysql:mysql" + } + ] +} diff --git a/doc/source/admin/mariadb-backup-and-restore.rst b/doc/source/admin/mariadb-backup-and-restore.rst index dc6b8517c5d7f29911cbb4adfb137860bb7038f7..8f3e85dce2a8acf68f2945d2553c6c41fb03425c 100644 --- a/doc/source/admin/mariadb-backup-and-restore.rst +++ b/doc/source/admin/mariadb-backup-and-restore.rst @@ -5,7 +5,7 @@ MariaDB database backup and restore =================================== Kolla-Ansible can facilitate either full or incremental backups of data -hosted in MariaDB. It achieves this using Percona's Xtrabackup, a tool +hosted in MariaDB. It achieves this using Mariabackup, a tool designed to allow for 'hot backups' - an approach which means that consistent backups can be taken without any downtime for your database or your cloud. @@ -27,7 +27,7 @@ Firstly, enable backups via ``globals.yml``: .. code-block:: console - enable_xtrabackup: "yes" + enable_mariabackup: "yes" Then, kick off a reconfiguration of MariaDB: @@ -67,38 +67,49 @@ backups scheduled via a cron job. Restoring backups ~~~~~~~~~~~~~~~~~ -Owing to the way in which XtraBackup performs hot backups, there are some +Owing to the way in which Mariabackup performs hot backups, there are some steps that must be performed in order to prepare your data before it can be copied into place for use by MariaDB. This process is currently manual, but -the Kolla XtraBackup image includes the tooling necessary to successfully +the Kolla Mariabackup image includes the tooling necessary to successfully prepare backups. Two examples are given below. Full ---- -For a full backup, start a new container using the XtraBackup image with the +For a full backup, start a new container using the Mariabackup image with the following options on the master database node: .. code-block:: console - docker run -it --volumes-from mariadb --name dbrestore \ - -v mariadb_backup:/backup kolla/centos-binary-xtrabackup:rocky \ + docker run --rm -it --volumes-from mariadb --name dbrestore \ + --volume mariadb_backup:/backup \ + kolla/centos-binary-mariadb:train \ /bin/bash - cd /backup - mkdir -p /restore/full - cat mysqlbackup-04-10-2018.xbc.xbs | xbstream -x -C /restore/full/ - innobackupex --decompress /restore/full - find /restore -name *.qp -exec rm {} \; - innobackupex --apply-log /restore/full + (dbrestore) $ cd /backup + (dbrestore) $ rm -rf /backup/restore + (dbrestore) $ mkdir -p /backup/restore/full + (dbrestore) $ gunzip mysqlbackup-04-10-2018.xbc.xbs.gz + (dbrestore) $ mbstream -x -C /backup/restore/full/ < mysqlbackup-04-10-2018.xbc.xbs + (dbrestore) $ mariabackup --prepare --target-dir /backup/restore/full -Then stop the MariaDB instance, delete the old data files (or move -them elsewhere), and copy the backup into place: +Stop the MariaDB instance. .. code-block:: console docker stop mariadb - rm -rf /var/lib/mysql/* /var/lib/mysql/.* - innobackupex --copy-back /restore/full + +Delete the old data files (or move them elsewhere), and copy the backup into +place: + +.. code-block:: console + + docker run --rm -it --volumes-from mariadb --name dbrestore \ + --volume mariadb_backup:/backup \ + kolla/centos-binary-mariadb:train \ + /bin/bash + (dbrestore) $ rm -rf /var/lib/mysql/* + (dbrestore) $ rm -rf /var/lib/mysql/\.[^\.]* + (dbrestore) $ mariabackup --copy-back --target-dir /backup/restore/full Then you can restart MariaDB with the restored data in place: @@ -121,20 +132,20 @@ incremental backup, .. code-block:: console - docker run -it --volumes-from mariadb --name dbrestore \ - -v mariadb_backup:/backup kolla/centos-binary-xtrabackup:rocky \ + docker run --rm -it --volumes-from mariadb --name dbrestore \ + --volume mariadb_backup:/backup --tmpfs /backup/restore \ + kolla/centos-binary-mariadb:train \ /bin/bash - cd /backup - mkdir -p /restore/full - mkdir -p /restore/inc/11 - cat mysqlbackup-06-11-2018-1541505206.qp.xbc.xbs | xbstream -x -C /restore/full/ - cat incremental-11-mysqlbackup-06-11-2018-1541505223.qp.xbc.xbs | xbstream -x -C /restore/inc/11 - innobackupex --decompress /restore/full - innobackupex --decompress /restore/inc/11 - find /restore -name *.qp -exec rm {} \; - innobackupex --apply-log --redo-only /restore/full - innobackupex --apply-log --redo-only --incremental-dir=/restore/inc/11 /restore/full - innobackupex --apply-log /restore/full + (dbrestore) $ cd /backup + (dbrestore) $ rm -rf /backup/restore + (dbrestore) $ mkdir -p /backup/restore/full + (dbrestore) $ mkdir -p /backup/restore/inc + (dbrestore) $ gunzip mysqlbackup-06-11-2018-1541505206.qp.xbc.xbs.gz + (dbrestore) $ gunzip incremental-11-mysqlbackup-06-11-2018-1541505223.qp.xbc.xbs.gz + (dbrestore) $ mbstream -x -C /backup/restore/full/ < mysqlbackup-06-11-2018-1541505206.qp.xbc.xbs + (dbrestore) $ mbstream -x -C /backup/restore/inc < incremental-11-mysqlbackup-06-11-2018-1541505223.qp.xbc.xbs + (dbrestore) $ mariabackup --prepare --target-dir /backup/restore/full + (dbrestore) $ mariabackup --prepare --incremental-dir=/backup/restore/inc --target-dir /backup/restore/full At this point the backup is prepared and ready to be copied back into place, as per the previous example. diff --git a/etc/kolla/globals.yml b/etc/kolla/globals.yml index b109da5d55e2cd2893b5869c2f38ff621d0d7977..5b34dcc24b35fb3c0e106d759f5790bc01ea4ae8 100644 --- a/etc/kolla/globals.yml +++ b/etc/kolla/globals.yml @@ -296,6 +296,7 @@ #enable_manila_backend_hnas: "no" #enable_manila_backend_cephfs_native: "no" #enable_manila_backend_cephfs_nfs: "no" +#enable_mariabackup: "no" #enable_masakari: "no" #enable_mistral: "no" #enable_monasca: "no" @@ -346,7 +347,6 @@ #enable_vitrage: "no" #enable_vmtp: "no" #enable_watcher: "no" -#enable_xtrabackup: "no" #enable_zookeeper: "{{ enable_kafka | bool }}" #enable_zun: "no" diff --git a/releasenotes/notes/mariabackup-bd3b238823e589da.yaml b/releasenotes/notes/mariabackup-bd3b238823e589da.yaml new file mode 100644 index 0000000000000000000000000000000000000000..55489a66f9b0c94b6e6ca498dba799ccd55c0854 --- /dev/null +++ b/releasenotes/notes/mariabackup-bd3b238823e589da.yaml @@ -0,0 +1,13 @@ +--- +upgrade: + - | + Changes the database backup procedure to use ``mariabackup`` which is + compatible with MariaDB 10.3. The ``qpress`` based compression used + previously is now replaced with ``gzip``. The documented restore procedure + has been modified accordingly. See the `Mariabackup documentation + <https://mariadb.com/kb/en/library/mariabackup-overview/>`__ for further + information. +deprecations: + - | + The ``enable_xtrabackup`` variable is deprecated in favour of + ``enable_mariabackup``.