SlideShare ist ein Scribd-Unternehmen logo
1 von 124
Introduction To MySQL Replication
                Kenny Gryp <kenny.gryp@percona.com>
               Percona Live Washington DC / 2012-01-11
MySQL Replication
Replication Overview
Binary Logs
Setting Up Replication
Commands
Other Common Configuration Settings
Replication Architectures
Common Issues
Replication Use Cases
Other Replication Implementations
Tools


                                      www.percona.com   2
MySQL Replication
Replication Overview
Binary Logs
Setting Up Replication
Commands
Other Common Configuration Settings
Replication Architectures
Common Issues
Replication Use Cases
Other Replication Implementations
Tools


                                      www.percona.com   3
What is Replication?
Replication enables data from one MySQL database server
   (the master) to be replicated to one or more MySQL
              database servers (the slaves)
       (Source: http://dev.mysql.com/doc/refman/5.5/en/replication.html)




                                                               www.percona.com   4
Replication Diagram

                                 APPLICATION

Queries

          MASTER                                               SLAVE

             ...                                  SQL Thread       ...
           MyISAM                                                MyISAM
           INNODB                                               INNODB
                                      IO Thread
                       BINLOGS                    RELAY LOGS




                                                                www.percona.com   5
Replication Diagram

                                 APPLICATION

Queries                                                                           Queries

          MASTER                                   BINLOGS
                                                               SLAVE

             ...                                  SQL Thread       ...
           MyISAM                                                MyISAM
           INNODB                                               INNODB
                                      IO Thread
                       BINLOGS                    RELAY LOGS




                                                                www.percona.com     6
Replication
Happens at MySQL level, not Storage Engine Level (*NDB)
Asynchronous! (Semi-sync available in 5.5)
A server can have only 1 master
IO Thread: Fetches from master
SQL Thread: Executes on slave
Single Threaded Execution (Expect enhancements in 5.6)
Different schema’s are possible between master and slave
(Watch out!!):
  different indexes
  storage engines
  data types
  columns
                                           www.percona.com   7
MySQL Replication
Replication Overview
Binary Logs
Setting Up Replication
Commands
Other Common Configuration Settings
Replication Architectures
Common Issues
Replication Use Cases
Other Replication Implementations
Tools


                                      www.percona.com   8
Binary Logs

       BINLOG.000001        BINLOG.index
     BINLOG.000002
                            BINLOG.000001
  BINLOG.000003             BINLOG.000002
BINLOG….                    BINLOG.000003




                                  www.percona.com   9
Binary Logs
Set of files
Contains all writes and schema changes
!= REDO/Transaction log
Rotated when full (Set max_binlog_size)
Incrementing numbers (000001,000002,000003,...)
Relay Logs are also binary logs
2 Formats:
   Statement Based (SBR)
   Row Based (RBR, since MySQL 5.1)
Binary file


                                        www.percona.com   10
Binary Logs - Info Files
master.info
  Contains IO Thread information & connection information
relay.info
  Contains SQL Thread information




                                                www.percona.com   11
Binary Log - Formats (binlog_format)
Statement Based Replication (SBR):
  Writes statements to binary logs, slave executes the stmts
  (An update stmt that changes 1 row but reads many will also do
  the same on the slave)
  Some functions are non-deterministic and cause
  inconsistencies:
     UUID(), SYSDATE(), FOUND_ROWS(), UPDATE .. LIMIT without
     ORDER BY...
     Works for NOW(): timestamp included in binary log
  More complete list of issues:
  http://dev.mysql.com/doc/refman/5.5/en/replication-features.html



                                                  www.percona.com   12
Binary Log - Formats (binlog_format)
Row Based Replication (RBR, since 5.1):
  Write row changes (larger binlogs)
  Check Binlog_cache_disk_use, possibly increase
  binlog_cache_size
  Does not need to parse/execute queries, just make the changes
  necessary
  Much less/different issues compared to SBR:
  http://dev.mysql.com/doc/refman/5.5/en/replication-rbr-
  usage.html
Mixed: Combination of both: defaults to SBR, use RBR
when necessary


                                                www.percona.com   13
Looking at Binary Log Contents
mysqlbinlog
SHOW BINLOG EVENTS




                          www.percona.com   14
Example SBR
> SHOW GLOBAL VARIABLES LIKE 'binlog_format';
+---------------+-----------+
| Variable_name | Value     |
+---------------+-----------+
| binlog_format | STATEMENT |
+---------------+-----------+
1 row in set (0.00 sec)

> CREATE DATABASE replication;
Query OK, 1 row affected (0.14 sec)

> use replication
Database changed

> CREATE TABLE repl (a int) ENGINE=innodb;
Query OK, 0 rows affected (0.25 sec)

> INSERT INTO repl VALUES (1);
Query OK, 1 row affected (0.14 sec)




                                                www.percona.com   15
Example SBR - mysqlbinlog
# mysqlbinlog mysql-bin.000193
...
# at 106
#120106 15:19:13 server id 9999 end_log_pos   203 !   Query!     thread_id=11
CREATE DATABASE replication
/*!*/;
# at 203
#120106 15:19:32 server id 9999 end_log_pos   312 !   Query!     thread_id=11
!        exec_time=1!     error_code=0
use replication/*!*/;
SET TIMESTAMP=1325859572/*!*/;
CREATE TABLE repl (a INT) ENGINE=innodb
/*!*/;
# at 312
#120106 15:19:55 server id 9999 end_log_pos   387 !   Query!     thread_id=11
!        exec_time=0!     error_code=0
SET TIMESTAMP=1325859595/*!*/;
BEGIN
/*!*/;
# at 387
#120106 15:19:55 server id 9999 end_log_pos   484 !   Query!     thread_id=11
!        exec_time=0!     error_code=0
SET TIMESTAMP=1325859595/*!*/;
INSERT INTO repl VALUES (1)
/*!*/;
# at 484
#120106 15:19:55 server id 9999 end_log_pos   511 !   Xid = 14             www.percona.com   16
COMMIT/*!*/;
> SHOW BINLOG EVENTS FROM 106G
*************************** 1. row ***************************
   Log_name: mysql-bin.000193

 Example SBR - SHOW BINLOG EVENTS
        Pos: 106
 Event_type: Query
  Server_id: 1
End_log_pos: 203
       Info: CREATE DATABASE replication
*************************** 2. row ***************************
   Log_name: mysql-bin.000193
        Pos: 203
 Event_type: Query
  Server_id: 1
End_log_pos: 312
       Info: use `replication`; CREATE TABLE repl (a INT) ENGINE=innodb
*************************** 3. row ***************************
   Log_name: mysql-bin.000193
        Pos: 312
 Event_type: Query
  Server_id: 1
End_log_pos: 387
       Info: BEGIN
*************************** 4. row ***************************
   Log_name: mysql-bin.000193
        Pos: 387
 Event_type: Query
  Server_id: 1
End_log_pos: 484
       Info: use `replication`; INSERT INTO repl VALUES (1)
*************************** 5. row ***************************
   Log_name: mysql-bin.000193
        Pos: 484
 Event_type: Xid
  Server_id: 1
End_log_pos: 511
       Info: COMMIT /* xid=14 */
5 rows in set (0.00 sec)                                                  www.percona.com   17
Example RBR
> SHOW GLOBAL VARIABLES LIKE 'binlog_format';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| binlog_format | ROW   |
+---------------+-------+
1 row in set (0.00 sec)

> CREATE DATABASE replication;
Query OK, 1 row affected (0.14 sec)

> use replication
Database changed

> CREATE TABLE repl (a int) ENGINE=innodb;
Query OK, 0 rows affected (0.25 sec)

> INSERT INTO repl VALUES (1);
Query OK, 1 row affected (0.14 sec)




                                                www.percona.com   18
Example RBR - mysqlbinlog
# mysqlbinlog mysql-bin.000193 --start-position=606
...
# at 606
#120106 15:54:54 server id 1 end_log_pos 703 !        Query!   thread_id=11
!        exec_time=0!     error_code=0
CREATE DATABASE replication
/*!*/;
# at 703
#120106 15:55:02 server id 1 end_log_pos 812 !        Query!   thread_id=11
!        exec_time=0!     error_code=0
use replication/*!*/;
SET TIMESTAMP=1325861702/*!*/;
CREATE TABLE repl (a int) ENGINE=innodb
/*!*/;
# at 812
...
# at 937
#120106 15:55:06 server id 1 end_log_pos 937 !        Table_map: `replication`.`repl` mapped to
number 17
#120106 15:55:06 server id 1 end_log_pos 971 !        Write_rows: table id 17 flags: STMT_END_F

BINLOG '
SgsHTxMBAAAAMgAAAKkDAAAAABEAAAAAAAEAC3JlcGxpY2F0aW9uAARyZXBsAAEDAAE=
SgsHTxcBAAAAIgAAAMsDAAAAABEAAAAAAAEAAf/+AQAAAA==
'/*!*/;
# at 971
#120106 15:55:06 server id 1 end_log_pos 998 !      Xid = 34             www.percona.com   19
COMMIT/*!*/;
Example RBR -
               mysqlbinlog --verbose
# mysqlbinlog mysql-bin.000193 --verbose --verbose
...
# at 937
#120106 15:55:06 server id 1 end_log_pos 937 !     Table_map: `replication`.`repl` mapped to
number 17
#120106 15:55:06 server id 1 end_log_pos 971 !     Write_rows: table id 17 flags: STMT_END_F

BINLOG '
SgsHTxMBAAAAMgAAAKkDAAAAABEAAAAAAAEAC3JlcGxpY2F0aW9uAARyZXBsAAEDAAE=
SgsHTxcBAAAAIgAAAMsDAAAAABEAAAAAAAEAAf/+AQAAAA==
'/*!*/;
### INSERT INTO replication.repl
### SET
###   @1=1 /* INT meta=0 nullable=1 is_null=0 */
# at 971




                                                                       www.percona.com   20
> SHOW BINLOG EVENTS FROM 606G
*************************** 1. row ***************************
    Log_name: mysql-bin.000193

 Example RBR - SHOW BINLOG EVENTS
         Pos: 606
 Event_type: Query
  Server_id: 1
End_log_pos: 703
        Info: CREATE DATABASE replication
*************************** 2. row ***************************
    Log_name: mysql-bin.000193
         Pos: 703
 Event_type: Query
  Server_id: 1
End_log_pos: 812
        Info: use `replication`; CREATE TABLE repl (a int) ENGINE=innodb
...
*************************** 4. row ***************************
    Log_name: mysql-bin.000193
         Pos: 887
 Event_type: Table_map
  Server_id: 1
End_log_pos: 937
        Info: table_id: 17 (replication.repl)
*************************** 5. row ***************************
    Log_name: mysql-bin.000193
         Pos: 937
 Event_type: Write_rows
  Server_id: 1
End_log_pos: 971
        Info: table_id: 17 flags: STMT_END_F
*************************** 6. row ***************************
    Log_name: mysql-bin.000193
         Pos: 971
 Event_type: Xid
  Server_id: 1
End_log_pos: 998
        Info: COMMIT /* xid=34 */                                          www.percona.com   21
6 rows in set (0.00 sec)
MySQL Replication
Replication Overview
Binary Logs
Setting Up Replication
Commands
Other Common Configuration Settings
Replication Architectures
Common Issues
Replication Use Cases
Other Replication Implementations
Tools


                                      www.percona.com   22
Setting up Replication
Prerequisites
Change master/slave MySQL configuration
Configure Replication
Start Replication/Check Status




                                          www.percona.com   23
Prerequisites
No way to easily create slave with 1 command
It’s required to Create/Restore consistent backup using
your favorite backup tool
  with mysqldump, use --master-data
Binlog file and position from backup should be recorded
  File: mysql-bin.000008
  Pos: 106




                                             www.percona.com   24
Change master/slave Configuration
On the master:
  Enable Binary Logging: log-bin=log-bin
  Set A Server ID: server-id=1
On the slave:
  Set A Server ID: server-id=2




                                           www.percona.com   25
Why server-id ?

                                    APPLICATION

     Queries                                                                         Queries


               MASTER                                     BINLOGS
                                                                        SLAVE

                             events get
                  ...        server-id=1                 SQL Thread        ...
                MyISAM                                                   MyISAM
                INNODB                                 server-id != 2    INNODB
                                           IO Thread
                          BINLOGS                       RELAY LOGS

server-id=1                                                                                server-id=2




                                                                         www.percona.com      26
Why server-id ?

                                         APPLICATION

     Queries                                                                               Queries


               MASTER          server-id != 1
                              RELAY LOGS                        BINLOGS
                                                                              SLAVE          events get
                                                                                             server-id=2
                SQL Thread                IO Thread
                         log_slave_updates            log_slave_updates
                                   events get
                   ...             server-id=1                 SQL Thread        ...
                 MyISAM                                                        MyISAM
                 INNODB                                      server-id != 2    INNODB
                                                 IO Thread
                               BINLOGS                        RELAY LOGS

server-id=1                                                                                      server-id=2




                                                                               www.percona.com      27
Why server-id ?
Avoid events to be written more than once
replicate_same_server_id does what it says




                                     www.percona.com   28
Configure Replication
On Master, add permissions:
> GRANT REPLICATION SLAVE ON *.* TO
‘repl’@‘slave’ IDENTIFIED BY ‘pass’;
On Slave, configure replication:
> CHANGE MASTER TO MASTER_HOST=‘master’,
MASTER_USER=‘repl’, MASTER_PASSWORD=‘pass’,
MASTER_LOG_FILE=‘mysql-bin.000008’,
MASTER_LOG_POS=106;




                                 www.percona.com   29
slave> START SLAVE;
slave> SHOW SLAVE STATUSG
               Slave_IO_State:    Waiting for master to send event
                                                                     IO Thread State
                                  Start Replication
                  Master_Host:    master
                  Master_User:    repl
                  Master_Port:    3306
                Connect_Retry:
              Master_Log_File:
                                  60
                                  mysql-bin.000008                   IO Thread Read Up To
          Read_Master_Log_Pos:    254
               Relay_Log_File:
                Relay_Log_Pos:
                                  relay-bin.000002
                                  399                                SQL Thread Read Up To
        Relay_Master_Log_File:    mysql-bin.000008
             Slave_IO_Running:
            Slave_SQL_Running:
                                  Yes
                                  Yes                                Threads Running?
              Replicate_Do_DB:
          Replicate_Ignore_DB:
           Replicate_Do_Table:
       Replicate_Ignore_Table:
      Replicate_Wild_Do_Table:
  Replicate_Wild_Ignore_Table:
                    Last_Errno:   0
                    Last_Error:
                 Skip_Counter:    0
          Exec_Master_Log_Pos:    254
              Relay_Log_Space:    566
              Until_Condition:    None
               Until_Log_File:
                Until_Log_Pos:    0
           Master_SSL_Allowed:    No
           Master_SSL_CA_File:
           Master_SSL_CA_Path:
              Master_SSL_Cert:
            Master_SSL_Cipher:
               Master_SSL_Key:
        Seconds_Behind_Master:
Master_SSL_Verify_Server_Cert:
                                  0
                                  No
                                                                     How Far Is Slave Behind?
                Last_IO_Errno:    0
                Last_IO_Error:
               Last_SQL_Errno:    0                                           www.percona.com   30
               Last_SQL_Error:
MySQL Replication
Replication Overview
Binary Logs
Setting Up Replication
Commands
Other Common Configuration Settings
Replication Architectures
Common Issues
Replication Use Cases
Other Replication Implementations
Tools


                                      www.percona.com   31
Commands
SQL Commands
  Adminstrative Commands
  Diagnostics Commands
Shell Commands
  mysqlbinlog




                             www.percona.com   32
Administrative Commands
Rotate binary log: FLUSH BINARY LOGS
Rotate relay log: FLUSH RELAY LOGS
START/STOP SLAVE IO_THREAD/SQL_THREAD
Remove binary logs:
PURGE MASTER LOGS TO ‘mysql-bin.000005’;
PURGE MASTER LOGS
        BEFORE ‘2012-01-01 00:00:00’;
Remove all binary logs: RESET MASTER
Remove slave configuration and files: RESET SLAVE



                                         www.percona.com   33
Diagnostics Commands
On Master
  SHOW   MASTER STATUS
  SHOW   PROCESSLIST
  SHOW   SLAVE HOSTS
  SHOW   BINLOG EVENTS
On Slave
  SHOW SLAVE STATUS
  SHOW PROCESSLIST




                             www.percona.com   34
On Master:SHOW MASTER STATUS

Current binary log file and position:
master> SHOW MASTER STATUSG
*************************** 1. row ***************************
            File: mysql-bin.000008
        Position: 254
    Binlog_Do_DB:
Binlog_Ignore_DB: 1 row in set (0.00 sec)




                                                 www.percona.com   35
On Master: SHOW PROCESSLIST
Find Connected Slaves using SHOW PROCESSLIST:
master> SHOW PROCESSLISTG
...
*************************** 2. row ***************************
      Id: 4
    User: repl
    Host: localhost:43537
      db: NULL
Command: Binlog Dump
    Time: 1264
  State: Has sent all binlog to slave; waiting for binlog to be
updated
    Info: NULL
...




                                                 www.percona.com   36
On Master: SHOW SLAVE HOSTS
Shows connected slaves with their server-id:
master> SHOW SLAVE HOSTS;
+-----------+-----------+------+-----------+
| Server_id | Host      | Port | Master_id |
+-----------+-----------+------+-----------+
|         2 | slave     | 3306 |         1 |
+-----------+-----------+------+-----------+
1 row in set (0.00 sec)
Only works when slaves have configured:
report-host, report-user, report-password,
report-port



                                               www.percona.com   37
On Slave: SHOW PROCESSLIST
Slave Thread Status:
SLAVE> SHOW PROCESSLISTG
***************************   1. row ***************************
     Id: 5
   User: system user
   Host:
     db: NULL
Command: Connect
   Time: 88611
  State: Waiting for master   to send event
   Info: NULL
***************************   2. row ***************************
     Id: 8
   User: system user
   Host:
     db: NULL
Command: Connect
   Time: 83
  State: Has read all relay   log; waiting for the slave I/O thread to update it
   Info: NULL




                                                                     www.percona.com   38
MySQL Replication
Replication Overview
Binary Logs
Setting Up Replication
Commands
Other Common Configuration Settings
Replication Architectures
Common Issues
Replication Use Cases
Other Replication Implementations
Tools


                                      www.percona.com   39
Other Common Configuration Options
Filtering: binlog-%, replicate-%
Don’t start replication at start: skip_slave_start
Put relay log events in it’s own binary log:
log_slave_updates
Disallow writing on slaves: read_only
Automatically remove binlogs: expire_logs_days
Change binlog format: binlog_format




                                           www.percona.com   40
Filtering on Master
binlog-do-db=..., binlog-ignore-db=...
Warning! Different behavior between SBR and RBR:
  SBR: Log all statements executed if the ‘default database’ (use
  database) should be binlogged
  RBR: Log all row changes of the databases that should be
  binlogged




                                                  www.percona.com   41
Filtering on Slave
replicate-do-db= & replicate-ignore-db=
Warning! Different behavior between SBR and RBR
Similar to binlog-do/ignore-db
replicate-do/ignore-table: Filter on table level
replicate-wild-do/ignore-table: Use wildcards
(%,_) to filter on table level
replicate-rewrite-db=db1->db2




                                       www.percona.com   42
MySQL Replication
Replication Overview
Binary Logs
Setting Up Replication
Commands
Other Common Configuration Settings
Replication Architectures
Common Issues
Replication Use Cases
Other Replication Implementations
Tools


                                      www.percona.com   43
Replication Architectures
Master-Slave
Master-Master
Multi Tiered Replication
Circular Replication




                               www.percona.com   44
Master-Slave



   Master

   Slave




               www.percona.com   45
Master-Slave

Application

                 Master

                 Slave




                             www.percona.com   45
Master-Slave

Application

                 Master

                 Slave




                             www.percona.com   45
Master-Slave

Application
              Writes/Reads
                   Master

                    Slave




                              www.percona.com   45
Master-Slave

Application
              Writes/Reads
                   Master

                    Slave




                              www.percona.com   45
Master-Slave

Application
              Writes/Reads
                   Master
      Reads
                    Slave




                              www.percona.com   45
Master-Slave



           Master

Slave      Slave       Slave




                       www.percona.com   46
Master-Slave

Application

                 Master

    Slave        Slave       Slave




                             www.percona.com   46
Master-Slave

Application

                 Master

    Slave        Slave       Slave




                             www.percona.com   46
Master-Slave

Application   Writes/Reads

                 Master

    Slave        Slave       Slave




                             www.percona.com   46
Master-Slave

Application   Writes/Reads

                 Master

    Slave        Slave       Slave




                             www.percona.com   46
Master-Slave

Application   Writes/Reads

                 Master
Reads

    Slave        Slave       Slave




                             www.percona.com   46
Master-Slave

Application   Writes/Reads

                 Master
Reads

    Slave        Slave       Slave




                             www.percona.com   46
Master-Slave

Application   Writes/Reads

                 Master
Reads

    Slave        Slave       Slave




                             www.percona.com   46
Master-Slave
Scaling Reads:
  Slaves can take reads (remember asynchronous!)
  Reporting/Search queries can go to separate slave
     Does not take resources on master ‘live-site’-slave.
     (‘live site’: lower response time requirements than reports)
     Can have other indexes, even other tables (summary tables,...)
  Not much benefit when too much writes
Maintenance (schema changes...)
  Upgrade slaves first:
     Take slave offline
     SET SQL_LOG_BIN=0; <-don’t put this session queries in
     ALTER TABLE ...;     the binary log
     SET SQL_LOG_BIN=1;
                                                       www.percona.com   47
Master-Slave: Reporting Queries



            Master

 Slave       Slave      Slave




                         www.percona.com   48
Master-Slave: Reporting Queries

Application

              Master

    Slave      Slave      Slave




                           www.percona.com   48
Master-Slave: Reporting Queries

Application

              Master

    Slave      Slave      Slave




                           www.percona.com   48
Master-Slave: Reporting Queries

Application   Writes/Reads

                 Master

    Slave        Slave       Slave




                             www.percona.com   48
Master-Slave: Reporting Queries

Application     Writes/Reads

                   Master
        Reads

    Slave          Slave       Slave




                               www.percona.com   48
Master-Slave: Reporting Queries

Application     Writes/Reads

                   Master
        Reads

    Slave          Slave       Slave




                               www.percona.com   48
Master-Slave: Reporting Queries

Application     Writes/Reads

                   Master
        Reads

    Slave          Slave       Slave




                               www.percona.com   48
Master-Slave: Reporting Queries

  Application       Writes/Reads
Reporting
                       Master
            Reads

      Slave            Slave       Slave




                                   www.percona.com   48
Master-Slave: Reporting Queries

  Application       Writes/Reads
Reporting
                       Master
            Reads

      Slave            Slave       Slave




                                   www.percona.com   48
Master-Slave: Write Intensive




Master                  Slaves      Master                 Slaves

         Capacity left for READS             Capacity left for READS

         Capacity taken by WRITES            Capacity taken by WRITES



                                                     www.percona.com    49
Master-Master




Master    Master




                   www.percona.com   50
Master-Master
Used for:
  High Availability
  Maintenance Tasks
Write to 1 master, failover to the passive master when
necessary
Passive master is a real slave, can be used for reads
Scale Writes? NO!
  Every write still has to be performed on both masters
Writing to both masters at the same time? NO*!
  Can cause inconsistencies
  even with auto_increment_increment/
  auto_increment_offset problems can happen
                                                  www.percona.com   51
Master-Master: Reads & Writes

Application
                 Writes/Reads

     Reads
              Master      Master




                                   www.percona.com   52
Master-Master: Maintenance

Application
Writes/Reads

              Master   Master




                                www.percona.com   53
Master-Master: Maintenance

Application
Writes/Reads

              Master       Master
                       SET SQL_LOG_BIN=0;
                       ALTER TABLE ...;
                       ...
                       SET SQL_LOG_BIN=1;




                                            www.percona.com   53
Master-Master: Maintenance

Application
Writes/Reads

              Master   Master




                                www.percona.com   53
Master-Master: Maintenance

Application
Writes/Reads

              Master          Master
         SET SQL_LOG_BIN=0;
         ALTER TABLE ...;
         ...
         SET SQL_LOG_BIN=1;




                                       www.percona.com   53
Master-Master: Write to Both?
                Inconsistencies
   Application


                          Master                        Master
                     +--------+----------------+   +--------+----------------+
                     | userid | email          |   | userid | email          |
                     +--------+----------------+   +--------+----------------+
                     |      1 | kg@percona.com |   |      1 | kg@percona.com |
                     +--------+----------------+   +--------+----------------+
CREATE TABLE users (
userid INT AUTO_INCREMENT,
email VARCHAR(128) NOT NULL,
PRIMARY KEY (userid),
UNIQUE KEY idx_email (email)
);



                                                                                 www.percona.com   54
Master-Master: Write to Both?
                Inconsistencies
   Application                                     UPDATE users SET
                                                   email=‘kenny@percona.com’
        UPDATE users SET                           where userid=1;
email=‘gryp@percona.com’
         where userid=1;


                           Master                          Master
                     +--------+----------------+      +--------+----------------+
                     | userid | email          |      | userid | email          |
                     +--------+----------------+      +--------+----------------+
                     |      1 | kg@percona.com |      |      1 | kg@percona.com |
                     +--------+----------------+      +--------+----------------+
CREATE TABLE users (
userid INT AUTO_INCREMENT,
email VARCHAR(128) NOT NULL,
PRIMARY KEY (userid),
UNIQUE KEY idx_email (email)
);



                                                                                    www.percona.com   54
Master-Master: Write to Both?
                Inconsistencies
   Application                                       UPDATE users SET
                                                     email=‘kenny@percona.com’
        UPDATE users SET                             where userid=1;
email=‘gryp@percona.com’
         where userid=1;


                           Master                            Master
                     +--------+------------------+      +--------+-------------------+
                     | userid | email            |      | userid | email             |
                     +--------+------------------+      +--------+-------------------+
                     |      1 | gryp@percona.com |      |      1 | kenny@percona.com |
                     +--------+------------------+      +--------+-------------------+
CREATE TABLE users (
userid INT AUTO_INCREMENT,
email VARCHAR(128) NOT NULL,
PRIMARY KEY (userid),
UNIQUE KEY idx_email (email)
);



                                                                                   www.percona.com   54
Master-Master: Write to Both?
                Inconsistencies
   Application
                                       UPDATE users SET email=‘kenny@percona.com’ where userid=1;




                          Master                                Master
                                             UPDATE users SET email=‘gryp@percona.com’ where userid=1;

                     +--------+------------------+        +--------+-------------------+
                     | userid | email            |        | userid | email             |
                     +--------+------------------+        +--------+-------------------+
                     |      1 | gryp@percona.com |        |      1 | kenny@percona.com |
                     +--------+------------------+        +--------+-------------------+
CREATE TABLE users (
userid INT AUTO_INCREMENT,
email VARCHAR(128) NOT NULL,
PRIMARY KEY (userid),
UNIQUE KEY idx_email (email)
);



                                                                                          www.percona.com   54
Master-Master: Write to Both?
                Inconsistencies
   Application
                                       UPDATE users SET email=‘kenny@percona.com’ where userid=1;




                          Master                                Master
                                             UPDATE users SET email=‘gryp@percona.com’ where userid=1;

                     +--------+-------------------+       +--------+------------------+
                     | userid | email             |       | userid | email            |
                     +--------+-------------------+       +--------+------------------+
                     |      1 | kenny@percona.com |       |      1 | gryp@percona.com |
                     +--------+-------------------+       +--------+------------------+
CREATE TABLE users (
userid INT AUTO_INCREMENT,
email VARCHAR(128) NOT NULL,
PRIMARY KEY (userid),
UNIQUE KEY idx_email (email)
);



                                                                                          www.percona.com   54
Master-Master: Write to Both?
               Replication Breaks
   Application


                          Master                        Master
                     +--------+----------------+   +--------+----------------+
                     | userid | email          |   | userid | email          |
                     +--------+----------------+   +--------+----------------+
                     |      1 | kg@percona.com |   |      1 | kg@percona.com |
                     +--------+----------------+   +--------+----------------+
CREATE TABLE users (
userid INT AUTO_INCREMENT,
email VARCHAR(128) NOT NULL,
PRIMARY KEY (userid),
UNIQUE KEY idx_email (email)
);



                                                                                 www.percona.com   55
Master-Master: Write to Both?
               Replication Breaks
   Application                                     UPDATE USERS SET
                                                   email=‘legryp@percona.com’
       INSERT INTO USERS                           WHERE userid=1;
          (email) VALUES
  (‘legryp@percona.com’)


                           Master                          Master
                     +--------+----------------+      +--------+----------------+
                     | userid | email          |      | userid | email          |
                     +--------+----------------+      +--------+----------------+
                     |      1 | kg@percona.com |      |      1 | kg@percona.com |
                     +--------+----------------+      +--------+----------------+
CREATE TABLE users (
userid INT AUTO_INCREMENT,
email VARCHAR(128) NOT NULL,
PRIMARY KEY (userid),
UNIQUE KEY idx_email (email)
);



                                                                                    www.percona.com   55
Master-Master: Write to Both?
               Replication Breaks
   Application                                     UPDATE USERS SET
                                                   email=‘legryp@percona.com’
       INSERT INTO USERS                           WHERE userid=1;
          (email) VALUES
  (‘legryp@percona.com’)


                           Master                           Master
                     +--------+--------------------+   +--------+--------------------+
                     | userid | email              |   | userid | email              |
                     +--------+--------------------+   +--------+--------------------+
                     |      1 | kg@percona.com     |   |      1 | legryp@percona.com |
                     |      2 | legryp@percona.com |   +--------+--------------------+
                     +--------+--------------------+
CREATE TABLE users (
userid INT AUTO_INCREMENT,
email VARCHAR(128) NOT NULL,
PRIMARY KEY (userid),
UNIQUE KEY idx_email (email)
);



                                                                                  www.percona.com   55
Master-Master: Write to Both?
               Replication Breaks
   Application
                                       UPDATE USERS SET email=‘legryp@percona.com’ WHERE userid=1;




                         Master                                 Master
                                               INSERT INTO USERS (email) VALUES (‘legryp@percona.com’)

                     +--------+--------------------+      +--------+--------------------+
                     | userid | email              |      | userid | email              |
                     +--------+--------------------+      +--------+--------------------+
                     |      1 | kg@percona.com     |      |      1 | legryp@percona.com |
                     |      2 | legryp@percona.com |      +--------+--------------------+
                     +--------+--------------------+
CREATE TABLE users (
userid INT AUTO_INCREMENT,
                                  Error 'Duplicate entry 'legryp@percona.com'
email VARCHAR(128) NOT NULL,
PRIMARY KEY (userid),             for key 'idx_email'' on query. Default
UNIQUE KEY idx_email (email)      database: 'test'. Query: 'insert into
);                                users(email) values ('legryp@percona.com')'

                                                                                          www.percona.com   55
Multi Tiered Replication


                Master

Slave           Slave            Slave

        Slave            Slave



                                 www.percona.com   56
Multi Tiered Replication
2 Second query takes 6 seconds to reach the 3rd level
Top level slaves could be a master for some dbs/tables too
  Replication main data (users...) to top level slaves
  Top level slaves are sort of functionally partitioned




                                                     www.percona.com   57
Multi Tiered Replication:
            Delay

                Master

Slave           Slave            Slave

        Slave            Slave



                                 www.percona.com   58
Multi Tiered Replication:
            Delay

                Master      2 Seconds


Slave           Slave            Slave

        Slave            Slave



                                 www.percona.com   58
Multi Tiered Replication:
            Delay

                Master      2 Seconds
                            2 Seconds
Slave           Slave            Slave

        Slave            Slave



                                 www.percona.com   58
Multi Tiered Replication:
            Delay

                Master      2 Seconds
                            2 Seconds
Slave           Slave            Slave
                            2 Seconds
        Slave            Slave



                                 www.percona.com   58
Multi Tiered Replication:
     Top Level Slaves

                     MASTER
                Master

   MASTER            SEARCH                   LOG
Slave           Slave            Slave

            SEARCH            SEARCH
        Slave            Slave



                                   www.percona.com   59
Multi Tiered Replication


                Master

Slave           Slave            Slave

        Slave            Slave

        No Updates Anymore

                                 www.percona.com   60
Circular Replication


          Master

Master              Master

          Master




                          www.percona.com   61
Circular Replication


          Master

Master              Master

          Master




                          www.percona.com   62
Circular Replication


          Master

Master              Master

          Master




                          www.percona.com   63
MySQL Replication
Replication Overview
Binary Logs
Setting Up Replication
Commands
Other Common Configuration Settings
Replication Architectures
Common Issues
Replication Use Cases
Other Replication Implementations
Tools


                                      www.percona.com   64
Common Issues
Replication Lag
Replication Breaking
Crash Safe Replication
Consistency




                               www.percona.com   65
Replication Lag - Causes
Single threaded execution on slave!!!
Long running queries with SBR: will take ~same time on
slave
Many row changes with RBR
MyISAM & table level locking: Long running SELECT on
slave might block replication
Schema changes:
  20min on master,
  20min on slave <-- 20 min replication lag




                                              www.percona.com   66
Replication Lag - Tips 1
Optimize DML Statements
Avoid DDL Statements in Replication (SQL_LOG_BIN=0)
Hardware specifications usually need to be equal or better
on slave
MySQL 5.6:
http://d2-systems.blogspot.com/2011/04/mysql-56x-feature-preview-multi.html
Ensure BBU&Write Back Cache is used or lower durability:
innodb_flush_log_at_trx_commit=2
Change architecture: functional/horizontal partitioning




                                                                  www.percona.com   67
Replication Lag - Tips 2
Try to avoid SQL Thread to need to do disk I/O:
  Replication Booster (Yoshinori Matsunobu)
     prefetches relay logs and converts queries to select and runs them,
     causing data to be cached before SQL thread reaches
  innodb_fake_changes
     http://www.percona.com/doc/percona-server/5.5/management/
     innodb_fake_changes.html
     http://dom.as/2011/12/03/replication-prefetching/




                                                        www.percona.com   68
Replication Booster




http://yoshinorimatsunobu.blogspot.com/2011/10/making-slave-pre-fetching-work-better.html
                                                                   www.percona.com   69
Replication Breaking - Examples
Last_Errno: 1146
Last_Error: Error 'Table 'db.table' doesn't exist' on query.
Default database: 'userdb'. Query: '...'
Last_Errno: 1062
Last_Error: Error 'Duplicate entry '1748099' for key 1' on query.
Default database: 'db'. Query: 'INSERT INTO table (url)
VALUES(‘http://www.google.com')'
Last_Errno: 1053
Last_Error: Query partially completed on the master (error on
master: 1053) and was aborted. There is a chance that your master
is inconsistent at this point. If you are sure that your master is
ok, run this query manually on the slave and then restart the
slave with SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; START SLAVE; .
Query: ALTER TABLE ‘users’ ADD ‘name’ VARCHAR(128) NULL DEFAULT;




                                                  www.percona.com   70
Replication Breaking - Causes
Writes happening on Slaves
SBR with bad statements
Crashes: Relay Log Corruption
Different schemas
Temporary tables
Mixing MyISAM with InnoDB
Different behavior between MySQL versions (minor/major)
Killing queries that change MyISAM tables will be partially
executed, and break replication
...


                                              www.percona.com   71
Replication Breaking - Fixing
Questions to ask yourself: Why? Where? Impact?
Quick ‘fix’:
SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; START SLAVE;
    Causes 1 event to be skipped
    Causes inconsistencies!!!
Look at:
    Check error & Investigate data on master/slave
    MySQL errorlogs
    SHOW SLAVE STATUSG
    mysqlbinlog on relaylogs/binarylogs and investigate
    pt-slave-restart
More On: http://www.percona.com/files/presentations/percona-live/london-2011/
PLUK2011-diagnosing-and-fixing-mysql-replication.pdf
                                                              www.percona.com   72
Crash Safe Replication
On master: sync_binlog=1 to fsync at every binlog write
  Performance impact, mainly on:
      Ext3 filesystem
      http://www.mysqlperformanceblog.com/2009/01/21/beware-ext3-and-sync-binlog-do-not-play-well-together/

      High write-response time disksubsystem (no WriteBackCache& BBU)
On slave:
  relay-log.info/master.info: not durable/consistent!
  When OS crash, old information might be in the file
  If InnoDB only: use innodb_overwrite_relay_log_info
  in Percona Server:
  http://www.percona.com/doc/percona-server/5.5/reliability/
  innodb_recovery_update_relay_log.html



                                                                                 www.percona.com       73
Consistency
Replication can cause inconsistencies:
  Statement Based Replication
     Certain functions like UUID()...
     UPDATE/DELETE with LIMIT without ORDER BY unique key
  Writing to multiple masters
  Writing to slaves (by accident? use read_only)
  Failover done wrong
  MyISAM with killing queries and/ord MySQL Crashes
  Wrongly restored slaves
  Replication broke and used SQL_SLAVE_SKIP_COUNTER
  ...
How to know if my data is consistent?
                                                www.percona.com   74
Consistency
Checking Consistency: pt-table-checksum
  Checksums chunks of data on master and slaves
  Monitors replication lag
  Low checksum response time to lower impact on production
  Uses Replication to ensure consistent view of data
Fixing Consistency: pt-table-sync
  Can checksum and use pt-table-checksum results
  Fixes inconsistencies




                                               www.percona.com   75
MySQL Replication
Replication Overview
Binary Logs
Setting Up Replication
Commands
Other Common Configuration Settings
Replication Architectures
Common Issues
Replication Use Cases
Other Replication Implementations
Tools


                                      www.percona.com   76
Replication Use Cases
Scale Reads
High Availability
Backups




                               www.percona.com   77
High Availability
Failover:
   Virtual IPs
   Change IP in application servers
Warning: Split-Brain possible!!!
   Ensure no writes happen on old master before moving
   Make sure new master is in sync
Scripts available to automate failover:
   MySQL-MHA http://code.google.com/p/mysql-master-ha/
   MMM (not-recommended) http://mysql-mmm.org/
   Percona-PRM
   http://www.mysqlperformanceblog.com/2011/11/29/percona-replication-manager-a-
   solution-for-mysql-high-availability-with-replication-using-pacemaker/


                                                              www.percona.com   78
High Availability
Due to asynchronous’ness, data might be lost:
Semi-Synchronous Replication:
  ensure at least one slave’s IO thread has received the event
  before the transaction is committed.
  http://dev.mysql.com/doc/refman/5.5/en/replication-semisync.html




                                                                www.percona.com   79
Backups
Point In Time Recovery, using binary logs
Delayed slave
Backup Slaves




                                            www.percona.com   80
Incremental / Point In Time Recovery
Restore Full Backup from your favorite backup tool
Replay binary logs with mysqldump from the last position
of the backup
# mysqlbinlog --start-position=15115 1sbinarylog | mysql
# mysqlbinlog                   next-binary-logs | mysql
If PITR, stop at the desired position/time:
# mysqlbinlog --stop-position=102151   binarylog | mysql
# mysqlbinlog --stop-datetime=“2012-01-01 23:00:00” 
                                   lastbinarylog | mysql




                                                  www.percona.com   81
Delayed Slave
Deliberately lag a slave for a predefined amount of time
Decrease recovery time in case of bad changes caused by:
  Humans (DROP DATABASE)
  Application (DELETE FROM table;)
How to configure:
  pt-slave-delay --delay 60m
  (http://www.percona.com/doc/percona-toolkit/2.0/pt-slave-delay.html)
  5.6 Built-in feature:
  > CHANGE MASTER TO MASTER_DELAY=3600;
When a problem happens stop replication just before the
malicious statement.
START SLAVE UNTIL MASTER_LOG_FILE='log_name',
MASTER_LOG_POS = pos;
                                                                 www.percona.com   82
Backup using Slaves
Online Backups might not be possible on active master:
Too much impact to make online:
  InnoDB backup
  (using MySQL enterprise backup or XtraBackup)
  LVM Snapshots MyISAM tables
Offsite Backup




                                              www.percona.com   83
MySQL Replication
Replication Overview
Binary Logs
Setting Up Replication
Commands
Other Common Configuration Settings
Replication Architectures
Common Issues
Replication Use Cases
Other Replication Implementations
Tools


                                      www.percona.com   84
Other Replication Implementations
Tungsten Replicator
  Uses binary log
  Parallel replication
  Enhanced filtering
  Multi-master
  Replication between different databases
Galera Cluster
  Does not use binary log
  Synchronous replication
  Active-active master
  Parallel replication
  Percona XtraDB Cluster! http://www.mysqlperformanceblog.com/2012/01/09/
  announcement-of-percona-xtradb-cluster-alpha-release/
                                                          www.percona.com   85
Tungsten Replicator




http://continuent.com/
http://code.google.com/p/tungsten-replicator/
                                                www.percona.com   86
Galera Cluster




http://codership.com/
                                   www.percona.com   87
MySQL Replication
Replication Overview
Binary Logs
Setting Up Replication
Commands
Other Common Configuration Settings
Replication Architectures
Common Issues
Replication Use Cases
Other Replication Implementations
Tools


                                      www.percona.com   88
Tools & More Info
Percona Toolkit http://www.percona.com/software/percona-toolkit/
pt-slave-find, pt-table-checksum, pt-table-sync,
pt-slave-delay, pt-slave-restart, pt-heartbeat
Percona Server http://www.percona.com/software/percona-server/
OpenArk kit http://code.openark.org/forge/openark-kit
Replication Booster https://github.com/yoshinorim/replication-booster-for-mysql
High Availability
    MMM http://mysql-mmm.org/
    Percona-PRM
    http://www.mysqlperformanceblog.com/2011/11/29/percona-replication-manager-a-
    solution-for-mysql-high-availability-with-replication-using-pacemaker/
    MySQL-MHA http://code.google.com/p/mysql-master-ha/
High Performance MySQL, 2nd Edition:
http://shop.oreilly.com/product/9780596101718.do

                                                               www.percona.com   89
MySQL Replication
Replication Overview
Binary Logs
Setting Up Replication
Commands
Other Common Configuration Settings
Replication Architectures
Common Issues
Replication Use Cases
Other Replication Implementations
Tools


                                      www.percona.com   90
Kenny Gryp
                 <kenny.gryp@percona.com>
                                    @gryp




                    We're Hiring!
www.percona.com/about-us/careers/

Weitere ähnliche Inhalte

Was ist angesagt?

Shipping Data from Postgres to Clickhouse, by Murat Kabilov, Adjust
Shipping Data from Postgres to Clickhouse, by Murat Kabilov, AdjustShipping Data from Postgres to Clickhouse, by Murat Kabilov, Adjust
Shipping Data from Postgres to Clickhouse, by Murat Kabilov, AdjustAltinity Ltd
 
MySQL Replication Overview -- PHPTek 2016
MySQL Replication Overview -- PHPTek 2016MySQL Replication Overview -- PHPTek 2016
MySQL Replication Overview -- PHPTek 2016Dave Stokes
 
MongoDB WiredTiger Internals
MongoDB WiredTiger InternalsMongoDB WiredTiger Internals
MongoDB WiredTiger InternalsNorberto Leite
 
ClickHouse Features for Advanced Users, by Aleksei Milovidov
ClickHouse Features for Advanced Users, by Aleksei MilovidovClickHouse Features for Advanced Users, by Aleksei Milovidov
ClickHouse Features for Advanced Users, by Aleksei MilovidovAltinity Ltd
 
Percona Live 2022 - MySQL Architectures
Percona Live 2022 - MySQL ArchitecturesPercona Live 2022 - MySQL Architectures
Percona Live 2022 - MySQL ArchitecturesFrederic Descamps
 
Kogito: cloud native business automation
Kogito: cloud native business automationKogito: cloud native business automation
Kogito: cloud native business automationMario Fusco
 
All About JSON and ClickHouse - Tips, Tricks and New Features-2022-07-26-FINA...
All About JSON and ClickHouse - Tips, Tricks and New Features-2022-07-26-FINA...All About JSON and ClickHouse - Tips, Tricks and New Features-2022-07-26-FINA...
All About JSON and ClickHouse - Tips, Tricks and New Features-2022-07-26-FINA...Altinity Ltd
 
MySQL Optimizer Cost Model
MySQL Optimizer Cost ModelMySQL Optimizer Cost Model
MySQL Optimizer Cost ModelOlav Sandstå
 
Better than you think: Handling JSON data in ClickHouse
Better than you think: Handling JSON data in ClickHouseBetter than you think: Handling JSON data in ClickHouse
Better than you think: Handling JSON data in ClickHouseAltinity Ltd
 
Achieving compliance With MongoDB Security
Achieving compliance With MongoDB Security Achieving compliance With MongoDB Security
Achieving compliance With MongoDB Security Mydbops
 
An Introduction To NoSQL & MongoDB
An Introduction To NoSQL & MongoDBAn Introduction To NoSQL & MongoDB
An Introduction To NoSQL & MongoDBLee Theobald
 
Redis cluster
Redis clusterRedis cluster
Redis clusteriammutex
 
Practical Partitioning in Production with Postgres
Practical Partitioning in Production with PostgresPractical Partitioning in Production with Postgres
Practical Partitioning in Production with PostgresEDB
 
InnoDB Performance Optimisation
InnoDB Performance OptimisationInnoDB Performance Optimisation
InnoDB Performance OptimisationMydbops
 
Entity Framework Core
Entity Framework CoreEntity Framework Core
Entity Framework CoreKiran Shahi
 

Was ist angesagt? (20)

Shipping Data from Postgres to Clickhouse, by Murat Kabilov, Adjust
Shipping Data from Postgres to Clickhouse, by Murat Kabilov, AdjustShipping Data from Postgres to Clickhouse, by Murat Kabilov, Adjust
Shipping Data from Postgres to Clickhouse, by Murat Kabilov, Adjust
 
MySQL Replication Overview -- PHPTek 2016
MySQL Replication Overview -- PHPTek 2016MySQL Replication Overview -- PHPTek 2016
MySQL Replication Overview -- PHPTek 2016
 
KFServing and Feast
KFServing and FeastKFServing and Feast
KFServing and Feast
 
MongoDB WiredTiger Internals
MongoDB WiredTiger InternalsMongoDB WiredTiger Internals
MongoDB WiredTiger Internals
 
ClickHouse Features for Advanced Users, by Aleksei Milovidov
ClickHouse Features for Advanced Users, by Aleksei MilovidovClickHouse Features for Advanced Users, by Aleksei Milovidov
ClickHouse Features for Advanced Users, by Aleksei Milovidov
 
Percona Live 2022 - MySQL Architectures
Percona Live 2022 - MySQL ArchitecturesPercona Live 2022 - MySQL Architectures
Percona Live 2022 - MySQL Architectures
 
NoSQL databases
NoSQL databasesNoSQL databases
NoSQL databases
 
Kogito: cloud native business automation
Kogito: cloud native business automationKogito: cloud native business automation
Kogito: cloud native business automation
 
All About JSON and ClickHouse - Tips, Tricks and New Features-2022-07-26-FINA...
All About JSON and ClickHouse - Tips, Tricks and New Features-2022-07-26-FINA...All About JSON and ClickHouse - Tips, Tricks and New Features-2022-07-26-FINA...
All About JSON and ClickHouse - Tips, Tricks and New Features-2022-07-26-FINA...
 
MySQL Optimizer Cost Model
MySQL Optimizer Cost ModelMySQL Optimizer Cost Model
MySQL Optimizer Cost Model
 
NOSQL vs SQL
NOSQL vs SQLNOSQL vs SQL
NOSQL vs SQL
 
Better than you think: Handling JSON data in ClickHouse
Better than you think: Handling JSON data in ClickHouseBetter than you think: Handling JSON data in ClickHouse
Better than you think: Handling JSON data in ClickHouse
 
Achieving compliance With MongoDB Security
Achieving compliance With MongoDB Security Achieving compliance With MongoDB Security
Achieving compliance With MongoDB Security
 
An Introduction To NoSQL & MongoDB
An Introduction To NoSQL & MongoDBAn Introduction To NoSQL & MongoDB
An Introduction To NoSQL & MongoDB
 
Redis cluster
Redis clusterRedis cluster
Redis cluster
 
Automated master failover
Automated master failoverAutomated master failover
Automated master failover
 
Practical Partitioning in Production with Postgres
Practical Partitioning in Production with PostgresPractical Partitioning in Production with Postgres
Practical Partitioning in Production with Postgres
 
SQL Tuning 101
SQL Tuning 101SQL Tuning 101
SQL Tuning 101
 
InnoDB Performance Optimisation
InnoDB Performance OptimisationInnoDB Performance Optimisation
InnoDB Performance Optimisation
 
Entity Framework Core
Entity Framework CoreEntity Framework Core
Entity Framework Core
 

Andere mochten auch

Oracle 11g R2 RAC implementation and concept
Oracle 11g R2 RAC implementation and conceptOracle 11g R2 RAC implementation and concept
Oracle 11g R2 RAC implementation and conceptSantosh Kangane
 
MySQL Atchitecture and Concepts
MySQL Atchitecture and ConceptsMySQL Atchitecture and Concepts
MySQL Atchitecture and ConceptsTuyen Vuong
 
Oracle architecture ppt
Oracle architecture pptOracle architecture ppt
Oracle architecture pptDeepak Shetty
 
MySQL::Replication (Melbourne Perl Mongers 2011-07)
MySQL::Replication (Melbourne Perl Mongers 2011-07)MySQL::Replication (Melbourne Perl Mongers 2011-07)
MySQL::Replication (Melbourne Perl Mongers 2011-07)Alfie John
 
DBA新人的述职报告
DBA新人的述职报告DBA新人的述职报告
DBA新人的述职报告mysqlops
 
MySQL应用优化实践
MySQL应用优化实践MySQL应用优化实践
MySQL应用优化实践mysqlops
 
分布式爬虫
分布式爬虫分布式爬虫
分布式爬虫mysqlops
 
Percona Live 2012PPT:mysql-security-privileges-and-user-management
Percona Live 2012PPT:mysql-security-privileges-and-user-managementPercona Live 2012PPT:mysql-security-privileges-and-user-management
Percona Live 2012PPT:mysql-security-privileges-and-user-managementmysqlops
 
QQ聊天系统后台架构的演化与启示
QQ聊天系统后台架构的演化与启示QQ聊天系统后台架构的演化与启示
QQ聊天系统后台架构的演化与启示mysqlops
 
SBAAAM, Web Push Notification System V.12
SBAAAM, Web Push Notification System V.12SBAAAM, Web Push Notification System V.12
SBAAAM, Web Push Notification System V.12Marco Del Bene
 
服务器性能测试介绍
服务器性能测试介绍服务器性能测试介绍
服务器性能测试介绍Paro Yin
 
Oracle数据库分析函数详解
Oracle数据库分析函数详解Oracle数据库分析函数详解
Oracle数据库分析函数详解mysqlops
 
The simplethebeautiful
The simplethebeautifulThe simplethebeautiful
The simplethebeautifulmysqlops
 
MySQL Cluster performance best practices
MySQL Cluster performance best practicesMySQL Cluster performance best practices
MySQL Cluster performance best practicesMat Keep
 
Step by Step Restore rman to different host
Step by Step Restore rman to different hostStep by Step Restore rman to different host
Step by Step Restore rman to different hostOsama Mustafa
 
MySQL Group Replication - an Overview
MySQL Group Replication - an OverviewMySQL Group Replication - an Overview
MySQL Group Replication - an OverviewMatt Lord
 
MySQL Backup and Recovery Essentials
MySQL Backup and Recovery EssentialsMySQL Backup and Recovery Essentials
MySQL Backup and Recovery EssentialsRonald Bradford
 
MySQL High Availability with Group Replication
MySQL High Availability with Group ReplicationMySQL High Availability with Group Replication
MySQL High Availability with Group ReplicationNuno Carvalho
 

Andere mochten auch (20)

Data Guard Architecture & Setup
Data Guard Architecture & SetupData Guard Architecture & Setup
Data Guard Architecture & Setup
 
Oracle 11g R2 RAC implementation and concept
Oracle 11g R2 RAC implementation and conceptOracle 11g R2 RAC implementation and concept
Oracle 11g R2 RAC implementation and concept
 
MySQL Atchitecture and Concepts
MySQL Atchitecture and ConceptsMySQL Atchitecture and Concepts
MySQL Atchitecture and Concepts
 
Introduction to Mysql
Introduction to MysqlIntroduction to Mysql
Introduction to Mysql
 
Oracle architecture ppt
Oracle architecture pptOracle architecture ppt
Oracle architecture ppt
 
MySQL::Replication (Melbourne Perl Mongers 2011-07)
MySQL::Replication (Melbourne Perl Mongers 2011-07)MySQL::Replication (Melbourne Perl Mongers 2011-07)
MySQL::Replication (Melbourne Perl Mongers 2011-07)
 
DBA新人的述职报告
DBA新人的述职报告DBA新人的述职报告
DBA新人的述职报告
 
MySQL应用优化实践
MySQL应用优化实践MySQL应用优化实践
MySQL应用优化实践
 
分布式爬虫
分布式爬虫分布式爬虫
分布式爬虫
 
Percona Live 2012PPT:mysql-security-privileges-and-user-management
Percona Live 2012PPT:mysql-security-privileges-and-user-managementPercona Live 2012PPT:mysql-security-privileges-and-user-management
Percona Live 2012PPT:mysql-security-privileges-and-user-management
 
QQ聊天系统后台架构的演化与启示
QQ聊天系统后台架构的演化与启示QQ聊天系统后台架构的演化与启示
QQ聊天系统后台架构的演化与启示
 
SBAAAM, Web Push Notification System V.12
SBAAAM, Web Push Notification System V.12SBAAAM, Web Push Notification System V.12
SBAAAM, Web Push Notification System V.12
 
服务器性能测试介绍
服务器性能测试介绍服务器性能测试介绍
服务器性能测试介绍
 
Oracle数据库分析函数详解
Oracle数据库分析函数详解Oracle数据库分析函数详解
Oracle数据库分析函数详解
 
The simplethebeautiful
The simplethebeautifulThe simplethebeautiful
The simplethebeautiful
 
MySQL Cluster performance best practices
MySQL Cluster performance best practicesMySQL Cluster performance best practices
MySQL Cluster performance best practices
 
Step by Step Restore rman to different host
Step by Step Restore rman to different hostStep by Step Restore rman to different host
Step by Step Restore rman to different host
 
MySQL Group Replication - an Overview
MySQL Group Replication - an OverviewMySQL Group Replication - an Overview
MySQL Group Replication - an Overview
 
MySQL Backup and Recovery Essentials
MySQL Backup and Recovery EssentialsMySQL Backup and Recovery Essentials
MySQL Backup and Recovery Essentials
 
MySQL High Availability with Group Replication
MySQL High Availability with Group ReplicationMySQL High Availability with Group Replication
MySQL High Availability with Group Replication
 

Ähnlich wie Percona Live 2012PPT: introduction-to-mysql-replication

MySQL Replication Basics -Ohio Linux Fest 2016
MySQL Replication Basics -Ohio Linux Fest 2016MySQL Replication Basics -Ohio Linux Fest 2016
MySQL Replication Basics -Ohio Linux Fest 2016Dave Stokes
 
2012 replication
2012 replication2012 replication
2012 replicationsqlhjalp
 
MySQL Replication Update -- Zendcon 2016
MySQL Replication Update -- Zendcon 2016MySQL Replication Update -- Zendcon 2016
MySQL Replication Update -- Zendcon 2016Dave Stokes
 
Fosdem2012 replication-features-of-2011
Fosdem2012 replication-features-of-2011Fosdem2012 replication-features-of-2011
Fosdem2012 replication-features-of-2011Sergey Petrunya
 
M|18 How Facebook Migrated to MyRocks
M|18 How Facebook Migrated to MyRocksM|18 How Facebook Migrated to MyRocks
M|18 How Facebook Migrated to MyRocksMariaDB plc
 
MySQL 5.7 in a Nutshell
MySQL 5.7 in a NutshellMySQL 5.7 in a Nutshell
MySQL 5.7 in a NutshellEmily Ikuta
 
2012 scale replication
2012 scale replication2012 scale replication
2012 scale replicationsqlhjalp
 
MySQL User Group NL - MySQL 8
MySQL User Group NL - MySQL 8MySQL User Group NL - MySQL 8
MySQL User Group NL - MySQL 8Frederic Descamps
 
ConFoo MySQL Replication Evolution : From Simple to Group Replication
ConFoo  MySQL Replication Evolution : From Simple to Group ReplicationConFoo  MySQL Replication Evolution : From Simple to Group Replication
ConFoo MySQL Replication Evolution : From Simple to Group ReplicationDave Stokes
 
MySQL Cluster Asynchronous replication (2014)
MySQL Cluster Asynchronous replication (2014) MySQL Cluster Asynchronous replication (2014)
MySQL Cluster Asynchronous replication (2014) Frazer Clement
 
[db tech showcase Tokyo 2014] B15: Scalability with MariaDB and MaxScale by ...
[db tech showcase Tokyo 2014] B15: Scalability with MariaDB and MaxScale  by ...[db tech showcase Tokyo 2014] B15: Scalability with MariaDB and MaxScale  by ...
[db tech showcase Tokyo 2014] B15: Scalability with MariaDB and MaxScale by ...Insight Technology, Inc.
 
MySQL Replication Evolution -- Confoo Montreal 2017
MySQL Replication Evolution -- Confoo Montreal 2017MySQL Replication Evolution -- Confoo Montreal 2017
MySQL Replication Evolution -- Confoo Montreal 2017Dave Stokes
 
MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)
MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)
MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)Jean-François Gagné
 
