Merge "Improve mariadb_recovery"
This commit is contained in:
commit
0f2d547b2c
@ -26,3 +26,8 @@ database_max_timeout: 120
|
||||
mariadb_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ kolla_install_type }}-mariadb"
|
||||
mariadb_tag: "{{ openstack_release }}"
|
||||
mariadb_image_full: "{{ mariadb_image }}:{{ mariadb_tag }}"
|
||||
|
||||
########################################
|
||||
# Vars used within recover_cluster.yml
|
||||
########################################
|
||||
mariadb_service: "{{ mariadb_services['mariadb'] }}"
|
||||
|
@ -17,33 +17,30 @@
|
||||
- block:
|
||||
- name: Stop MariaDB containers
|
||||
kolla_docker:
|
||||
name: "mariadb"
|
||||
name: "{{ mariadb_service.container_name }}"
|
||||
action: "stop_container"
|
||||
|
||||
- name: Run MariaDB wsrep recovery
|
||||
vars:
|
||||
service_name: "mariadb"
|
||||
service: "{{ mariadb_services[service_name] }}"
|
||||
kolla_docker:
|
||||
action: "start_container"
|
||||
common_options: "{{ docker_common_options }}"
|
||||
environment:
|
||||
KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
|
||||
BOOTSTRAP_ARGS: "--wsrep-recover"
|
||||
image: "{{ service.image }}"
|
||||
image: "{{ mariadb_service.image }}"
|
||||
labels:
|
||||
BOOTSTRAP:
|
||||
name: "{{ service.container_name }}"
|
||||
name: "{{ mariadb_service.container_name }}"
|
||||
restart_policy: "never"
|
||||
volumes: "{{ service.volumes }}"
|
||||
volumes: "{{ mariadb_service.volumes }}"
|
||||
|
||||
- name: Stop MariaDB containers
|
||||
kolla_docker:
|
||||
name: "{{ service.container_name }}"
|
||||
name: "{{ mariadb_service.container_name }}"
|
||||
action: "stop_container"
|
||||
|
||||
- name: Copying MariaDB log file to /tmp
|
||||
shell: "docker cp {{ service.container_name }}:/var/log/kolla/mariadb/mariadb.log /tmp/mariadb_tmp.log"
|
||||
shell: "docker cp {{ mariadb_service.container_name }}:/var/log/kolla/mariadb/mariadb.log /tmp/mariadb_tmp.log"
|
||||
|
||||
- name: Get MariaDB wsrep recovery seqno
|
||||
shell: "tail -n 200 /tmp/mariadb_tmp.log | grep Recovered | tail -1 | awk '{print $7}' | awk -F'\n' '{print $1}' | awk -F':' '{print $2}'"
|
||||
@ -88,7 +85,7 @@
|
||||
changed_when: true
|
||||
|
||||
- name: Copying grastate.dat file from MariaDB container in bootstrap host
|
||||
command: docker cp mariadb:/var/lib/mysql/grastate.dat /tmp/kolla_mariadb_grastate.dat
|
||||
command: "docker cp {{ mariadb_service.container_name }}:/var/lib/mysql/grastate.dat /tmp/kolla_mariadb_grastate.dat"
|
||||
changed_when: false
|
||||
when:
|
||||
- bootstrap_host is defined
|
||||
@ -97,7 +94,7 @@
|
||||
- name: Set grastate.dat file from MariaDB container in bootstrap host
|
||||
lineinfile:
|
||||
dest: /tmp/kolla_mariadb_grastate.dat
|
||||
regexp: 'safe_to_bootstrap: 0'
|
||||
regexp: 'safe_to_bootstrap:(.*)$'
|
||||
line: 'safe_to_bootstrap: 1'
|
||||
state: present
|
||||
when:
|
||||
@ -112,21 +109,18 @@
|
||||
- bootstrap_host == inventory_hostname
|
||||
|
||||
- name: Starting first MariaDB container
|
||||
vars:
|
||||
service_name: "mariadb"
|
||||
service: "{{ mariadb_services[service_name] }}"
|
||||
kolla_docker:
|
||||
action: "start_container"
|
||||
common_options: "{{ docker_common_options }}"
|
||||
environment:
|
||||
KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
|
||||
BOOTSTRAP_ARGS: "--wsrep-new-cluster"
|
||||
image: "{{ service.image }}"
|
||||
image: "{{ mariadb_service.image }}"
|
||||
labels:
|
||||
BOOTSTRAP:
|
||||
name: "{{ service.container_name }}"
|
||||
name: "{{ mariadb_service.container_name }}"
|
||||
restart_policy: "never"
|
||||
volumes: "{{ service.volumes }}"
|
||||
volumes: "{{ mariadb_service.volumes }}"
|
||||
when:
|
||||
- bootstrap_host is defined
|
||||
- bootstrap_host == inventory_hostname
|
||||
@ -147,28 +141,25 @@
|
||||
- bootstrap_host == inventory_hostname
|
||||
|
||||
- name: Set first MariaDB container as primary
|
||||
shell: "docker exec mariadb mysql -uroot -p{{ database_password }} -e \"SET GLOBAL wsrep_provider_options='pc.bootstrap=yes';\""
|
||||
shell: "docker exec {{ mariadb_service.container_name }} mysql -uroot -p{{ database_password }} -e \"SET GLOBAL wsrep_provider_options='pc.bootstrap=yes';\""
|
||||
no_log: True
|
||||
when:
|
||||
- bootstrap_host is defined
|
||||
- bootstrap_host == inventory_hostname
|
||||
|
||||
- name: Restart slave MariaDB container
|
||||
vars:
|
||||
service_name: "mariadb"
|
||||
service: "{{ mariadb_services[service_name] }}"
|
||||
kolla_docker:
|
||||
action: "start_container"
|
||||
common_options: "{{ docker_common_options }}"
|
||||
environment:
|
||||
KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
|
||||
BOOTSTRAP_ARGS: " "
|
||||
image: "{{ service.image }}"
|
||||
image: "{{ mariadb_service.image }}"
|
||||
labels:
|
||||
BOOTSTRAP:
|
||||
name: "{{ service.container_name }}"
|
||||
name: "{{ mariadb_service.container_name }}"
|
||||
restart_policy: "never"
|
||||
volumes: "{{ service.volumes }}"
|
||||
volumes: "{{ mariadb_service.volumes }}"
|
||||
when:
|
||||
- bootstrap_host is defined
|
||||
- bootstrap_host != inventory_hostname
|
||||
|
Loading…
Reference in New Issue
Block a user