以前の覚書 日々の覚書: Percona XtraDB Cluster設計の迷いどころ(現在進行形) で迷ってたんですが、気付いたらPITRフツーにできたのでメモ。
あの記事を書いた時点で検証していたのはwsrep 25.2.xだったんですが、wsrepも気付けば25.5.x (MySQLと同じで、25. x . y のうち25はAPIバージョンなので、wsrepのバージョンは2.x系から5.x系なのでメジャー2世代くらい?)、25.2.xと25.3.xの間で結構インプリメントされたような話は聞いてたんですが、そのせいなのかどうかはよく判らず。
( ´-`).oO(なんか25.2.xの時のcodershipのMLで、25.3.x(の初期)ではマルチマスターでPITRまだできないねー、みたいなのを読んだ気がしたんですがソース見つからず。
このディスカッション見ると、25.3.xと5.6の組み合わせで実装される予定(当時からすれば未来)だったのかなと思いますが。
http://www.linkedin.com/groups/How-do-pointintime-recovery-in-3973740.S.5802907499266850819
で、まあ、できました。
必要なのはmy.cnfにlog-slave-updates、これだけ。
これで、全てのインスタンスのバイナリーログに(ROWモードでだけど)記録されるようになる。
(前はこれができなかった。log-slave-updatesしても、実際にステートメントを実行したインスタンスのバイナリーログのみ)
というわけで、どれか1台以上のmysqldにmysqlbinlog -R --raw --stop-neverでつないでおけば、フツーのMySQLと同じようにPITRできそう。ビバ。
PlanetMySQL Voting: Vote UP / Vote DOWN
あの記事を書いた時点で検証していたのはwsrep 25.2.xだったんですが、wsrepも気付けば25.5.x (MySQLと同じで、25. x . y のうち25はAPIバージョンなので、wsrepのバージョンは2.x系から5.x系なのでメジャー2世代くらい?)、25.2.xと25.3.xの間で結構インプリメントされたような話は聞いてたんですが、そのせいなのかどうかはよく判らず。
( ´-`).oO(なんか25.2.xの時のcodershipのMLで、25.3.x(の初期)ではマルチマスターでPITRまだできないねー、みたいなのを読んだ気がしたんですがソース見つからず。
このディスカッション見ると、25.3.xと5.6の組み合わせで実装される予定(当時からすれば未来)だったのかなと思いますが。
http://www.linkedin.com/groups/How-do-pointintime-recovery-in-3973740.S.5802907499266850819
で、まあ、できました。
必要なのはmy.cnfにlog-slave-updates、これだけ。
これで、全てのインスタンスのバイナリーログに(ROWモードでだけど)記録されるようになる。
(前はこれができなかった。log-slave-updatesしても、実際にステートメントを実行したインスタンスのバイナリーログのみ)
mysql> use d1
Database changed
mysql> INSERT INTO t1 VALUES (1, 'one'), (2, 'two');
Query OK, 2 rows affected (0.01 sec)
Records: 2 Duplicates: 0 Warnings: 0
mysql> DELETE FROM t1 WHERE num= 1;
Query OK, 1 row affected (0.00 sec)
$ ll pxc*/bin*
-rw-rw---- 1 mysql mysql 501 Jul 9 08:28 pxc1/bin.000001
-rw-rw---- 1 mysql mysql 13 Jul 9 08:28 pxc1/bin.index
-rw-rw---- 1 mysql mysql 487 Jul 9 08:28 pxc2/bin.000001
-rw-rw---- 1 mysql mysql 13 Jul 9 08:28 pxc2/bin.index
-rw-rw---- 1 mysql mysql 487 Jul 9 08:28 pxc3/bin.000001
-rw-rw---- 1 mysql mysql 13 Jul 9 08:28 pxc3/bin.index
$ mysqlbinlog -vv pxc*/bin.000001 | grep "^#"
Warning: mysqlbinlog: unknown variable 'loose-default-character-set=utf8'
# at 4
#140709 8:28:26 server id 1 end_log_pos 120 Start: binlog v 4, server v 5.6.15-56-log created 140709 8:28:26 at startup
# Warning: this binlog is either in use or was not closed properly.
# at 120
#140709 8:28:42 server id 1 end_log_pos 191 Query thread_id=4 exec_time=0 error_code=0
# at 191
#140709 8:28:42 server id 1 end_log_pos 233 Table_map: `d1`.`t1` mapped to number 70
# at 233
#140709 8:28:42 server id 1 end_log_pos 290 Write_rows: table id 70 flags: STMT_END_F
### INSERT INTO `d1`.`t1`
### SET
### @1=1 /* LONGINT meta=0 nullable=0 is_null=0 */
### @2='one' /* VARSTRING(96) meta=96 nullable=1 is_null=0 */
### INSERT INTO `d1`.`t1`
### SET
### @1=2 /* LONGINT meta=0 nullable=0 is_null=0 */
### @2='two' /* VARSTRING(96) meta=96 nullable=1 is_null=0 */
# at 290
#140709 8:28:42 server id 1 end_log_pos 317 Xid = 12
# at 317
#140709 8:28:48 server id 1 end_log_pos 388 Query thread_id=4 exec_time=0 error_code=0
# at 388
#140709 8:28:48 server id 1 end_log_pos 430 Table_map: `d1`.`t1` mapped to number 70
# at 430
#140709 8:28:48 server id 1 end_log_pos 474 Delete_rows: table id 70 flags: STMT_END_F
### DELETE FROM `d1`.`t1`
### WHERE
### @1=1 /* LONGINT meta=0 nullable=0 is_null=0 */
### @2='one' /* VARSTRING(96) meta=96 nullable=1 is_null=0 */
# at 474
#140709 8:28:48 server id 1 end_log_pos 501 Xid = 13
# at 4
#140709 8:28:19 server id 1 end_log_pos 120 Start: binlog v 4, server v 5.6.15-56-log created 140709 8:28:19 at startup
# Warning: this binlog is either in use or was not closed properly.
# at 120
#140709 8:28:42 server id 1 end_log_pos 184 Query thread_id=4 exec_time=0 error_code=0
# at 184
#140709 8:28:42 server id 1 end_log_pos 226 Table_map: `d1`.`t1` mapped to number 70
# at 226
#140709 8:28:42 server id 1 end_log_pos 283 Write_rows: table id 70 flags: STMT_END_F
### INSERT INTO `d1`.`t1`
### SET
### @1=1 /* LONGINT meta=0 nullable=0 is_null=0 */
### @2='one' /* VARSTRING(96) meta=96 nullable=1 is_null=0 */
### INSERT INTO `d1`.`t1`
### SET
### @1=2 /* LONGINT meta=0 nullable=0 is_null=0 */
### @2='two' /* VARSTRING(96) meta=96 nullable=1 is_null=0 */
# at 283
#140709 8:28:42 server id 1 end_log_pos 310 Xid = 12
# at 310
#140709 8:28:48 server id 1 end_log_pos 374 Query thread_id=4 exec_time=0 error_code=0
# at 374
#140709 8:28:48 server id 1 end_log_pos 416 Table_map: `d1`.`t1` mapped to number 70
# at 416
#140709 8:28:48 server id 1 end_log_pos 460 Delete_rows: table id 70 flags: STMT_END_F
### DELETE FROM `d1`.`t1`
### WHERE
### @1=1 /* LONGINT meta=0 nullable=0 is_null=0 */
### @2='one' /* VARSTRING(96) meta=96 nullable=1 is_null=0 */
# at 460
#140709 8:28:48 server id 1 end_log_pos 487 Xid = 13
# at 4
#140709 8:28:22 server id 1 end_log_pos 120 Start: binlog v 4, server v 5.6.15-56-log created 140709 8:28:22 at startup
# Warning: this binlog is either in use or was not closed properly.
# at 120
#140709 8:28:42 server id 1 end_log_pos 184 Query thread_id=4 exec_time=0 error_code=0
# at 184
#140709 8:28:42 server id 1 end_log_pos 226 Table_map: `d1`.`t1` mapped to number 70
# at 226
#140709 8:28:42 server id 1 end_log_pos 283 Write_rows: table id 70 flags: STMT_END_F
### INSERT INTO `d1`.`t1`
### SET
### @1=1 /* LONGINT meta=0 nullable=0 is_null=0 */
### @2='one' /* VARSTRING(96) meta=96 nullable=1 is_null=0 */
### INSERT INTO `d1`.`t1`
### SET
### @1=2 /* LONGINT meta=0 nullable=0 is_null=0 */
### @2='two' /* VARSTRING(96) meta=96 nullable=1 is_null=0 */
# at 283
#140709 8:28:42 server id 1 end_log_pos 310 Xid = 12
# at 310
#140709 8:28:48 server id 1 end_log_pos 374 Query thread_id=4 exec_time=0 error_code=0
# at 374
#140709 8:28:48 server id 1 end_log_pos 416 Table_map: `d1`.`t1` mapped to number 70
# at 416
#140709 8:28:48 server id 1 end_log_pos 460 Delete_rows: table id 70 flags: STMT_END_F
### DELETE FROM `d1`.`t1`
### WHERE
### @1=1 /* LONGINT meta=0 nullable=0 is_null=0 */
### @2='one' /* VARSTRING(96) meta=96 nullable=1 is_null=0 */
# at 460
#140709 8:28:48 server id 1 end_log_pos 487 Xid = 13
# End of log file
というわけで、どれか1台以上のmysqldにmysqlbinlog -R --raw --stop-neverでつないでおけば、フツーのMySQLと同じようにPITRできそう。ビバ。
PlanetMySQL Voting: Vote UP / Vote DOWN