Redo log improvements MYSQL 8.0
Redo log improvements MYSQL 8.0Redo log improvements MYSQL 8.0
Redo log improvements MYSQL 8.0Mydbops
 
Optimizing MariaDB for maximum performance
Optimizing MariaDB for maximum performanceOptimizing MariaDB for maximum performance
Optimizing MariaDB for maximum performanceMariaDB plc
 
DBA だってもっと効率化したい!〜最近の自動化事情とOracle Database〜
DBA だってもっと効率化したい!〜最近の自動化事情とOracle Database〜DBA だってもっと効率化したい!〜最近の自動化事情とOracle Database〜
DBA だってもっと効率化したい!〜最近の自動化事情とOracle Database〜Michitoshi Yoshida
 
MySQL Binary Log API Presentation - OSCON 2011
MySQL Binary Log API Presentation - OSCON 2011MySQL Binary Log API Presentation - OSCON 2011
MySQL Binary Log API Presentation - OSCON 2011Mats Kindahl
 

Ähnlich wie Percona Live 2012PPT: introduction-to-mysql-replication (20)

MySQL Replication Basics -Ohio Linux Fest 2016
MySQL Replication Basics -Ohio Linux Fest 2016MySQL Replication Basics -Ohio Linux Fest 2016
MySQL Replication Basics -Ohio Linux Fest 2016
 
