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_image: "{{ docker_registry ~ '/' if docker_registry else '' }}{{ docker_namespace }}/{{ kolla_base_distro }}-{{ kolla_install_type }}-mariadb"
|
||||||
mariadb_tag: "{{ openstack_release }}"
|
mariadb_tag: "{{ openstack_release }}"
|
||||||
mariadb_image_full: "{{ mariadb_image }}:{{ mariadb_tag }}"
|
mariadb_image_full: "{{ mariadb_image }}:{{ mariadb_tag }}"
|
||||||
|
|
||||||
|
########################################
|
||||||
|
# Vars used within recover_cluster.yml
|
||||||
|
########################################
|
||||||
|
mariadb_service: "{{ mariadb_services['mariadb'] }}"
|
||||||
|
@ -17,33 +17,30 @@
|
|||||||
- block:
|
- block:
|
||||||
- name: Stop MariaDB containers
|
- name: Stop MariaDB containers
|
||||||
kolla_docker:
|
kolla_docker:
|
||||||
name: "mariadb"
|
name: "{{ mariadb_service.container_name }}"
|
||||||
action: "stop_container"
|
action: "stop_container"
|
||||||
|
|
||||||
- name: Run MariaDB wsrep recovery
|
- name: Run MariaDB wsrep recovery
|
||||||
vars:
|
|
||||||
service_name: "mariadb"
|
|
||||||
service: "{{ mariadb_services[service_name] }}"
|
|
||||||
kolla_docker:
|
kolla_docker:
|
||||||
action: "start_container"
|
action: "start_container"
|
||||||
common_options: "{{ docker_common_options }}"
|
common_options: "{{ docker_common_options }}"
|
||||||
environment:
|
environment:
|
||||||
KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
|
KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
|
||||||
BOOTSTRAP_ARGS: "--wsrep-recover"
|
BOOTSTRAP_ARGS: "--wsrep-recover"
|
||||||
image: "{{ service.image }}"
|
image: "{{ mariadb_service.image }}"
|
||||||
labels:
|
labels:
|
||||||
BOOTSTRAP:
|
BOOTSTRAP:
|
||||||
name: "{{ service.container_name }}"
|
name: "{{ mariadb_service.container_name }}"
|
||||||
restart_policy: "never"
|
restart_policy: "never"
|
||||||
volumes: "{{ service.volumes }}"
|
volumes: "{{ mariadb_service.volumes }}"
|
||||||
|
|
||||||
- name: Stop MariaDB containers
|
- name: Stop MariaDB containers
|
||||||
kolla_docker:
|
kolla_docker:
|
||||||
name: "{{ service.container_name }}"
|
name: "{{ mariadb_service.container_name }}"
|
||||||
action: "stop_container"
|
action: "stop_container"
|
||||||
|
|
||||||
- name: Copying MariaDB log file to /tmp
|
- 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
|
- 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}'"
|
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
|
changed_when: true
|
||||||
|
|
||||||
- name: Copying grastate.dat file from MariaDB container in bootstrap host
|
- 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
|
changed_when: false
|
||||||
when:
|
when:
|
||||||
- bootstrap_host is defined
|
- bootstrap_host is defined
|
||||||
@ -97,7 +94,7 @@
|
|||||||
- name: Set grastate.dat file from MariaDB container in bootstrap host
|
- name: Set grastate.dat file from MariaDB container in bootstrap host
|
||||||
lineinfile:
|
lineinfile:
|
||||||
dest: /tmp/kolla_mariadb_grastate.dat
|
dest: /tmp/kolla_mariadb_grastate.dat
|
||||||
regexp: 'safe_to_bootstrap: 0'
|
regexp: 'safe_to_bootstrap:(.*)$'
|
||||||
line: 'safe_to_bootstrap: 1'
|
line: 'safe_to_bootstrap: 1'
|
||||||
state: present
|
state: present
|
||||||
when:
|
when:
|
||||||
@ -112,21 +109,18 @@
|
|||||||
- bootstrap_host == inventory_hostname
|
- bootstrap_host == inventory_hostname
|
||||||
|
|
||||||
- name: Starting first MariaDB container
|
- name: Starting first MariaDB container
|
||||||
vars:
|
|
||||||
service_name: "mariadb"
|
|
||||||
service: "{{ mariadb_services[service_name] }}"
|
|
||||||
kolla_docker:
|
kolla_docker:
|
||||||
action: "start_container"
|
action: "start_container"
|
||||||
common_options: "{{ docker_common_options }}"
|
common_options: "{{ docker_common_options }}"
|
||||||
environment:
|
environment:
|
||||||
KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
|
KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
|
||||||
BOOTSTRAP_ARGS: "--wsrep-new-cluster"
|
BOOTSTRAP_ARGS: "--wsrep-new-cluster"
|
||||||
image: "{{ service.image }}"
|
image: "{{ mariadb_service.image }}"
|
||||||
labels:
|
labels:
|
||||||
BOOTSTRAP:
|
BOOTSTRAP:
|
||||||
name: "{{ service.container_name }}"
|
name: "{{ mariadb_service.container_name }}"
|
||||||
restart_policy: "never"
|
restart_policy: "never"
|
||||||
volumes: "{{ service.volumes }}"
|
volumes: "{{ mariadb_service.volumes }}"
|
||||||
when:
|
when:
|
||||||
- bootstrap_host is defined
|
- bootstrap_host is defined
|
||||||
- bootstrap_host == inventory_hostname
|
- bootstrap_host == inventory_hostname
|
||||||
@ -147,28 +141,25 @@
|
|||||||
- bootstrap_host == inventory_hostname
|
- bootstrap_host == inventory_hostname
|
||||||
|
|
||||||
- name: Set first MariaDB container as primary
|
- 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
|
no_log: True
|
||||||
when:
|
when:
|
||||||
- bootstrap_host is defined
|
- bootstrap_host is defined
|
||||||
- bootstrap_host == inventory_hostname
|
- bootstrap_host == inventory_hostname
|
||||||
|
|
||||||
- name: Restart slave MariaDB container
|
- name: Restart slave MariaDB container
|
||||||
vars:
|
|
||||||
service_name: "mariadb"
|
|
||||||
service: "{{ mariadb_services[service_name] }}"
|
|
||||||
kolla_docker:
|
kolla_docker:
|
||||||
action: "start_container"
|
action: "start_container"
|
||||||
common_options: "{{ docker_common_options }}"
|
common_options: "{{ docker_common_options }}"
|
||||||
environment:
|
environment:
|
||||||
KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
|
KOLLA_CONFIG_STRATEGY: "{{ config_strategy }}"
|
||||||
BOOTSTRAP_ARGS: " "
|
BOOTSTRAP_ARGS: " "
|
||||||
image: "{{ service.image }}"
|
image: "{{ mariadb_service.image }}"
|
||||||
labels:
|
labels:
|
||||||
BOOTSTRAP:
|
BOOTSTRAP:
|
||||||
name: "{{ service.container_name }}"
|
name: "{{ mariadb_service.container_name }}"
|
||||||
restart_policy: "never"
|
restart_policy: "never"
|
||||||
volumes: "{{ service.volumes }}"
|
volumes: "{{ mariadb_service.volumes }}"
|
||||||
when:
|
when:
|
||||||
- bootstrap_host is defined
|
- bootstrap_host is defined
|
||||||
- bootstrap_host != inventory_hostname
|
- bootstrap_host != inventory_hostname
|
||||||
|
Loading…
Reference in New Issue
Block a user