6. 1. New Crash-Safe Slaves
mysql> select * from mysql.slave_relay_log_infoG
*************************** 1. row ***************************
Number_of_lines: 7
Relay_log_name: ./db-ha-db2-relay-bin.000011
Relay_log_pos: 1770
Master_log_name: mysql-bin.000005
Master_log_pos: 2396
Sql_delay: 60
Number_of_workers: 0
Id: 1
1 row in set (0.00 sec)
장애 시 Duplication 제거
Query 이용 !!! (DIS)
느리다!!!
7. 2. New Multi-threaded Slaves
1.
2.
3.
4.
5.
6.
New
New
New
New
New
New
Crash-Safe Slaves
Multi-threaded Slaves
Time-delayed Replication
Optimized Row-based Replication
Replication Checksums
Global Transactions Identifiers (GTIDs)
9. 2. New Multi-threaded Slaves
MASTER
mysql> show processlist;
+-----+------+--------------------------+------+-------------+------+-----------------------------------------------------------------------+------------------+
| Id | User | Host
| db
| Command
| Time | State
| Info
|
+-----+------+--------------------------+------+-------------+------+-----------------------------------------------------------------------+------------------+
| 146 | root | localhost
| NULL | Sleep
| 362 |
| NULL
|
| 147 | mig | db-ha-db2.daum.net:34782 | NULL | Binlog Dump | 269 | Master has sent all binlog to slave; waiting for binlog to be updated | NULL
|
| 148 | root | localhost
| NULL | Query
|
0 | init
| show processlist |
+-----+------+--------------------------+------+-------------+------+-----------------------------------------------------------------------+------------------+
3 rows in set (0.00 sec)
SLAVE
+-----+-------------+-----------+-------+---------+------+-----------------------------------------------------------------------------+------------------+
| Id | User
| Host
| db
| Command | Time | State
| Info
|
+-----+-------------+-----------+-------+---------+------+-----------------------------------------------------------------------------+------------------+
|
1 | system user |
| NULL | Connect | 1692 | Waiting for master to send event
| NULL
|
| 12 | root
| localhost | mysql | Query
|
0 | init
| show processlist |
| 602 | system user |
| NULL | Connect |
17 | Slave has read all relay log; waiting for the slave I/O thread to update it | NULL
|
| 603 | system user |
| NULL | Connect |
98 | Waiting for an event from Coordinator
| NULL
|
| 604 | system user |
| NULL | Connect |
79 | Waiting for an event from Coordinator
| NULL
|
| 605 | system user |
| NULL | Connect |
85 | Waiting for an event from Coordinator
| NULL
|
+-----+-------------+-----------+-------+---------+------+-----------------------------------------------------------------------------+------------------+
11. 2. New Multi-threaded Slaves (thread 1)
MASTER
mysql> show processlist;
+----+------+--------------------------+-------+-------------+------+-----------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------+
| Id | User | Host
| db
| Command
| Time | State
| Info
|
+----+------+--------------------------+-------+-------------+------+-----------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------+
| 5 | root | localhost
| mysql | Query
|
0 | init
| show processlist
|
| 7 | mig | db-ha-db2.daum.net:58746 | NULL | Binlog Dump | 208 | Master has sent all binlog to slave; waiting for binlog to be updated | NULL
|
| 9 | root | localhost
| test | Query
|
1 | query end
| INSERT INTO sbtest(k, c, pad)
VALUES (0,' ','qqqqqqqqqqwwwwwwwwwweeeeeeeeeerrrrrrrrrrtttttttttt'),(0 |
+----+------+--------------------------+-------+-------------+------+-----------------------------------------------------------------------+-----------------------------------------------------------------------------------------------------+
3 rows in set (0.00 sec)
20. 4. New Optimized Row-based Replication
my.cnf
binlog_row_image=MINMAL
#
#
#
#
default FULL
full : Log all columns
minimal : Log only changed columns, and columns needed to identify rows
noblob : Log all columns, except for unneeded BLOB and TEXT columns
21. 4. New Optimized Row-based Replication
mysql> reset master;
Query OK, 0 rows affected (0.08 sec)
mysql> show master status;
+------------------+----------+--------------+------------------+-------------------+
| File
| Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000001 |
151 |
|
|
|
+------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)
mysql> show session variables like 'binlog_row_image';
+------------------+-------+
| Variable_name
| Value |
+------------------+-------+
| binlog_row_image | FULL |
+------------------+-------+
1 row in set (0.00 sec)
mysql> update sss set k=10 where id=1;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> show master status;
+------------------+----------+--------------+------------------+----------------------------------------+
| File
| Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set
|
+------------------+----------+--------------+------------------+----------------------------------------+
| mysql-bin.000001 |
511 |
|
| c35b769a-8fac-11e2-a667-00a0d1e293e2:1 |
+------------------+----------+--------------+------------------+----------------------------------------+
1 row in set (0.00 sec)
22. 4. New Optimized Row-based Replication
mysql> set session binlog_row_image='MINIMAL';
Query OK, 0 rows affected (0.00 sec)
mysql> reset master;
Query OK, 0 rows affected (0.01 sec)
mysql> show master status;
+------------------+----------+--------------+------------------+-------------------+
| File
| Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set |
+------------------+----------+--------------+------------------+-------------------+
| mysql-bin.000001 |
151 |
|
|
|
+------------------+----------+--------------+------------------+-------------------+
1 row in set (0.00 sec)
mysql> update sss set k=11 where id=1;
Query OK, 1 row affected (0.02 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> show master status;
+------------------+----------+--------------+------------------+----------------------------------------+
| File
| Position | Binlog_Do_DB | Binlog_Ignore_DB | Executed_Gtid_Set
|
+------------------+----------+--------------+------------------+----------------------------------------+
| mysql-bin.000001 |
399 |
|
| c35b769a-8fac-11e2-a667-00a0d1e293e2:1 |
+------------------+----------+--------------+------------------+----------------------------------------+
1 row in set (0.00 sec)
23. 4. New Optimized Row-based Replication
mysql> show session variables like 'binlog_row_image';
+------------------+-------+
| Variable_name
| Value |
+------------------+-------+
| binlog_row_image | FULL |
+------------------+-------+
1 row in set (0.00 sec)mysql> update sss set k=12 where
id=1;
Query OK, 1 row affected (0.01 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> show session variables like 'binlog_row_image';
+------------------+---------+
| Variable_name
| Value
|
+------------------+---------+
| binlog_row_image | MINIMAL |
+------------------+---------+
1 row in set (0.00 sec)mysql> update sss set k=11 where
id=1;
Query OK, 1 row affected (0.02 sec)
Rows matched: 1 Changed: 1 Warnings: 0
### UPDATE `ttt`.`sss`
### WHERE
###
@1=1
###
@2=11
###
@3=''
###
@4='qqqqqqqqqqwwwwwwwwwweeeeeeeeeerrrrrrrrrrtttttttttt
'
### SET
###
@1=1
###
@2=12
###
@3=''
###
@4='qqqqqqqqqqwwwwwwwwwweeeeeeeeeerrrrrrrrrrtttttttttt
'
# at 728
### UPDATE `ttt`.`sss`
### WHERE
###
@1=1
### SET
###
@2=11
# at 368
24. 4. New Optimized Row-based Replication
CREATE TABLE `t1` (
`a` int(11) NOT NULL DEFAULT '0',
`b` int(11) DEFAULT NULL,
`c` char(10) DEFAULT NULL,
PRIMARY KEY (`a`)
)
update t1 set b=10 where a=1;
### UPDATE `ttt`.`t1`
### WHERE
###
@1=1
### SET
###
@2=10
CREATE TABLE `t2` (
`a` int(11) NOT NULL DEFAULT '0',
`b` int(11) DEFAULT NULL,
`c` char(10) DEFAULT NULL,
PRIMARY KEY (`a`),
KEY `b` (`b`)
)
update t2 set b=10 where b=1;
### UPDATE `ttt`.`t2`
### WHERE
###
@1=101
### SET
###
@2=10
CREATE TABLE `t3` (
`a` int(11) DEFAULT NULL,
`b` int(11) DEFAULT NULL,
`c` char(10) DEFAULT NULL
)
update t3 set b=10 where a=1;
### UPDATE `ttt`.`t3`
### WHERE
###
@1=1
###
@2=100
###
@3='aaaaa'
### SET
###
@2=10
25. 4. New Optimized Row-based Replication
스마트해진 ROW format
PK가 필요함 !!!