2012 replication
2012 replication2012 replication
2012 replication
 
MySQL Replication Update -- Zendcon 2016
MySQL Replication Update -- Zendcon 2016MySQL Replication Update -- Zendcon 2016
MySQL Replication Update -- Zendcon 2016
 
Fosdem2012 replication-features-of-2011
Fosdem2012 replication-features-of-2011Fosdem2012 replication-features-of-2011
Fosdem2012 replication-features-of-2011
 
M|18 How Facebook Migrated to MyRocks
M|18 How Facebook Migrated to MyRocksM|18 How Facebook Migrated to MyRocks
M|18 How Facebook Migrated to MyRocks
 
MySQL 5.7 in a Nutshell
MySQL 5.7 in a NutshellMySQL 5.7 in a Nutshell
MySQL 5.7 in a Nutshell
 
2012 scale replication
2012 scale replication2012 scale replication
2012 scale replication
 
MySQL database
MySQL databaseMySQL database
MySQL database
 
MySQL User Group NL - MySQL 8
MySQL User Group NL - MySQL 8MySQL User Group NL - MySQL 8
MySQL User Group NL - MySQL 8
 
ConFoo MySQL Replication Evolution : From Simple to Group Replication
ConFoo  MySQL Replication Evolution : From Simple to Group ReplicationConFoo  MySQL Replication Evolution : From Simple to Group Replication
ConFoo MySQL Replication Evolution : From Simple to Group Replication
 
