Quantcast
Channel: 日々の覚書
Viewing all articles
Browse latest Browse all 581

MariaDB 10.0のMulti-source replicationを試す

$
0
0
MariaDB 10.0.2でインプリメントされたMulti-source replication(1スレーブに複数マスター構成)、MySQL 5.6に紛れて試していなかったんだけれど時間があったのでちょっとだけ試してみた。

リファレンス ⇒ https://mariadb.com/kb/en/multi-source-replication/

MariaDB KnowledgebaseはWEB遅い、マニュアル見づらい感。。



mariadb> SHOW ALL SLAVES STATUS\G
Empty set (0.00 sec)

mariadb> CHANGE MASTER 'mysql56' TO master_host= 'localhost', master_port= 64056, master_user= 'replicator', master_log_file= 'bin.000001', master_log_pos= 1;
Query OK, 0 rows affected (0.03 sec)

mariadb> SHOW SLAVE 'mysql56' STATUS\G
*************************** 1. row ***************************
Slave_IO_State:
Master_Host: localhost
Master_User: replicator
Master_Port: 64056
Connect_Retry: 60
Master_Log_File: bin.000001
Read_Master_Log_Pos: 4
Relay_Log_File: relay-mysql56.000001
Relay_Log_Pos: 4
Relay_Master_Log_File: bin.000001
Slave_IO_Running: No
Slave_SQL_Running: No
..
1 row in set (0.00 sec)

mariadb> CHANGE MASTER 'mysql55' TO master_host= 'localhost', master_port= 64055, master_user= 'replicator', master_log_file= 'bin.000001', master_log_pos= 1;
Query OK, 0 rows affected (0.02 sec)

mariadb> SHOW ALL SLAVES STATUS\G
*************************** 1. row ***************************
Connection_name: mysql55
Slave_SQL_State:
Slave_IO_State:
Master_Host: localhost
Master_User: replicator
Master_Port: 64055
Connect_Retry: 60
Master_Log_File: bin.000001
Read_Master_Log_Pos: 4
Relay_Log_File: relay-mysql55.000001
Relay_Log_Pos: 4
Relay_Master_Log_File: bin.000001
Slave_IO_Running: No
Slave_SQL_Running: No
..
*************************** 2. row ***************************
Connection_name: mysql56
Slave_SQL_State:
Slave_IO_State:
Master_Host: localhost
Master_User: replicator
Master_Port: 64056
Connect_Retry: 60
Master_Log_File: bin.000001
Read_Master_Log_Pos: 4
Relay_Log_File: relay-mysql56.000001
Relay_Log_Pos: 4
Relay_Master_Log_File: bin.000001
Slave_IO_Running: No
Slave_SQL_Running: No
..
2 rows in set (0.00 sec)

mariadb> SHOW SLAVE STATUS\G
Empty set (0.00 sec)

mariadb> SET SESSION default_master_connection= 'mysql55';
Query OK, 0 rows affected (0.01 sec)

mariadb> SHOW SLAVE STATUS\G
*************************** 1. row ***************************
Slave_IO_State:
Master_Host: localhost
Master_User: replicator
Master_Port: 64055
Connect_Retry: 60
Master_Log_File: bin.000001
Read_Master_Log_Pos: 107
Relay_Log_File: relay-mysql55.000001
Relay_Log_Pos: 4
Relay_Master_Log_File: bin.000001
Slave_IO_Running: No
Slave_SQL_Running: No
..

mariadb> START SLAVE;
ERROR 1200 (HY000): The server is not configured as slave; fix in config file or with CHANGE MASTER TO

こんな感じで設定。
取り敢えずハマったのは、
  • SHOW ALL SLAVESとか。
  • SET SESSION default_master_connectionしておくと、コネクション名を指定しないSTART SLAVEとかはそのコネクションあてになる。
  • connection name(mysql55とかmysql56とかしてるやつ)はクォートしないといけない。
  • START SLAVE 'mysql55'; もSTART ALL SLAVES; も何故か通らない(何が足りないのか調べてない。。)
    とはいえ、まあ何か面白そうですよね!

    以上、PHP Conference 2013のLT聞きながらでした。。


    【2013/09/17 12:49】
    START SLAVEできなかったのは、server-idを指定していなかったというまさかのオチでしたよ! orz

    Viewing all articles
    Browse latest Browse all 581

    Trending Articles