gpt4 book ai didi

mysql复制与ansible

转载 作者:行者123 更新时间:2023-11-30 22:20:09 25 4
gpt4 key购买 nike

我正在使用 Ansible 进行 mysql 复制。

我有以下 ansible 任务:

---
- name: update mysql config file
template:
src: templates/my.cnf.j2
dest: /etc/mysql/my.cnf
notify:
- restart mysql

- name: create replicator user
mysql_user:
name: "replicator"
host: "%"
password: "{{ mysql_replicator_password }}"
priv: "*.*:REPLICATION SLAVE"
state: present
notify:
- restart mysql

- name: Check replication init with checking file existence
stat: path=/etc/mysql/repl.ansible
register: check_sql_path

- mysql_replication:
mode: changemaster
master_host: "{{ groups.web[1] }}"
master_user: replicator
master_password: "{{ mysql_replicator_password }}"
when: groups.web[1] is defined and check_sql_path.stat.exists == false and '{{ inventory_hostname }}' == '{{ groups.web[0] }}'
notify:
- restart mysql

- command: touch /etc/mysql/repl.ansible
when: groups.web[1] is defined and check_sql_path.stat.exists == false and '{{ inventory_hostname }}' == '{{ groups.web[0] }}'

- mysql_replication:
mode: changemaster
master_host: "{{ groups.web[0] }}"
master_user: replicator
master_password: "{{ mysql_replicator_password }}"
when: groups.web[1] is defined and check_sql_path.stat.exists == false and '{{ inventory_hostname }}' == '{{ groups.web[1] }}'
notify:
- restart mysql

- command: touch /etc/mysql/repl.ansible
when: groups.web[1] is defined and check_sql_path.stat.exists == false and '{{ inventory_hostname }}' == '{{ groups.web[1] }}'

这个任务在我运行时没问题,但是当我使用 phpmyadmin 查看复制状态时,我收到以下消息(在两个服务器上):

  • Slave_IO_State:连接到 master
  • Slave_IO_Running:正在连接
  • Slave_SQL_Running:是

我不是 mysql 复制方面的专家,您认为有什么可以帮助我的吗?

(我遵循本教程:https://raymii.org/s/articles/Building_HA_Clusters_With_Ansible_and_Openstack.html)

谢谢

最佳答案

I'm not an expert in mysql replication, do you see anything can help me ?

它是在主-主复制中运行 mysql 的 2 个数据库服务器:

MySQL replication is the process by which a single data set, stored in a MySQL database, will be live-copied to a second server. This configuration, called "master-slave" replication.

Master-master replication allows data to be copied from either server to the other one. This subtle but important difference allows us to perform mysql read or writes from either server. This configuration adds redundancy and increases efficiency when dealing with accessing the data.

您的链接还描述了:

We also use a double when conditional. We need to set up the servers with each other's IP as the master. Therefore we need to run the setup for host A with the master IP of host B, and vice versa.

关于mysql复制与ansible,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36864514/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com