MySQL Cluster Asynchronous replication (2014)
MySQL Cluster Asynchronous replication (2014) MySQL Cluster Asynchronous replication (2014)
MySQL Cluster Asynchronous replication (2014)
 
[db tech showcase Tokyo 2014] B15: Scalability with MariaDB and MaxScale by ...
[db tech showcase Tokyo 2014] B15: Scalability with MariaDB and MaxScale  by ...[db tech showcase Tokyo 2014] B15: Scalability with MariaDB and MaxScale  by ...
[db tech showcase Tokyo 2014] B15: Scalability with MariaDB and MaxScale by ...
 
MySQL Replication Evolution -- Confoo Montreal 2017
MySQL Replication Evolution -- Confoo Montreal 2017MySQL Replication Evolution -- Confoo Montreal 2017
MySQL Replication Evolution -- Confoo Montreal 2017
 
MariaDB workshop
MariaDB workshopMariaDB workshop
MariaDB workshop
 
MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)
MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)
MySQL Parallel Replication: All the 5.7 and 8.0 Details (LOGICAL_CLOCK)
 
Redo log improvements MYSQL 8.0
Redo log improvements MYSQL 8.0Redo log improvements MYSQL 8.0
Redo log improvements MYSQL 8.0
 
Optimizing MariaDB for maximum performance
Optimizing MariaDB for maximum performanceOptimizing MariaDB for maximum performance
Optimizing MariaDB for maximum performance
 
