2016-04-26 9 views
1

私はAnsibleでMySQLのレプリケーションを行っています。可能な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] }}' 

私はそれを実行したときに、このタスクはOKですが、私はphpMyAdminのレプリケーションの状態を見ると、私は次のメッセージ(両方のサーバ上に)持っている:

  • Slave_IO_State:
  • Slave_IO_Runningをマスターするの接続:はい
  • Slave_SQL_Runningを接続します

私は、MySQLのレプリケーションの専門家ではありませんが、何か私を助けることが表示されますか?

(私はこのチュートリアルは、次のとおりです。https://raymii.org/s/articles/Building_HA_Clusters_With_Ansible_and_Openstack.html)を

Thxを

+0

特権を与えてマスターを変更した後に再起動するのはなぜですか? – mannoj

答えて

0

私はあなたが何も私を助けることができます参照してくださいか、MySQLのレプリケーションの専門家ではありませんよ?

これは、マスター・マスター・レプリケーションでのMySQLの実行2台のデータベースサーバです:MySQLのレプリケーションは、MySQLデータベース に保存された単一のデータ・セットは、にライブコピーされるプロセスです

2番目のサーバー。この の設定は、「マスタースレーブ」レプリケーションと呼ばれます。

マスタマスターレプリケーションでは、サーバ から別のサーバにデータをコピーできます。この微妙ではあるが重要な違いは、 がどちらのサーバからもmysqlの読み書きを実行できることです。このコンフィグレーション は、データを にアクセスする際の冗長性を高め、効率を向上させます。

また、あなたのリンクがあることを説明します。際の条件我々はまた、二重を使用

。お互いのIPをマスタとしてサーバ を設定する必要があります。したがって、ホストBのマスターIPを使用してホストAの設定 を実行する必要があります(逆も同様です)。

関連する問題