ansible_adanced_oci

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
ansible_adanced_oci [2022/02/08 21:13] andonovjansible_adanced_oci [2024/08/19 13:03] (current) andonovj
Line 696: Line 696:
  
 With this, we were able to setup replication using OCI and ansible. The resnap can be done as many time as needed. It will always clone the primary's block device and attach it on replica, then it will re-establish replication. With this, we were able to setup replication using OCI and ansible. The resnap can be done as many time as needed. It will always clone the primary's block device and attach it on replica, then it will re-establish replication.
 +
 +There is one more playbook which we need to add.
 +
 +<Code:bash|detach_iscsi>
 +---
 +
 +- name: Detach the device
 +  vars:
 +    ansible_user: opc
 +    ansible_become: yes
 +    ansible_become_method: sudo
 +
 +  hosts: '{{ instance_ip }}'
 +  tasks:
 +    - name: Find the IQN
 +      shell: |
 +        iscsiadm --mode session  -P 3 | grep Target: | head | awk -F " " '{print $2}'
 +      register: iqn
 +
 +    - name: Stop  MySQL
 +      service: name=mysqld state=stopped enabled=false
 +      when: iqn.stdout != ""
 +
 +    - name: Find possible processes holding the file system
 +      shell: |
 +        lsof +D /var/lib/mysql |  awk -F " " '{print $2}' | uniq | grep -v "PID"
 +      register: locking_processes
 +      ignore_errors: yes
 +
 +    - name: Print locking process
 +      debug:
 +        msg: '{{ locking_processes }}'
 +      when: locking_processes.stdout_lines|length != 0
 +
 +    - name: Kill and unmount the file system
 +      shell: |
 +        kill -9 '{{ item }}'
 +      with_items: '{{ locking_processes.stdout_lines }}'
 +      when: locking_processes.stdout_lines|length != 0
 +
 +    - name: Print IQN
 +      debug:
 +        msg: '{{iqn.stdout}}'
 +
 +    - name: Unmount File system
 +      mount:
 +        path: /var/lib/mysql
 +        state: unmounted
 +
 +    - name: Detach the iSCSI
 +      community.general.open_iscsi:
 +        login: no
 +        target: '{{iqn.stdout}}'
 +      when: iqn.stdout != ""
 +</Code>
 +
 +That playbook will stop the MySQL and detach the iSCSI from the compute node, so we can safely, remove it from the OCI as well.
 +
 +=====MySQL Clusterset Automation=====
 +This ansible project consists of 3 roles:
 +  - MySQL Instance
 +  - MySQL InnoDB Cluster
 +  - MySQL Router
 +
 +That will create architecture with 1 InnoDB Clusterset and a replicaset attached to it. The full code, you can see here:
 +
 +https://github.com/JulienAndonov/MySQL_Cluster_Ansible
 + 
  • ansible_adanced_oci.1644354828.txt.gz
  • Last modified: 2022/02/08 21:13
  • by andonovj