DBA だってもっと効率化したい!〜最近の自動化事情とOracle Database〜
DBA だってもっと効率化したい!〜最近の自動化事情とOracle Database〜DBA だってもっと効率化したい!〜最近の自動化事情とOracle Database〜
DBA だってもっと効率化したい!〜最近の自動化事情とOracle Database〜
 
MySQL Binary Log API Presentation - OSCON 2011
MySQL Binary Log API Presentation - OSCON 2011MySQL Binary Log API Presentation - OSCON 2011
MySQL Binary Log API Presentation - OSCON 2011
 
NoSQL with MySQL
NoSQL with MySQLNoSQL with MySQL
NoSQL with MySQL
 

Mehr von mysqlops

Percona Live 2012PPT: MySQL Cluster And NDB Cluster
Percona Live 2012PPT: MySQL Cluster And NDB ClusterPercona Live 2012PPT: MySQL Cluster And NDB Cluster
Percona Live 2012PPT: MySQL Cluster And NDB Clustermysqlops
 
Percona Live 2012PPT: MySQL Query optimization
Percona Live 2012PPT: MySQL Query optimizationPercona Live 2012PPT: MySQL Query optimization
Percona Live 2012PPT: MySQL Query optimizationmysqlops
 
Pldc2012 innodb architecture and internals
Pldc2012 innodb architecture and internalsPldc2012 innodb architecture and internals
Pldc2012 innodb architecture and internalsmysqlops
 
eBay EDW元数据管理及应用
eBay EDW元数据管理及应用eBay EDW元数据管理及应用
eBay EDW元数据管理及应用mysqlops
 
基于协程的网络开发框架的设计与实现
基于协程的网络开发框架的设计与实现基于协程的网络开发框架的设计与实现
基于协程的网络开发框架的设计与实现mysqlops
 
eBay基于Hadoop平台的用户邮件数据分析
eBay基于Hadoop平台的用户邮件数据分析eBay基于Hadoop平台的用户邮件数据分析
eBay基于Hadoop平台的用户邮件数据分析mysqlops
 
对MySQL DBA的一些思考
对MySQL DBA的一些思考对MySQL DBA的一些思考
对MySQL DBA的一些思考mysqlops
 
腾讯即时聊天IM1.4亿在线背后的故事
腾讯即时聊天IM1.4亿在线背后的故事腾讯即时聊天IM1.4亿在线背后的故事
腾讯即时聊天IM1.4亿在线背后的故事mysqlops
 
分布式存储与TDDL
分布式存储与TDDL分布式存储与TDDL
分布式存储与TDDLmysqlops
 
MySQL数据库生产环境维护
MySQL数据库生产环境维护MySQL数据库生产环境维护
MySQL数据库生产环境维护mysqlops
 
MySQL数据库开发的三十六条军规
MySQL数据库开发的三十六条军规MySQL数据库开发的三十六条军规
MySQL数据库开发的三十六条军规mysqlops
 
Web请求异步处理和海量数据即时分析在淘宝开放平台的实践
Web请求异步处理和海量数据即时分析在淘宝开放平台的实践Web请求异步处理和海量数据即时分析在淘宝开放平台的实践
Web请求异步处理和海量数据即时分析在淘宝开放平台的实践mysqlops
 
新浪微博开放平台Redis实战
新浪微博开放平台Redis实战新浪微博开放平台Redis实战
新浪微博开放平台Redis实战mysqlops
 
MySQL Explain输出详解
MySQL Explain输出详解MySQL Explain输出详解
MySQL Explain输出详解mysqlops
 
MySQL Explain输出详解
MySQL Explain输出详解MySQL Explain输出详解
MySQL Explain输出详解mysqlops
 
如何写有效的Bug报告
如何写有效的Bug报告如何写有效的Bug报告
如何写有效的Bug报告mysqlops
 
如何写有效的Bug报告
如何写有效的Bug报告如何写有效的Bug报告
如何写有效的Bug报告mysqlops
 

Mehr von mysqlops (20)

Percona Live 2012PPT: MySQL Cluster And NDB Cluster
Percona Live 2012PPT: MySQL Cluster And NDB ClusterPercona Live 2012PPT: MySQL Cluster And NDB Cluster
Percona Live 2012PPT: MySQL Cluster And NDB Cluster
 
Percona Live 2012PPT: MySQL Query optimization
Percona Live 2012PPT: MySQL Query optimizationPercona Live 2012PPT: MySQL Query optimization
Percona Live 2012PPT: MySQL Query optimization
 
Pldc2012 innodb architecture and internals
Pldc2012 innodb architecture and internalsPldc2012 innodb architecture and internals
Pldc2012 innodb architecture and internals
 
eBay EDW元数据管理及应用
eBay EDW元数据管理及应用eBay EDW元数据管理及应用
eBay EDW元数据管理及应用
 
基于协程的网络开发框架的设计与实现
基于协程的网络开发框架的设计与实现基于协程的网络开发框架的设计与实现
基于协程的网络开发框架的设计与实现
 
eBay基于Hadoop平台的用户邮件数据分析
eBay基于Hadoop平台的用户邮件数据分析eBay基于Hadoop平台的用户邮件数据分析
eBay基于Hadoop平台的用户邮件数据分析
 
对MySQL DBA的一些思考
对MySQL DBA的一些思考对MySQL DBA的一些思考
对MySQL DBA的一些思考
 
腾讯即时聊天IM1.4亿在线背后的故事
腾讯即时聊天IM1.4亿在线背后的故事腾讯即时聊天IM1.4亿在线背后的故事
腾讯即时聊天IM1.4亿在线背后的故事
 
分布式存储与TDDL
分布式存储与TDDL分布式存储与TDDL
分布式存储与TDDL
 
MySQL数据库生产环境维护
MySQL数据库生产环境维护MySQL数据库生产环境维护
MySQL数据库生产环境维护
 
Memcached
MemcachedMemcached
Memcached
 
DevOPS
DevOPSDevOPS
DevOPS
 
MySQL数据库开发的三十六条军规
MySQL数据库开发的三十六条军规MySQL数据库开发的三十六条军规
MySQL数据库开发的三十六条军规
 
Web请求异步处理和海量数据即时分析在淘宝开放平台的实践
Web请求异步处理和海量数据即时分析在淘宝开放平台的实践Web请求异步处理和海量数据即时分析在淘宝开放平台的实践
Web请求异步处理和海量数据即时分析在淘宝开放平台的实践
 
新浪微博开放平台Redis实战
新浪微博开放平台Redis实战新浪微博开放平台Redis实战
新浪微博开放平台Redis实战
 
MySQL Explain输出详解
MySQL Explain输出详解MySQL Explain输出详解
MySQL Explain输出详解
 
MySQL Explain输出详解
MySQL Explain输出详解MySQL Explain输出详解
MySQL Explain输出详解
 
Cbo100053
Cbo100053Cbo100053
Cbo100053
 
如何写有效的Bug报告
如何写有效的Bug报告如何写有效的Bug报告
如何写有效的Bug报告
 
如何写有效的Bug报告
如何写有效的Bug报告如何写有效的Bug报告
如何写有效的Bug报告
 

Kürzlich hochgeladen

Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfLoriGlavin3
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESmohitsingh558521
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxLoriGlavin3
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxLoriGlavin3
 

Kürzlich hochgeladen (20)

Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
Moving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdfMoving Beyond Passwords: FIDO Paris Seminar.pdf
Moving Beyond Passwords: FIDO Paris Seminar.pdf
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICESSALESFORCE EDUCATION CLOUD | FEXLE SERVICES
SALESFORCE EDUCATION CLOUD | FEXLE SERVICES
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptxUse of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
Use of FIDO in the Payments and Identity Landscape: FIDO Paris Seminar.pptx
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptxMerck Moving Beyond Passwords: FIDO Paris Seminar.pptx
Merck Moving Beyond Passwords: FIDO Paris Seminar.pptx
 

Percona Live 2012PPT: introduction-to-mysql-replication

  • 1. Introduction To MySQL Replication Kenny Gryp <kenny.gryp@percona.com> Percona Live Washington DC / 2012-01-11
  • 2. MySQL Replication Replication Overview Binary Logs Setting Up Replication Commands Other Common Configuration Settings Replication Architectures Common Issues Replication Use Cases Other Replication Implementations Tools www.percona.com 2
  • 3. MySQL Replication Replication Overview Binary Logs Setting Up Replication Commands Other Common Configuration Settings Replication Architectures Common Issues Replication Use Cases Other Replication Implementations Tools www.percona.com 3
  • 4. What is Replication? Replication enables data from one MySQL database server (the master) to be replicated to one or more MySQL database servers (the slaves) (Source: http://dev.mysql.com/doc/refman/5.5/en/replication.html) www.percona.com 4
  • 5. Replication Diagram APPLICATION Queries MASTER SLAVE ... SQL Thread ... MyISAM MyISAM INNODB INNODB IO Thread BINLOGS RELAY LOGS www.percona.com 5
  • 6. Replication Diagram APPLICATION Queries Queries MASTER BINLOGS SLAVE ... SQL Thread ... MyISAM MyISAM INNODB INNODB IO Thread BINLOGS RELAY LOGS www.percona.com 6
  • 7. Replication Happens at MySQL level, not Storage Engine Level (*NDB) Asynchronous! (Semi-sync available in 5.5) A server can have only 1 master IO Thread: Fetches from master SQL Thread: Executes on slave Single Threaded Execution (Expect enhancements in 5.6) Different schema’s are possible between master and slave (Watch out!!): different indexes storage engines data types columns www.percona.com 7
  • 8. MySQL Replication Replication Overview Binary Logs Setting Up Replication Commands Other Common Configuration Settings Replication Architectures Common Issues Replication Use Cases Other Replication Implementations Tools www.percona.com 8
  • 9. Binary Logs BINLOG.000001 BINLOG.index BINLOG.000002 BINLOG.000001 BINLOG.000003 BINLOG.000002 BINLOG…. BINLOG.000003 www.percona.com 9
  • 10. Binary Logs Set of files Contains all writes and schema changes != REDO/Transaction log Rotated when full (Set max_binlog_size) Incrementing numbers (000001,000002,000003,...) Relay Logs are also binary logs 2 Formats: Statement Based (SBR) Row Based (RBR, since MySQL 5.1) Binary file www.percona.com 10
  • 11. Binary Logs - Info Files master.info Contains IO Thread information & connection information relay.info Contains SQL Thread information www.percona.com 11
  • 12. Binary Log - Formats (binlog_format) Statement Based Replication (SBR): Writes statements to binary logs, slave executes the stmts (An update stmt that changes 1 row but reads many will also do the same on the slave) Some functions are non-deterministic and cause inconsistencies: UUID(), SYSDATE(), FOUND_ROWS(), UPDATE .. LIMIT without ORDER BY... Works for NOW(): timestamp included in binary log More complete list of issues: http://dev.mysql.com/doc/refman/5.5/en/replication-features.html www.percona.com 12
  • 13. Binary Log - Formats (binlog_format) Row Based Replication (RBR, since 5.1): Write row changes (larger binlogs) Check Binlog_cache_disk_use, possibly increase binlog_cache_size Does not need to parse/execute queries, just make the changes necessary Much less/different issues compared to SBR: http://dev.mysql.com/doc/refman/5.5/en/replication-rbr- usage.html Mixed: Combination of both: defaults to SBR, use RBR when necessary www.percona.com 13
  • 14. Looking at Binary Log Contents mysqlbinlog SHOW BINLOG EVENTS www.percona.com 14
  • 15. Example SBR > SHOW GLOBAL VARIABLES LIKE 'binlog_format'; +---------------+-----------+ | Variable_name | Value | +---------------+-----------+ | binlog_format | STATEMENT | +---------------+-----------+ 1 row in set (0.00 sec) > CREATE DATABASE replication; Query OK, 1 row affected (0.14 sec) > use replication Database changed > CREATE TABLE repl (a int) ENGINE=innodb; Query OK, 0 rows affected (0.25 sec) > INSERT INTO repl VALUES (1); Query OK, 1 row affected (0.14 sec) www.percona.com 15
  • 16. Example SBR - mysqlbinlog # mysqlbinlog mysql-bin.000193 ... # at 106 #120106 15:19:13 server id 9999 end_log_pos 203 ! Query! thread_id=11 CREATE DATABASE replication /*!*/; # at 203 #120106 15:19:32 server id 9999 end_log_pos 312 ! Query! thread_id=11 ! exec_time=1! error_code=0 use replication/*!*/; SET TIMESTAMP=1325859572/*!*/; CREATE TABLE repl (a INT) ENGINE=innodb /*!*/; # at 312 #120106 15:19:55 server id 9999 end_log_pos 387 ! Query! thread_id=11 ! exec_time=0! error_code=0 SET TIMESTAMP=1325859595/*!*/; BEGIN /*!*/; # at 387 #120106 15:19:55 server id 9999 end_log_pos 484 ! Query! thread_id=11 ! exec_time=0! error_code=0 SET TIMESTAMP=1325859595/*!*/; INSERT INTO repl VALUES (1) /*!*/; # at 484 #120106 15:19:55 server id 9999 end_log_pos 511 ! Xid = 14 www.percona.com 16 COMMIT/*!*/;
  • 17. > SHOW BINLOG EVENTS FROM 106G *************************** 1. row *************************** Log_name: mysql-bin.000193 Example SBR - SHOW BINLOG EVENTS Pos: 106 Event_type: Query Server_id: 1 End_log_pos: 203 Info: CREATE DATABASE replication *************************** 2. row *************************** Log_name: mysql-bin.000193 Pos: 203 Event_type: Query Server_id: 1 End_log_pos: 312 Info: use `replication`; CREATE TABLE repl (a INT) ENGINE=innodb *************************** 3. row *************************** Log_name: mysql-bin.000193 Pos: 312 Event_type: Query Server_id: 1 End_log_pos: 387 Info: BEGIN *************************** 4. row *************************** Log_name: mysql-bin.000193 Pos: 387 Event_type: Query Server_id: 1 End_log_pos: 484 Info: use `replication`; INSERT INTO repl VALUES (1) *************************** 5. row *************************** Log_name: mysql-bin.000193 Pos: 484 Event_type: Xid Server_id: 1 End_log_pos: 511 Info: COMMIT /* xid=14 */ 5 rows in set (0.00 sec) www.percona.com 17
  • 18. Example RBR > SHOW GLOBAL VARIABLES LIKE 'binlog_format'; +---------------+-------+ | Variable_name | Value | +---------------+-------+ | binlog_format | ROW | +---------------+-------+ 1 row in set (0.00 sec) > CREATE DATABASE replication; Query OK, 1 row affected (0.14 sec) > use replication Database changed > CREATE TABLE repl (a int) ENGINE=innodb; Query OK, 0 rows affected (0.25 sec) > INSERT INTO repl VALUES (1); Query OK, 1 row affected (0.14 sec) www.percona.com 18
  • 19. Example RBR - mysqlbinlog # mysqlbinlog mysql-bin.000193 --start-position=606 ... # at 606 #120106 15:54:54 server id 1 end_log_pos 703 ! Query! thread_id=11 ! exec_time=0! error_code=0 CREATE DATABASE replication /*!*/; # at 703 #120106 15:55:02 server id 1 end_log_pos 812 ! Query! thread_id=11 ! exec_time=0! error_code=0 use replication/*!*/; SET TIMESTAMP=1325861702/*!*/; CREATE TABLE repl (a int) ENGINE=innodb /*!*/; # at 812 ... # at 937 #120106 15:55:06 server id 1 end_log_pos 937 ! Table_map: `replication`.`repl` mapped to number 17 #120106 15:55:06 server id 1 end_log_pos 971 ! Write_rows: table id 17 flags: STMT_END_F BINLOG ' SgsHTxMBAAAAMgAAAKkDAAAAABEAAAAAAAEAC3JlcGxpY2F0aW9uAARyZXBsAAEDAAE= SgsHTxcBAAAAIgAAAMsDAAAAABEAAAAAAAEAAf/+AQAAAA== '/*!*/; # at 971 #120106 15:55:06 server id 1 end_log_pos 998 ! Xid = 34 www.percona.com 19 COMMIT/*!*/;
  • 20. Example RBR - mysqlbinlog --verbose # mysqlbinlog mysql-bin.000193 --verbose --verbose ... # at 937 #120106 15:55:06 server id 1 end_log_pos 937 ! Table_map: `replication`.`repl` mapped to number 17 #120106 15:55:06 server id 1 end_log_pos 971 ! Write_rows: table id 17 flags: STMT_END_F BINLOG ' SgsHTxMBAAAAMgAAAKkDAAAAABEAAAAAAAEAC3JlcGxpY2F0aW9uAARyZXBsAAEDAAE= SgsHTxcBAAAAIgAAAMsDAAAAABEAAAAAAAEAAf/+AQAAAA== '/*!*/; ### INSERT INTO replication.repl ### SET ### @1=1 /* INT meta=0 nullable=1 is_null=0 */ # at 971 www.percona.com 20
  • 21. > SHOW BINLOG EVENTS FROM 606G *************************** 1. row *************************** Log_name: mysql-bin.000193 Example RBR - SHOW BINLOG EVENTS Pos: 606 Event_type: Query Server_id: 1 End_log_pos: 703 Info: CREATE DATABASE replication *************************** 2. row *************************** Log_name: mysql-bin.000193 Pos: 703 Event_type: Query Server_id: 1 End_log_pos: 812 Info: use `replication`; CREATE TABLE repl (a int) ENGINE=innodb ... *************************** 4. row *************************** Log_name: mysql-bin.000193 Pos: 887 Event_type: Table_map Server_id: 1 End_log_pos: 937 Info: table_id: 17 (replication.repl) *************************** 5. row *************************** Log_name: mysql-bin.000193 Pos: 937 Event_type: Write_rows Server_id: 1 End_log_pos: 971 Info: table_id: 17 flags: STMT_END_F *************************** 6. row *************************** Log_name: mysql-bin.000193 Pos: 971 Event_type: Xid Server_id: 1 End_log_pos: 998 Info: COMMIT /* xid=34 */ www.percona.com 21 6 rows in set (0.00 sec)
  • 22. MySQL Replication Replication Overview Binary Logs Setting Up Replication Commands Other Common Configuration Settings Replication Architectures Common Issues Replication Use Cases Other Replication Implementations Tools www.percona.com 22
  • 23. Setting up Replication Prerequisites Change master/slave MySQL configuration Configure Replication Start Replication/Check Status www.percona.com 23
  • 24. Prerequisites No way to easily create slave with 1 command It’s required to Create/Restore consistent backup using your favorite backup tool with mysqldump, use --master-data Binlog file and position from backup should be recorded File: mysql-bin.000008 Pos: 106 www.percona.com 24
  • 25. Change master/slave Configuration On the master: Enable Binary Logging: log-bin=log-bin Set A Server ID: server-id=1 On the slave: Set A Server ID: server-id=2 www.percona.com 25
  • 26. Why server-id ? APPLICATION Queries Queries MASTER BINLOGS SLAVE events get ... server-id=1 SQL Thread ... MyISAM MyISAM INNODB server-id != 2 INNODB IO Thread BINLOGS RELAY LOGS server-id=1 server-id=2 www.percona.com 26
  • 27. Why server-id ? APPLICATION Queries Queries MASTER server-id != 1 RELAY LOGS BINLOGS SLAVE events get server-id=2 SQL Thread IO Thread log_slave_updates log_slave_updates events get ... server-id=1 SQL Thread ... MyISAM MyISAM INNODB server-id != 2 INNODB IO Thread BINLOGS RELAY LOGS server-id=1 server-id=2 www.percona.com 27
  • 28. Why server-id ? Avoid events to be written more than once replicate_same_server_id does what it says www.percona.com 28
  • 29. Configure Replication On Master, add permissions: > GRANT REPLICATION SLAVE ON *.* TO ‘repl’@‘slave’ IDENTIFIED BY ‘pass’; On Slave, configure replication: > CHANGE MASTER TO MASTER_HOST=‘master’, MASTER_USER=‘repl’, MASTER_PASSWORD=‘pass’, MASTER_LOG_FILE=‘mysql-bin.000008’, MASTER_LOG_POS=106; www.percona.com 29
  • 30. slave> START SLAVE; slave> SHOW SLAVE STATUSG Slave_IO_State: Waiting for master to send event IO Thread State Start Replication Master_Host: master Master_User: repl Master_Port: 3306 Connect_Retry: Master_Log_File: 60 mysql-bin.000008 IO Thread Read Up To Read_Master_Log_Pos: 254 Relay_Log_File: Relay_Log_Pos: relay-bin.000002 399 SQL Thread Read Up To Relay_Master_Log_File: mysql-bin.000008 Slave_IO_Running: Slave_SQL_Running: Yes Yes Threads Running? Replicate_Do_DB: Replicate_Ignore_DB: Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: Last_Errno: 0 Last_Error: Skip_Counter: 0 Exec_Master_Log_Pos: 254 Relay_Log_Space: 566 Until_Condition: None Until_Log_File: Until_Log_Pos: 0 Master_SSL_Allowed: No Master_SSL_CA_File: Master_SSL_CA_Path: Master_SSL_Cert: Master_SSL_Cipher: Master_SSL_Key: Seconds_Behind_Master: Master_SSL_Verify_Server_Cert: 0 No How Far Is Slave Behind? Last_IO_Errno: 0 Last_IO_Error: Last_SQL_Errno: 0 www.percona.com 30 Last_SQL_Error:
  • 31. MySQL Replication Replication Overview Binary Logs Setting Up Replication Commands Other Common Configuration Settings Replication Architectures Common Issues Replication Use Cases Other Replication Implementations Tools www.percona.com 31
  • 32. Commands SQL Commands Adminstrative Commands Diagnostics Commands Shell Commands mysqlbinlog www.percona.com 32
  • 33. Administrative Commands Rotate binary log: FLUSH BINARY LOGS Rotate relay log: FLUSH RELAY LOGS START/STOP SLAVE IO_THREAD/SQL_THREAD Remove binary logs: PURGE MASTER LOGS TO ‘mysql-bin.000005’; PURGE MASTER LOGS BEFORE ‘2012-01-01 00:00:00’; Remove all binary logs: RESET MASTER Remove slave configuration and files: RESET SLAVE www.percona.com 33
  • 34. Diagnostics Commands On Master SHOW MASTER STATUS SHOW PROCESSLIST SHOW SLAVE HOSTS SHOW BINLOG EVENTS On Slave SHOW SLAVE STATUS SHOW PROCESSLIST www.percona.com 34
  • 35. On Master:SHOW MASTER STATUS Current binary log file and position: master> SHOW MASTER STATUSG *************************** 1. row *************************** File: mysql-bin.000008 Position: 254 Binlog_Do_DB: Binlog_Ignore_DB: 1 row in set (0.00 sec) www.percona.com 35
  • 36. On Master: SHOW PROCESSLIST Find Connected Slaves using SHOW PROCESSLIST: master> SHOW PROCESSLISTG ... *************************** 2. row *************************** Id: 4 User: repl Host: localhost:43537 db: NULL Command: Binlog Dump Time: 1264 State: Has sent all binlog to slave; waiting for binlog to be updated Info: NULL ... www.percona.com 36
  • 37. On Master: SHOW SLAVE HOSTS Shows connected slaves with their server-id: master> SHOW SLAVE HOSTS; +-----------+-----------+------+-----------+ | Server_id | Host | Port | Master_id | +-----------+-----------+------+-----------+ | 2 | slave | 3306 | 1 | +-----------+-----------+------+-----------+ 1 row in set (0.00 sec) Only works when slaves have configured: report-host, report-user, report-password, report-port www.percona.com 37
  • 38. On Slave: SHOW PROCESSLIST Slave Thread Status: SLAVE> SHOW PROCESSLISTG *************************** 1. row *************************** Id: 5 User: system user Host: db: NULL Command: Connect Time: 88611 State: Waiting for master to send event Info: NULL *************************** 2. row *************************** Id: 8 User: system user Host: db: NULL Command: Connect Time: 83 State: Has read all relay log; waiting for the slave I/O thread to update it Info: NULL www.percona.com 38
  • 39. MySQL Replication Replication Overview Binary Logs Setting Up Replication Commands Other Common Configuration Settings Replication Architectures Common Issues Replication Use Cases Other Replication Implementations Tools www.percona.com 39
  • 40. Other Common Configuration Options Filtering: binlog-%, replicate-% Don’t start replication at start: skip_slave_start Put relay log events in it’s own binary log: log_slave_updates Disallow writing on slaves: read_only Automatically remove binlogs: expire_logs_days Change binlog format: binlog_format www.percona.com 40
  • 41. Filtering on Master binlog-do-db=..., binlog-ignore-db=... Warning! Different behavior between SBR and RBR: SBR: Log all statements executed if the ‘default database’ (use database) should be binlogged RBR: Log all row changes of the databases that should be binlogged www.percona.com 41
  • 42. Filtering on Slave replicate-do-db= & replicate-ignore-db= Warning! Different behavior between SBR and RBR Similar to binlog-do/ignore-db replicate-do/ignore-table: Filter on table level replicate-wild-do/ignore-table: Use wildcards (%,_) to filter on table level replicate-rewrite-db=db1->db2 www.percona.com 42
  • 43. MySQL Replication Replication Overview Binary Logs Setting Up Replication Commands Other Common Configuration Settings Replication Architectures Common Issues Replication Use Cases Other Replication Implementations Tools www.percona.com 43
  • 44. Replication Architectures Master-Slave Master-Master Multi Tiered Replication Circular Replication www.percona.com 44
  • 45. Master-Slave Master Slave www.percona.com 45
  • 46. Master-Slave Application Master Slave www.percona.com 45
  • 47. Master-Slave Application Master Slave www.percona.com 45
  • 48. Master-Slave Application Writes/Reads Master Slave www.percona.com 45
  • 49. Master-Slave Application Writes/Reads Master Slave www.percona.com 45
  • 50. Master-Slave Application Writes/Reads Master Reads Slave www.percona.com 45
  • 51. Master-Slave Master Slave Slave Slave www.percona.com 46
  • 52. Master-Slave Application Master Slave Slave Slave www.percona.com 46
  • 53. Master-Slave Application Master Slave Slave Slave www.percona.com 46
  • 54. Master-Slave Application Writes/Reads Master Slave Slave Slave www.percona.com 46
  • 55. Master-Slave Application Writes/Reads Master Slave Slave Slave www.percona.com 46
  • 56. Master-Slave Application Writes/Reads Master Reads Slave Slave Slave www.percona.com 46
  • 57. Master-Slave Application Writes/Reads Master Reads Slave Slave Slave www.percona.com 46
  • 58. Master-Slave Application Writes/Reads Master Reads Slave Slave Slave www.percona.com 46
  • 59. Master-Slave Scaling Reads: Slaves can take reads (remember asynchronous!) Reporting/Search queries can go to separate slave Does not take resources on master ‘live-site’-slave. (‘live site’: lower response time requirements than reports) Can have other indexes, even other tables (summary tables,...) Not much benefit when too much writes Maintenance (schema changes...) Upgrade slaves first: Take slave offline SET SQL_LOG_BIN=0; <-don’t put this session queries in ALTER TABLE ...; the binary log SET SQL_LOG_BIN=1; www.percona.com 47
  • 60. Master-Slave: Reporting Queries Master Slave Slave Slave www.percona.com 48
  • 61. Master-Slave: Reporting Queries Application Master Slave Slave Slave www.percona.com 48
  • 62. Master-Slave: Reporting Queries Application Master Slave Slave Slave www.percona.com 48
  • 63. Master-Slave: Reporting Queries Application Writes/Reads Master Slave Slave Slave www.percona.com 48
  • 64. Master-Slave: Reporting Queries Application Writes/Reads Master Reads Slave Slave Slave www.percona.com 48
  • 65. Master-Slave: Reporting Queries Application Writes/Reads Master Reads Slave Slave Slave www.percona.com 48
  • 66. Master-Slave: Reporting Queries Application Writes/Reads Master Reads Slave Slave Slave www.percona.com 48
  • 67. Master-Slave: Reporting Queries Application Writes/Reads Reporting Master Reads Slave Slave Slave www.percona.com 48
  • 68. Master-Slave: Reporting Queries Application Writes/Reads Reporting Master Reads Slave Slave Slave www.percona.com 48
  • 69. Master-Slave: Write Intensive Master Slaves Master Slaves Capacity left for READS Capacity left for READS Capacity taken by WRITES Capacity taken by WRITES www.percona.com 49
  • 70. Master-Master Master Master www.percona.com 50
  • 71. Master-Master Used for: High Availability Maintenance Tasks Write to 1 master, failover to the passive master when necessary Passive master is a real slave, can be used for reads Scale Writes? NO! Every write still has to be performed on both masters Writing to both masters at the same time? NO*! Can cause inconsistencies even with auto_increment_increment/ auto_increment_offset problems can happen www.percona.com 51
  • 72. Master-Master: Reads & Writes Application Writes/Reads Reads Master Master www.percona.com 52
  • 73. Master-Master: Maintenance Application Writes/Reads Master Master www.percona.com 53
  • 74. Master-Master: Maintenance Application Writes/Reads Master Master SET SQL_LOG_BIN=0; ALTER TABLE ...; ... SET SQL_LOG_BIN=1; www.percona.com 53
  • 75. Master-Master: Maintenance Application Writes/Reads Master Master www.percona.com 53
  • 76. Master-Master: Maintenance Application Writes/Reads Master Master SET SQL_LOG_BIN=0; ALTER TABLE ...; ... SET SQL_LOG_BIN=1; www.percona.com 53
  • 77. Master-Master: Write to Both? Inconsistencies Application Master Master +--------+----------------+ +--------+----------------+ | userid | email | | userid | email | +--------+----------------+ +--------+----------------+ | 1 | kg@percona.com | | 1 | kg@percona.com | +--------+----------------+ +--------+----------------+ CREATE TABLE users ( userid INT AUTO_INCREMENT, email VARCHAR(128) NOT NULL, PRIMARY KEY (userid), UNIQUE KEY idx_email (email) ); www.percona.com 54
  • 78. Master-Master: Write to Both? Inconsistencies Application UPDATE users SET email=‘kenny@percona.com’ UPDATE users SET where userid=1; email=‘gryp@percona.com’ where userid=1; Master Master +--------+----------------+ +--------+----------------+ | userid | email | | userid | email | +--------+----------------+ +--------+----------------+ | 1 | kg@percona.com | | 1 | kg@percona.com | +--------+----------------+ +--------+----------------+ CREATE TABLE users ( userid INT AUTO_INCREMENT, email VARCHAR(128) NOT NULL, PRIMARY KEY (userid), UNIQUE KEY idx_email (email) ); www.percona.com 54
  • 79. Master-Master: Write to Both? Inconsistencies Application UPDATE users SET email=‘kenny@percona.com’ UPDATE users SET where userid=1; email=‘gryp@percona.com’ where userid=1; Master Master +--------+------------------+ +--------+-------------------+ | userid | email | | userid | email | +--------+------------------+ +--------+-------------------+ | 1 | gryp@percona.com | | 1 | kenny@percona.com | +--------+------------------+ +--------+-------------------+ CREATE TABLE users ( userid INT AUTO_INCREMENT, email VARCHAR(128) NOT NULL, PRIMARY KEY (userid), UNIQUE KEY idx_email (email) ); www.percona.com 54
  • 80. Master-Master: Write to Both? Inconsistencies Application UPDATE users SET email=‘kenny@percona.com’ where userid=1; Master Master UPDATE users SET email=‘gryp@percona.com’ where userid=1; +--------+------------------+ +--------+-------------------+ | userid | email | | userid | email | +--------+------------------+ +--------+-------------------+ | 1 | gryp@percona.com | | 1 | kenny@percona.com | +--------+------------------+ +--------+-------------------+ CREATE TABLE users ( userid INT AUTO_INCREMENT, email VARCHAR(128) NOT NULL, PRIMARY KEY (userid), UNIQUE KEY idx_email (email) ); www.percona.com 54
  • 81. Master-Master: Write to Both? Inconsistencies Application UPDATE users SET email=‘kenny@percona.com’ where userid=1; Master Master UPDATE users SET email=‘gryp@percona.com’ where userid=1; +--------+-------------------+ +--------+------------------+ | userid | email | | userid | email | +--------+-------------------+ +--------+------------------+ | 1 | kenny@percona.com | | 1 | gryp@percona.com | +--------+-------------------+ +--------+------------------+ CREATE TABLE users ( userid INT AUTO_INCREMENT, email VARCHAR(128) NOT NULL, PRIMARY KEY (userid), UNIQUE KEY idx_email (email) ); www.percona.com 54
  • 82. Master-Master: Write to Both? Replication Breaks Application Master Master +--------+----------------+ +--------+----------------+ | userid | email | | userid | email | +--------+----------------+ +--------+----------------+ | 1 | kg@percona.com | | 1 | kg@percona.com | +--------+----------------+ +--------+----------------+ CREATE TABLE users ( userid INT AUTO_INCREMENT, email VARCHAR(128) NOT NULL, PRIMARY KEY (userid), UNIQUE KEY idx_email (email) ); www.percona.com 55
  • 83. Master-Master: Write to Both? Replication Breaks Application UPDATE USERS SET email=‘legryp@percona.com’ INSERT INTO USERS WHERE userid=1; (email) VALUES (‘legryp@percona.com’) Master Master +--------+----------------+ +--------+----------------+ | userid | email | | userid | email | +--------+----------------+ +--------+----------------+ | 1 | kg@percona.com | | 1 | kg@percona.com | +--------+----------------+ +--------+----------------+ CREATE TABLE users ( userid INT AUTO_INCREMENT, email VARCHAR(128) NOT NULL, PRIMARY KEY (userid), UNIQUE KEY idx_email (email) ); www.percona.com 55
  • 84. Master-Master: Write to Both? Replication Breaks Application UPDATE USERS SET email=‘legryp@percona.com’ INSERT INTO USERS WHERE userid=1; (email) VALUES (‘legryp@percona.com’) Master Master +--------+--------------------+ +--------+--------------------+ | userid | email | | userid | email | +--------+--------------------+ +--------+--------------------+ | 1 | kg@percona.com | | 1 | legryp@percona.com | | 2 | legryp@percona.com | +--------+--------------------+ +--------+--------------------+ CREATE TABLE users ( userid INT AUTO_INCREMENT, email VARCHAR(128) NOT NULL, PRIMARY KEY (userid), UNIQUE KEY idx_email (email) ); www.percona.com 55
  • 85. Master-Master: Write to Both? Replication Breaks Application UPDATE USERS SET email=‘legryp@percona.com’ WHERE userid=1; Master Master INSERT INTO USERS (email) VALUES (‘legryp@percona.com’) +--------+--------------------+ +--------+--------------------+ | userid | email | | userid | email | +--------+--------------------+ +--------+--------------------+ | 1 | kg@percona.com | | 1 | legryp@percona.com | | 2 | legryp@percona.com | +--------+--------------------+ +--------+--------------------+ CREATE TABLE users ( userid INT AUTO_INCREMENT, Error 'Duplicate entry 'legryp@percona.com' email VARCHAR(128) NOT NULL, PRIMARY KEY (userid), for key 'idx_email'' on query. Default UNIQUE KEY idx_email (email) database: 'test'. Query: 'insert into ); users(email) values ('legryp@percona.com')' www.percona.com 55
  • 86. Multi Tiered Replication Master Slave Slave Slave Slave Slave www.percona.com 56
  • 87. Multi Tiered Replication 2 Second query takes 6 seconds to reach the 3rd level Top level slaves could be a master for some dbs/tables too Replication main data (users...) to top level slaves Top level slaves are sort of functionally partitioned www.percona.com 57
  • 88. Multi Tiered Replication: Delay Master Slave Slave Slave Slave Slave www.percona.com 58
  • 89. Multi Tiered Replication: Delay Master 2 Seconds Slave Slave Slave Slave Slave www.percona.com 58
  • 90. Multi Tiered Replication: Delay Master 2 Seconds 2 Seconds Slave Slave Slave Slave Slave www.percona.com 58
  • 91. Multi Tiered Replication: Delay Master 2 Seconds 2 Seconds Slave Slave Slave 2 Seconds Slave Slave www.percona.com 58
  • 92. Multi Tiered Replication: Top Level Slaves MASTER Master MASTER SEARCH LOG Slave Slave Slave SEARCH SEARCH Slave Slave www.percona.com 59
  • 93. Multi Tiered Replication Master Slave Slave Slave Slave Slave No Updates Anymore www.percona.com 60
  • 94. Circular Replication Master Master Master Master www.percona.com 61
  • 95. Circular Replication Master Master Master Master www.percona.com 62
  • 96. Circular Replication Master Master Master Master www.percona.com 63
  • 97. MySQL Replication Replication Overview Binary Logs Setting Up Replication Commands Other Common Configuration Settings Replication Architectures Common Issues Replication Use Cases Other Replication Implementations Tools www.percona.com 64
  • 98. Common Issues Replication Lag Replication Breaking Crash Safe Replication Consistency www.percona.com 65
  • 99. Replication Lag - Causes Single threaded execution on slave!!! Long running queries with SBR: will take ~same time on slave Many row changes with RBR MyISAM & table level locking: Long running SELECT on slave might block replication Schema changes: 20min on master, 20min on slave <-- 20 min replication lag www.percona.com 66
  • 100. Replication Lag - Tips 1 Optimize DML Statements Avoid DDL Statements in Replication (SQL_LOG_BIN=0) Hardware specifications usually need to be equal or better on slave MySQL 5.6: http://d2-systems.blogspot.com/2011/04/mysql-56x-feature-preview-multi.html Ensure BBU&Write Back Cache is used or lower durability: innodb_flush_log_at_trx_commit=2 Change architecture: functional/horizontal partitioning www.percona.com 67
  • 101. Replication Lag - Tips 2 Try to avoid SQL Thread to need to do disk I/O: Replication Booster (Yoshinori Matsunobu) prefetches relay logs and converts queries to select and runs them, causing data to be cached before SQL thread reaches innodb_fake_changes http://www.percona.com/doc/percona-server/5.5/management/ innodb_fake_changes.html http://dom.as/2011/12/03/replication-prefetching/ www.percona.com 68
  • 103. Replication Breaking - Examples Last_Errno: 1146 Last_Error: Error 'Table 'db.table' doesn't exist' on query. Default database: 'userdb'. Query: '...' Last_Errno: 1062 Last_Error: Error 'Duplicate entry '1748099' for key 1' on query. Default database: 'db'. Query: 'INSERT INTO table (url) VALUES(‘http://www.google.com')' Last_Errno: 1053 Last_Error: Query partially completed on the master (error on master: 1053) and was aborted. There is a chance that your master is inconsistent at this point. If you are sure that your master is ok, run this query manually on the slave and then restart the slave with SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; START SLAVE; . Query: ALTER TABLE ‘users’ ADD ‘name’ VARCHAR(128) NULL DEFAULT; www.percona.com 70
  • 104. Replication Breaking - Causes Writes happening on Slaves SBR with bad statements Crashes: Relay Log Corruption Different schemas Temporary tables Mixing MyISAM with InnoDB Different behavior between MySQL versions (minor/major) Killing queries that change MyISAM tables will be partially executed, and break replication ... www.percona.com 71
  • 105. Replication Breaking - Fixing Questions to ask yourself: Why? Where? Impact? Quick ‘fix’: SET GLOBAL SQL_SLAVE_SKIP_COUNTER=1; START SLAVE; Causes 1 event to be skipped Causes inconsistencies!!! Look at: Check error & Investigate data on master/slave MySQL errorlogs SHOW SLAVE STATUSG mysqlbinlog on relaylogs/binarylogs and investigate pt-slave-restart More On: http://www.percona.com/files/presentations/percona-live/london-2011/ PLUK2011-diagnosing-and-fixing-mysql-replication.pdf www.percona.com 72
  • 106. Crash Safe Replication On master: sync_binlog=1 to fsync at every binlog write Performance impact, mainly on: Ext3 filesystem http://www.mysqlperformanceblog.com/2009/01/21/beware-ext3-and-sync-binlog-do-not-play-well-together/ High write-response time disksubsystem (no WriteBackCache& BBU) On slave: relay-log.info/master.info: not durable/consistent! When OS crash, old information might be in the file If InnoDB only: use innodb_overwrite_relay_log_info in Percona Server: http://www.percona.com/doc/percona-server/5.5/reliability/ innodb_recovery_update_relay_log.html www.percona.com 73
  • 107. Consistency Replication can cause inconsistencies: Statement Based Replication Certain functions like UUID()... UPDATE/DELETE with LIMIT without ORDER BY unique key Writing to multiple masters Writing to slaves (by accident? use read_only) Failover done wrong MyISAM with killing queries and/ord MySQL Crashes Wrongly restored slaves Replication broke and used SQL_SLAVE_SKIP_COUNTER ... How to know if my data is consistent? www.percona.com 74
  • 108. Consistency Checking Consistency: pt-table-checksum Checksums chunks of data on master and slaves Monitors replication lag Low checksum response time to lower impact on production Uses Replication to ensure consistent view of data Fixing Consistency: pt-table-sync Can checksum and use pt-table-checksum results Fixes inconsistencies www.percona.com 75
  • 109. MySQL Replication Replication Overview Binary Logs Setting Up Replication Commands Other Common Configuration Settings Replication Architectures Common Issues Replication Use Cases Other Replication Implementations Tools www.percona.com 76
  • 110. Replication Use Cases Scale Reads High Availability Backups www.percona.com 77
  • 111. High Availability Failover: Virtual IPs Change IP in application servers Warning: Split-Brain possible!!! Ensure no writes happen on old master before moving Make sure new master is in sync Scripts available to automate failover: MySQL-MHA http://code.google.com/p/mysql-master-ha/ MMM (not-recommended) http://mysql-mmm.org/ Percona-PRM http://www.mysqlperformanceblog.com/2011/11/29/percona-replication-manager-a- solution-for-mysql-high-availability-with-replication-using-pacemaker/ www.percona.com 78
  • 112. High Availability Due to asynchronous’ness, data might be lost: Semi-Synchronous Replication: ensure at least one slave’s IO thread has received the event before the transaction is committed. http://dev.mysql.com/doc/refman/5.5/en/replication-semisync.html www.percona.com 79
  • 113. Backups Point In Time Recovery, using binary logs Delayed slave Backup Slaves www.percona.com 80
  • 114. Incremental / Point In Time Recovery Restore Full Backup from your favorite backup tool Replay binary logs with mysqldump from the last position of the backup # mysqlbinlog --start-position=15115 1sbinarylog | mysql # mysqlbinlog next-binary-logs | mysql If PITR, stop at the desired position/time: # mysqlbinlog --stop-position=102151 binarylog | mysql # mysqlbinlog --stop-datetime=“2012-01-01 23:00:00” lastbinarylog | mysql www.percona.com 81
  • 115. Delayed Slave Deliberately lag a slave for a predefined amount of time Decrease recovery time in case of bad changes caused by: Humans (DROP DATABASE) Application (DELETE FROM table;) How to configure: pt-slave-delay --delay 60m (http://www.percona.com/doc/percona-toolkit/2.0/pt-slave-delay.html) 5.6 Built-in feature: > CHANGE MASTER TO MASTER_DELAY=3600; When a problem happens stop replication just before the malicious statement. START SLAVE UNTIL MASTER_LOG_FILE='log_name', MASTER_LOG_POS = pos; www.percona.com 82
  • 116. Backup using Slaves Online Backups might not be possible on active master: Too much impact to make online: InnoDB backup (using MySQL enterprise backup or XtraBackup) LVM Snapshots MyISAM tables Offsite Backup www.percona.com 83
  • 117. MySQL Replication Replication Overview Binary Logs Setting Up Replication Commands Other Common Configuration Settings Replication Architectures Common Issues Replication Use Cases Other Replication Implementations Tools www.percona.com 84
  • 118. Other Replication Implementations Tungsten Replicator Uses binary log Parallel replication Enhanced filtering Multi-master Replication between different databases Galera Cluster Does not use binary log Synchronous replication Active-active master Parallel replication Percona XtraDB Cluster! http://www.mysqlperformanceblog.com/2012/01/09/ announcement-of-percona-xtradb-cluster-alpha-release/ www.percona.com 85
  • 121. MySQL Replication Replication Overview Binary Logs Setting Up Replication Commands Other Common Configuration Settings Replication Architectures Common Issues Replication Use Cases Other Replication Implementations Tools www.percona.com 88
  • 122. Tools & More Info Percona Toolkit http://www.percona.com/software/percona-toolkit/ pt-slave-find, pt-table-checksum, pt-table-sync, pt-slave-delay, pt-slave-restart, pt-heartbeat Percona Server http://www.percona.com/software/percona-server/ OpenArk kit http://code.openark.org/forge/openark-kit Replication Booster https://github.com/yoshinorim/replication-booster-for-mysql High Availability MMM http://mysql-mmm.org/ Percona-PRM http://www.mysqlperformanceblog.com/2011/11/29/percona-replication-manager-a- solution-for-mysql-high-availability-with-replication-using-pacemaker/ MySQL-MHA http://code.google.com/p/mysql-master-ha/ High Performance MySQL, 2nd Edition: http://shop.oreilly.com/product/9780596101718.do www.percona.com 89
  • 123. MySQL Replication Replication Overview Binary Logs Setting Up Replication Commands Other Common Configuration Settings Replication Architectures Common Issues Replication Use Cases Other Replication Implementations Tools www.percona.com 90
  • 124. Kenny Gryp <kenny.gryp@percona.com> @gryp We're Hiring! www.percona.com/about-us/careers/