SlideShare ist ein Scribd-Unternehmen logo
1 von 75
Easy MySQL Replication
Setup and Troubleshooting
Bob Burgess
Salesforce ExactTarget Marketing Cloud (Radian6)
• Introduction
• Description
• Configuration Items
• Commands
• Setup
• Beyond the Basics
• Troubleshooting Faults
• Gotchas
• Closing
• Introduction
• Description
• Configuration Items
• Commands
• Setup
• Beyond the Basics
• Troubleshooting Faults
• Gotchas
• Closing
Slides
• I will post these slides on the conference site
and slideshare
• No need to copy them down
Who Am I?
• MySQL user since 2007
• Radian6: Social Media Monitoring
• Now part of
Salesforce ExactTarget Marketing Cloud
• Large Data Set
• Dozens of Databases
• Replication is CRUCIAL for us
Why Am I Doing This?
• Replication isn’t hard
• Show simplest replication case
• Share how we deal with common problems
Our First Replication
• Set up a separate database for running
reports, to separate back-end from user-facing
activity
• Alexander Rubin of MySQL Support in 2008
What is “Replication”?
Why Replication?
• Database Failure
• Share Read Traffic (Scale-Out)
• Reporting/Analytics Databases
• Network Load
• Backups
Replication Compared
• DRBD
– Block-level
– Replica is unusable until switched to
• Galera / Percona Cluster
– More complicated
– Not WAN-Friendly for High Transaction Rate
• Tungsten Replicator
• Others..?
• Introduction
• Description
• Configuration Items
• Commands
• Setup
• Beyond the Basics
• Troubleshooting Faults
• Gotchas
• Closing
Replication Described
Master Replica
Replication Described
Master
table1
table2
mysql
Update table1 set...
Insert into table2...
Binlogs:
• Events in commit order
• Contains timestamps and auto-increment IDs
client
Replica
table1
table2
IO Thread SQL Thread
Update table1 set...
Insert into table2...
mysql
• Introduction
• Description
• Configuration Items
• Commands
• Setup
• Beyond the Basics
• Troubleshooting Faults
• Gotchas
• Closing
Replication Described
log_bin=/data/log/mysql-bin
Config items
Master
table1
table2
mysql
Update table1 set...
Insert into table2...
client
Replica
table1
table2
IO Thread SQL Thread
Update table1 set...
Insert into table2...
mysql
Replication Described
server_id=1 server_id=2
Config items
(1) Master
table1
table2
mysql
Update table1 set...
Insert into table2...
client
Replica (2)
table1
table2
IO Thread SQL Thread
Update table1 set...
Insert into table2...
mysql
• Introduction
• Description
• Configuration Items
• Commands
• Setup
• Beyond the Basics
• Troubleshooting Faults
• Gotchas
• Closing
Replication Commands
• change master to
• start slave
• stop slave
• reset slave
• show slave statusG
• show master status
• mysqlbinlog
• grant replication slave
Replication Commands
change master to...
Which server? Port? Credentials? Log file & position?
(1) Master
table1
table2
mysql
client
Replica (2)
table1
table2
IO Thread SQL Thread
Update table1 set...
Insert into table2...
mysql
Update table1 set...
Insert into table2...
Replication Commands
• change master to...
Which server? Port? Credentials? Log file & position?
• change master to
master_host=‘Master’, master_port=3306,
master_user=‘repl’, master_password=‘pass’,
master_log_file=‘mysql_bin.000001’,
master_log_pos=4563744;
Replication Commands
(1) Master
table1
table2
mysql
Update table1 set...
Insert into table2...
client
Replica (2)
table1
table2
mysql
Replication Commands
change master to
master_host=‘Master’, master_port=3306,
master_user=‘repl’, master_password=‘pass’,
master_log_file=‘mysql_bin.000001’,
master_log_pos=4563744;
(1) Master
table1
table2
mysql
Update table1 set...
Insert into table2...
client
Replica (2)
table1
table2
IO Thread
Update table1 set...
Insert into table2...
mysql
Replication Commands
start slave;
(1) Master
table1
table2
mysql
Update table1 set...
Insert into table2...
client
Replica (2)
table1
table2
IO Thread SQL Thread
Update table1 set...
Insert into table2...
mysql
Replication Commands
stop slave;
(1) Master
table1
table2
mysql
Update table1 set...
Insert into table2...
client
Replica (2)
table1
table2
Update table1 set...
Insert into table2...
mysql
Replication Commands
reset slave;
(1) Master
table1
table2
mysql
Update table1 set...
Insert into table2...
client
Replica (2)
table1
table2
mysql
Replication Commands
• show slave statusG
• Manual troubleshooting
• Use in scripts for alarming
LAG=$(mysql -s -e’show slave statusG’|grep
‘Seconds_Behind_Master’|cut -f2 -d:| tr -d ‘ ‘)
IO_UP=$(mysql -s -e’show slave statusG’|grep
‘Slave_IO_Running’|cut -f2 -d:| tr -d ‘ ‘)
Slave_IO_State: Waiting for
master to send
event
Master_Host: Master
Master_User: repl
Master_Port: 3306
Connect_Retry: 3
Master_Log_File: mysql-bin.000001
Read_Master_Log_Pos: 28762843
Relay_Log_File: relay-bin.000002
Relay_Log_Pos: 548
Relay_Master_Log_File: mysql-bin.000001
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
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: 23456234
Relay_Log_Space: 52
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: 8
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids: 0
Master_Server_Id: 1
Slave_IO_State: Waiting for
master to
send event
Master_Host: Master
Master_User: repl
Master_Port: 3306
Connect_Retry: 3
Master_Log_File: mysql-bin.000001
Read_Master_Log_Pos: 28762843
Relay_Log_File: relay-bin.000002
Relay_Log_Pos: 548
Relay_Master_Log_File: mysql-bin.000001
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
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: 23456234
Relay_Log_Space: 52
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: 8
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids: 0
Master_Server_Id: 1
What it’s doing
Slave_IO_State: Waiting for
master to send
event
Master_Host: Master
Master_User: repl
Master_Port: 3306
Connect_Retry: 3
Master_Log_File: mysql-bin.000001
Read_Master_Log_Pos: 28762843
Relay_Log_File: relay-bin.000002
Relay_Log_Pos: 548
Relay_Master_Log_File: mysql-bin.000001
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
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: 23456234
Relay_Log_Space: 52
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: 8
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids: 0
Master_Server_Id: 1
Where it’s connected
Slave_IO_State: Waiting for
master to send
event
Master_Host: Master
Master_User: repl
Master_Port: 3306
Connect_Retry: 3
Master_Log_File: mysql-bin.000001
Read_Master_Log_Pos: 28762843
Relay_Log_File: relay-bin.000002
Relay_Log_Pos: 548
Relay_Master_Log_File: mysql-bin.000001
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
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: 23456234
Relay_Log_Space: 52
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: 8
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids: 0
Master_Server_Id: 1
Where the IO Thread has read up to
Master
table1
table2
mysql
Update table1 set...
Insert into table2...
client
Replica
table1
table2
IO Thread SQL Thread
Update table1 set...
Insert into table2...
mysql
Master_Log_File: mysql-bin.000001
Read_Master_Log_Pos: 28762843
Slave_IO_State: Waiting for
master to send
event
Master_Host: Master
Master_User: repl
Master_Port: 3306
Connect_Retry: 3
Master_Log_File: mysql-bin.000001
Read_Master_Log_Pos: 28762843
Relay_Log_File: relay-bin.000002
Relay_Log_Pos: 548
Relay_Master_Log_File: mysql-bin.000001
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
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: 23456234
Relay_Log_Space: 52
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: 8
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids: 0
Master_Server_Id: 1
Where the SQL Thread has executed up to
(in relaylog)
Master
table1
table2
mysql
Update table1 set...
Insert into table2...
client
Replica
table1
table2
IO Thread SQL Thread
Update table1 set...
Insert into table2...
mysql
Relay_Log_File: relay-bin.000002
Relay_Log_Pos: 548
Slave_IO_State: Waiting for
master to send
event
Master_Host: Master
Master_User: repl
Master_Port: 3306
Connect_Retry: 3
Master_Log_File: mysql-bin.000001
Read_Master_Log_Pos: 28762843
Relay_Log_File: relay-bin.000002
Relay_Log_Pos: 548
Relay_Master_Log_File:
mysql-bin.000001
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
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:
23456234
Relay_Log_Space: 52
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: 8
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids: 0
Master_Server_Id: 1
Where the SQL Thread has executed up to
(corresponding position in Master’s binlog)
Master
table1
table2
mysql
Update table1 set...
Insert into table2...
client
Replica
table1
table2
IO Thread SQL Thread
Update table1 set...
Insert into table2...
mysql
Relay_Master_Log_File: mysql-bin.000001
Exec_Master_Log_Pos: 23456234
Slave_IO_State: Waiting for
master to send
event
Master_Host: Master
Master_User: repl
Master_Port: 3306
Connect_Retry: 3
Master_Log_File: mysql-bin.000001
Read_Master_Log_Pos: 28762843
Relay_Log_File: relay-bin.000002
Relay_Log_Pos: 548
Relay_Master_Log_File: mysql-bin.000001
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
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: 23456234
Relay_Log_Space: 52
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: 8
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids: 0
Master_Server_Id: 1
If the IO and SQL Threads are running
Slave_IO_State: Waiting for
master to send
event
Master_Host: Master
Master_User: repl
Master_Port: 3306
Connect_Retry: 3
Master_Log_File: mysql-bin.000001
Read_Master_Log_Pos: 28762843
Relay_Log_File: relay-bin.000002
Relay_Log_Pos: 548
Relay_Master_Log_File: mysql-bin.000001
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
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: 23456234
Relay_Log_Space: 52
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: 8
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids: 0
Master_Server_Id: 1
Replication Filters in effect
Slave_IO_State: Waiting for
master to send
event
Master_Host: Master
Master_User: repl
Master_Port: 3306
Connect_Retry: 3
Master_Log_File: mysql-bin.000001
Read_Master_Log_Pos: 28762843
Relay_Log_File: relay-bin.000002
Relay_Log_Pos: 548
Relay_Master_Log_File: mysql-bin.000001
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
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: 23456234
Relay_Log_Space: 52
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: 8
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids: 0
Master_Server_Id: 1
Replication Lag (how long ago was
timestamp of latest-processed query?)
Can be “NULL”
Slave_IO_State: Waiting for
master to send
event
Master_Host: Master
Master_User: repl
Master_Port: 3306
Connect_Retry: 3
Master_Log_File: mysql-bin.000001
Read_Master_Log_Pos: 28762843
Relay_Log_File: relay-bin.000002
Relay_Log_Pos: 548
Relay_Master_Log_File: mysql-bin.000001
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
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: 23456234
Relay_Log_Space: 52
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: 8
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids: 0
Master_Server_Id: 1
Replication Error (SQL Thread)
Slave_IO_State: Waiting for
master to send
event
Master_Host: Master
Master_User: repl
Master_Port: 3306
Connect_Retry: 3
Master_Log_File: mysql-bin.000001
Read_Master_Log_Pos: 28762843
Relay_Log_File: relay-bin.000002
Relay_Log_Pos: 548
Relay_Master_Log_File: mysql-bin.000001
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
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: 23456234
Relay_Log_Space: 52
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: 8
Master_SSL_Verify_Server_Cert: No
Last_IO_Errno: 0
Last_IO_Error:
Last_SQL_Errno: 0
Last_SQL_Error:
Replicate_Ignore_Server_Ids: 0
Master_Server_Id: 1
Replication Error (IO Thread)
• Introduction
• Description
• Configuration Items
• Commands
• Setup
• Beyond the Basics
• Troubleshooting Faults
• Gotchas
• Closing
Basic Setup Walk-Through
• Unique server_id values
my.cnf on master
[mysqld]
server_id=1
my.cnf on replica
[mysqld]
server_id=2
Basic Setup Walk-Through
• Replication User
On Master:
grant replication slave on *.* to ‘repl’
identified by ‘pass’;
Basic Setup Walk-Through
• Point to the correct binlog position
• On master:
show master status;
...once both databases are equal
• On Replica:
change master to ...
Basic Setup Walk-Through
• Start it up
• On replica:
start slave;
• Check it
• On replica:
show slave statusG
And that’s it.
• Introduction
• Description
• Configuration Items
• Commands
• Setup
• Beyond the Basics
• Troubleshooting Faults
• Gotchas
• Closing
Limiting Tables or Schemas
• If you don’t need all the tables
• In my.cnf:
replicate-do-table=schema.tableName
replicate-skip-table=schema.otherTable
• If you don’t need all the schemas
• In my.cnf
replication-do-db=schemaOne
replication_skip_db=schemaTwo
Limiting Tables
replicate-do-table=schema.tableName
(1) Master
table1
table2
mysql
Update table1 set...
Insert into table2...
client
Replica (2)
table1
table2
IO Thread SQL Thread
with filter
Update table1 set...
Insert into table2...
mysql
Limiting Columns or Rows
• If you don’t need all columns
• Subset of table for reporting or analytics
Limiting Columns or Rows
• Original table
create table x (a int primary key,
b int, c int) engine=InnoDB;
• Blackhole table on replica like master table
create table x (a int, b int, c int)
engine=blackhole;
• Target table on replica
create table y (a int primary key,
b int) engine=InnoDB;
Limiting Columns or Rows
• Before-insert trigger on replica to put data into
second “real” table
• Only columns a and b, and only for b=1
create trigger x_bi before insert on x
for each row
insert into y (a, b)
select new.a, new.b
from dual
where new.b=1;
Limiting Columns or Rows
(1) Master
table1
table2
mysql
Update table1 set...
Insert into table2...
client
Replica (2)
x y
IO Thread SQL Thread
Update table1 set...
Insert into table2...
mysql
TRG
Multi-Level
• Local and Remote DR Site
• Spreading load over many servers
M R M R
M R
R
R
R
R
R
R
R
...
Multi-Level
• Config
log_slave_updates=1
Multi-Level
Master Replica
table1
table2
table1
table2
mysql IO Thread SQL Thread
Update table1 set...
Insert into table2...
Update table1 set...
Insert into table2...
Replica
table1
table2
IO Thread SQL Thread
Update table1 set...
Insert into table2...
Update table1 set...
Insert into table2...
mysql
Types of Binlogs
• Statement-Based
– Contains the actual statements run
– Data drift is more likely (code modified by
triggers, etc)
• Row-based
– Replicates changes for each row
– Mostly unreadable by humans
– Unaffected by how the change is done (data drift less
likely)
– mysqlbinlog -v
• Introduction
• Description
• Configuration Items
• Commands
• Setup
• Beyond the Basics
• Troubleshooting Faults
• Gotchas
• Closing
Fault: Lag
• Long-running transactions
• High concurrency on master becomes single
session on replica
• show slave statusG
• Easy to alarm on
Fault: Stopping from Error
• Any error stops SQL Thread!
• Duplicate Key
• Unknown Function
• slave_exec_mode=idempotent
...suppresses duplicate-key and no-key-found
errors
• show slave statusG
Faults: Can’t Connect to Master
• Fault shows in slave status as soon as you
start slave.
• Did you create replication slave user?
• Correct user/password?
• Correct hostname/port?
• Master is running and reachable?
Fault: Can’t Find Binlog
• Clearly stated in the slave status
• Can happen if replica has been stopped (or is
lagged) and the binlogs are removed from the
master
• Execute from archive
OR
• Rebuild replica and restart from a known good
binlog position
Faults: Configuration
• replication-do-table
• replication-do-schema
• log_slave_updates
Faults: server_id
• Must be unique!
• If equal: “Seconds behind” jumps everywhere.
• Introduction
• Description
• Configuration Items
• Commands
• Setup
• Beyond the Basics
• Troubleshooting Faults
• Gotchas
• Closing
Gotcha: functions
• Functions will be run on the replica even if
only appearing in a select on the master
• Make sure all functions exist on replica
DB, even if only a dummy version
create function myFtn (a int, b int)
returns int deterministic return 0;
Gotcha: Reconnection
• When a replica is stopped and reset, until the
database is restarted, replication may
reconnect to a master after “reset slave”
change master to master_port=1234;
Gotcha: Master Crash
• Replication becomes unstable if master crashes
• Error: unknown instruction at position xxx
• Often need to use mysqlbinlog to find a
suitable position in the binlog to restart
replication from
stop slave; reset slave;
change master to ...;
start slave;
Gotcha: MySQL Versions
• Replication not completely compatible
between versions (especially later=>earlier)
• 5.5 master to 5.1 replica: character set error
“sometimes”
• Stops replication
Impossible
• One replica can have only one master
(until 5.7)
• Can’t change table or schema filters
dynamically
• Can’t put binlogs back on master server, for
recovery purposes
• Introduction
• Description
• Configuration Items
• Commands
• Setup
• Beyond the Basics
• Troubleshooting Faults
• Gotchas
• Closing
The Book
Alternatives
• Tungsten Replicator from Continuent
• Others?
Questions?
Thank you!
Bob Burgess
rburgess@salesforce.com
Don’t forget your session evaluation!

Weitere ähnliche Inhalte

Was ist angesagt?

9 DevOps Tips for Going in Production with Galera Cluster for MySQL - Slides
9 DevOps Tips for Going in Production with Galera Cluster for MySQL - Slides9 DevOps Tips for Going in Production with Galera Cluster for MySQL - Slides
9 DevOps Tips for Going in Production with Galera Cluster for MySQL - SlidesSeveralnines
 
Codership's galera cluster installation and quickstart webinar march 2016
Codership's galera cluster installation and quickstart webinar march 2016Codership's galera cluster installation and quickstart webinar march 2016
Codership's galera cluster installation and quickstart webinar march 2016Sakari Keskitalo
 
Galera explained 3
Galera explained 3Galera explained 3
Galera explained 3Marco Tusa
 
MariaDB Galera Cluster - Simple, Transparent, Highly Available
MariaDB Galera Cluster - Simple, Transparent, Highly AvailableMariaDB Galera Cluster - Simple, Transparent, Highly Available
MariaDB Galera Cluster - Simple, Transparent, Highly AvailableMariaDB Corporation
 
Webinar Slides: Migrating to Galera Cluster
Webinar Slides: Migrating to Galera ClusterWebinar Slides: Migrating to Galera Cluster
Webinar Slides: Migrating to Galera ClusterSeveralnines
 
Consistency between Engine and Binlog under Reduced Durability
Consistency between Engine and Binlog under Reduced DurabilityConsistency between Engine and Binlog under Reduced Durability
Consistency between Engine and Binlog under Reduced DurabilityYoshinori Matsunobu
 
Repair & Recovery for your MySQL, MariaDB & MongoDB / TokuMX Clusters - Webin...
Repair & Recovery for your MySQL, MariaDB & MongoDB / TokuMX Clusters - Webin...Repair & Recovery for your MySQL, MariaDB & MongoDB / TokuMX Clusters - Webin...
Repair & Recovery for your MySQL, MariaDB & MongoDB / TokuMX Clusters - Webin...Severalnines
 
Scaling with sync_replication using Galera and EC2
Scaling with sync_replication using Galera and EC2Scaling with sync_replication using Galera and EC2
Scaling with sync_replication using Galera and EC2Marco Tusa
 
Best practices for MySQL High Availability
Best practices for MySQL High AvailabilityBest practices for MySQL High Availability
Best practices for MySQL High AvailabilityColin Charles
 
Advanced Percona XtraDB Cluster in a nutshell... la suite
Advanced Percona XtraDB Cluster in a nutshell... la suiteAdvanced Percona XtraDB Cluster in a nutshell... la suite
Advanced Percona XtraDB Cluster in a nutshell... la suiteKenny Gryp
 
Introduction to Galera
Introduction to GaleraIntroduction to Galera
Introduction to GaleraHenrik Ingo
 
Galera 3.0 Webinar Slides: Galera Monitoring & Management
Galera 3.0 Webinar Slides: Galera Monitoring & ManagementGalera 3.0 Webinar Slides: Galera Monitoring & Management
Galera 3.0 Webinar Slides: Galera Monitoring & ManagementSeveralnines
 
Performance Tuning Best Practices
Performance Tuning Best PracticesPerformance Tuning Best Practices
Performance Tuning Best Practiceswebhostingguy
 
A26 MariaDB : The New&Implemented MySQL Branch by Colin Charles
A26 MariaDB : The New&Implemented MySQL Branch by Colin CharlesA26 MariaDB : The New&Implemented MySQL Branch by Colin Charles
A26 MariaDB : The New&Implemented MySQL Branch by Colin CharlesInsight Technology, Inc.
 
MariaDB 5.5 and what comes next - Percona Live NYC 2012
MariaDB 5.5 and what comes next - Percona Live NYC 2012MariaDB 5.5 and what comes next - Percona Live NYC 2012
MariaDB 5.5 and what comes next - Percona Live NYC 2012Colin Charles
 

Was ist angesagt? (20)

9 DevOps Tips for Going in Production with Galera Cluster for MySQL - Slides
9 DevOps Tips for Going in Production with Galera Cluster for MySQL - Slides9 DevOps Tips for Going in Production with Galera Cluster for MySQL - Slides
9 DevOps Tips for Going in Production with Galera Cluster for MySQL - Slides
 
Introducing Galera 3.0
Introducing Galera 3.0Introducing Galera 3.0
Introducing Galera 3.0
 
Codership's galera cluster installation and quickstart webinar march 2016
Codership's galera cluster installation and quickstart webinar march 2016Codership's galera cluster installation and quickstart webinar march 2016
Codership's galera cluster installation and quickstart webinar march 2016
 
Galera webinar migration to galera cluster from my sql async replication
Galera webinar migration to galera cluster from my sql async replicationGalera webinar migration to galera cluster from my sql async replication
Galera webinar migration to galera cluster from my sql async replication
 
Galera explained 3
Galera explained 3Galera explained 3
Galera explained 3
 
MariaDB Galera Cluster - Simple, Transparent, Highly Available
MariaDB Galera Cluster - Simple, Transparent, Highly AvailableMariaDB Galera Cluster - Simple, Transparent, Highly Available
MariaDB Galera Cluster - Simple, Transparent, Highly Available
 
How to understand Galera Cluster - 2013
How to understand Galera Cluster - 2013How to understand Galera Cluster - 2013
How to understand Galera Cluster - 2013
 
Webinar Slides: Migrating to Galera Cluster
Webinar Slides: Migrating to Galera ClusterWebinar Slides: Migrating to Galera Cluster
Webinar Slides: Migrating to Galera Cluster
 
Taking Full Advantage of Galera Multi Master Cluster
Taking Full Advantage of Galera Multi Master ClusterTaking Full Advantage of Galera Multi Master Cluster
Taking Full Advantage of Galera Multi Master Cluster
 
Consistency between Engine and Binlog under Reduced Durability
Consistency between Engine and Binlog under Reduced DurabilityConsistency between Engine and Binlog under Reduced Durability
Consistency between Engine and Binlog under Reduced Durability
 
Repair & Recovery for your MySQL, MariaDB & MongoDB / TokuMX Clusters - Webin...
Repair & Recovery for your MySQL, MariaDB & MongoDB / TokuMX Clusters - Webin...Repair & Recovery for your MySQL, MariaDB & MongoDB / TokuMX Clusters - Webin...
Repair & Recovery for your MySQL, MariaDB & MongoDB / TokuMX Clusters - Webin...
 
Scaling with sync_replication using Galera and EC2
Scaling with sync_replication using Galera and EC2Scaling with sync_replication using Galera and EC2
Scaling with sync_replication using Galera and EC2
 
Best practices for MySQL High Availability
Best practices for MySQL High AvailabilityBest practices for MySQL High Availability
Best practices for MySQL High Availability
 
Advanced Percona XtraDB Cluster in a nutshell... la suite
Advanced Percona XtraDB Cluster in a nutshell... la suiteAdvanced Percona XtraDB Cluster in a nutshell... la suite
Advanced Percona XtraDB Cluster in a nutshell... la suite
 
Introduction to Galera
Introduction to GaleraIntroduction to Galera
Introduction to Galera
 
Galera 3.0 Webinar Slides: Galera Monitoring & Management
Galera 3.0 Webinar Slides: Galera Monitoring & ManagementGalera 3.0 Webinar Slides: Galera Monitoring & Management
Galera 3.0 Webinar Slides: Galera Monitoring & Management
 
Galera Cluster 3.0 Features
Galera Cluster 3.0 FeaturesGalera Cluster 3.0 Features
Galera Cluster 3.0 Features
 
Performance Tuning Best Practices
Performance Tuning Best PracticesPerformance Tuning Best Practices
Performance Tuning Best Practices
 
A26 MariaDB : The New&Implemented MySQL Branch by Colin Charles
A26 MariaDB : The New&Implemented MySQL Branch by Colin CharlesA26 MariaDB : The New&Implemented MySQL Branch by Colin Charles
A26 MariaDB : The New&Implemented MySQL Branch by Colin Charles
 
MariaDB 5.5 and what comes next - Percona Live NYC 2012
MariaDB 5.5 and what comes next - Percona Live NYC 2012MariaDB 5.5 and what comes next - Percona Live NYC 2012
MariaDB 5.5 and what comes next - Percona Live NYC 2012
 

Ähnlich wie Easy MySQL Replication Setup and Troubleshooting

MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)Aurimas Mikalauskas
 
My sql 56_roadmap_april2012
My sql 56_roadmap_april2012My sql 56_roadmap_april2012
My sql 56_roadmap_april2012sqlhjalp
 
Replication features, technologies and 3rd party Extinction
Replication features, technologies and 3rd party ExtinctionReplication features, technologies and 3rd party Extinction
Replication features, technologies and 3rd party ExtinctionBen Mildren
 
MySQL Replication Update -- Zendcon 2016
MySQL Replication Update -- Zendcon 2016MySQL Replication Update -- Zendcon 2016
MySQL Replication Update -- Zendcon 2016Dave Stokes
 
MySQL Utilities -- Cool Tools For You: PHP World Nov 16 2016
MySQL Utilities -- Cool Tools For You: PHP World Nov 16 2016MySQL Utilities -- Cool Tools For You: PHP World Nov 16 2016
MySQL Utilities -- Cool Tools For You: PHP World Nov 16 2016Dave Stokes
 
Loadays MySQL
Loadays MySQLLoadays MySQL
Loadays MySQLlefredbe
 
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
 
MySQL replication best practices 105-232-931
MySQL replication best practices 105-232-931MySQL replication best practices 105-232-931
MySQL replication best practices 105-232-931Baruch Osoveskiy
 
MySQL 101 PHPTek 2017
MySQL 101 PHPTek 2017MySQL 101 PHPTek 2017
MySQL 101 PHPTek 2017Dave Stokes
 
Mysql replication @ gnugroup
Mysql replication @ gnugroupMysql replication @ gnugroup
Mysql replication @ gnugroupJayant Chutke
 
[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.
 
Spil Games @ FOSDEM: Galera Replicator IRL
Spil Games @ FOSDEM: Galera Replicator IRLSpil Games @ FOSDEM: Galera Replicator IRL
Spil Games @ FOSDEM: Galera Replicator IRLspil-engineering
 
Percona Live '18 Tutorial: The Accidental DBA
Percona Live '18 Tutorial: The Accidental DBAPercona Live '18 Tutorial: The Accidental DBA
Percona Live '18 Tutorial: The Accidental DBAJenni Snyder
 
Buytaert kris my_sql-pacemaker
Buytaert kris my_sql-pacemakerBuytaert kris my_sql-pacemaker
Buytaert kris my_sql-pacemakerkuchinskaya
 
2012 replication
2012 replication2012 replication
2012 replicationsqlhjalp
 
Mysql 57-upcoming-changes
Mysql 57-upcoming-changesMysql 57-upcoming-changes
Mysql 57-upcoming-changesMorgan Tocker
 
MySQL Replication Evolution -- Confoo Montreal 2017
MySQL Replication Evolution -- Confoo Montreal 2017MySQL Replication Evolution -- Confoo Montreal 2017
MySQL Replication Evolution -- Confoo Montreal 2017Dave Stokes
 
2012 scale replication
2012 scale replication2012 scale replication
2012 scale replicationsqlhjalp
 

Ähnlich wie Easy MySQL Replication Setup and Troubleshooting (20)

MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
MySQL Performance Tuning. Part 1: MySQL Configuration (includes MySQL 5.7)
 
My sql 56_roadmap_april2012
My sql 56_roadmap_april2012My sql 56_roadmap_april2012
My sql 56_roadmap_april2012
 
Replication features, technologies and 3rd party Extinction
Replication features, technologies and 3rd party ExtinctionReplication features, technologies and 3rd party Extinction
Replication features, technologies and 3rd party Extinction
 
MySQL Replication Update -- Zendcon 2016
MySQL Replication Update -- Zendcon 2016MySQL Replication Update -- Zendcon 2016
MySQL Replication Update -- Zendcon 2016
 
MySQL Utilities -- Cool Tools For You: PHP World Nov 16 2016
MySQL Utilities -- Cool Tools For You: PHP World Nov 16 2016MySQL Utilities -- Cool Tools For You: PHP World Nov 16 2016
MySQL Utilities -- Cool Tools For You: PHP World Nov 16 2016
 
Loadays MySQL
Loadays MySQLLoadays MySQL
Loadays MySQL
 
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
 
MySQL highav Availability
MySQL highav AvailabilityMySQL highav Availability
MySQL highav Availability
 
MySQL replication best practices 105-232-931
MySQL replication best practices 105-232-931MySQL replication best practices 105-232-931
MySQL replication best practices 105-232-931
 
MySQL 101 PHPTek 2017
MySQL 101 PHPTek 2017MySQL 101 PHPTek 2017
MySQL 101 PHPTek 2017
 
Mysql replication @ gnugroup
Mysql replication @ gnugroupMysql replication @ gnugroup
Mysql replication @ gnugroup
 
[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 ...
 
Spil Games @ FOSDEM: Galera Replicator IRL
Spil Games @ FOSDEM: Galera Replicator IRLSpil Games @ FOSDEM: Galera Replicator IRL
Spil Games @ FOSDEM: Galera Replicator IRL
 
Percona Live '18 Tutorial: The Accidental DBA
Percona Live '18 Tutorial: The Accidental DBAPercona Live '18 Tutorial: The Accidental DBA
Percona Live '18 Tutorial: The Accidental DBA
 
Buytaert kris my_sql-pacemaker
Buytaert kris my_sql-pacemakerBuytaert kris my_sql-pacemaker
Buytaert kris my_sql-pacemaker
 
DBCC - Dubi Lebel
DBCC - Dubi LebelDBCC - Dubi Lebel
DBCC - Dubi Lebel
 
2012 replication
2012 replication2012 replication
2012 replication
 
Mysql 57-upcoming-changes
Mysql 57-upcoming-changesMysql 57-upcoming-changes
Mysql 57-upcoming-changes
 
MySQL Replication Evolution -- Confoo Montreal 2017
MySQL Replication Evolution -- Confoo Montreal 2017MySQL Replication Evolution -- Confoo Montreal 2017
MySQL Replication Evolution -- Confoo Montreal 2017
 
2012 scale replication
2012 scale replication2012 scale replication
2012 scale replication
 

Kürzlich hochgeladen

How we prevented account sharing with MFA
How we prevented account sharing with MFAHow we prevented account sharing with MFA
How we prevented account sharing with MFAAndrei Kaleshka
 
Heart Disease Classification Report: A Data Analysis Project
Heart Disease Classification Report: A Data Analysis ProjectHeart Disease Classification Report: A Data Analysis Project
Heart Disease Classification Report: A Data Analysis ProjectBoston Institute of Analytics
 
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改yuu sss
 
Identifying Appropriate Test Statistics Involving Population Mean
Identifying Appropriate Test Statistics Involving Population MeanIdentifying Appropriate Test Statistics Involving Population Mean
Identifying Appropriate Test Statistics Involving Population MeanMYRABACSAFRA2
 
办理(UWIC毕业证书)英国卡迪夫城市大学毕业证成绩单原版一比一
办理(UWIC毕业证书)英国卡迪夫城市大学毕业证成绩单原版一比一办理(UWIC毕业证书)英国卡迪夫城市大学毕业证成绩单原版一比一
办理(UWIC毕业证书)英国卡迪夫城市大学毕业证成绩单原版一比一F La
 
Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...
Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...
Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...Boston Institute of Analytics
 
Business Analytics using Microsoft Excel
Business Analytics using Microsoft ExcelBusiness Analytics using Microsoft Excel
Business Analytics using Microsoft Excelysmaelreyes
 
INTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTDINTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTDRafezzaman
 
Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...
Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...
Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...ssuserf63bd7
 
ASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel CanterASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel Cantervoginip
 
Conf42-LLM_Adding Generative AI to Real-Time Streaming Pipelines
Conf42-LLM_Adding Generative AI to Real-Time Streaming PipelinesConf42-LLM_Adding Generative AI to Real-Time Streaming Pipelines
Conf42-LLM_Adding Generative AI to Real-Time Streaming PipelinesTimothy Spann
 
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝DelhiRS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhijennyeacort
 
Student Profile Sample report on improving academic performance by uniting gr...
Student Profile Sample report on improving academic performance by uniting gr...Student Profile Sample report on improving academic performance by uniting gr...
Student Profile Sample report on improving academic performance by uniting gr...Seán Kennedy
 
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一F La
 
modul pembelajaran robotic Workshop _ by Slidesgo.pptx
modul pembelajaran robotic Workshop _ by Slidesgo.pptxmodul pembelajaran robotic Workshop _ by Slidesgo.pptx
modul pembelajaran robotic Workshop _ by Slidesgo.pptxaleedritatuxx
 
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degreeyuu sss
 
Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 2Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 217djon017
 
Real-Time AI Streaming - AI Max Princeton
Real-Time AI  Streaming - AI Max PrincetonReal-Time AI  Streaming - AI Max Princeton
Real-Time AI Streaming - AI Max PrincetonTimothy Spann
 
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一F sss
 
NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...
NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...
NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...Boston Institute of Analytics
 

Kürzlich hochgeladen (20)

How we prevented account sharing with MFA
How we prevented account sharing with MFAHow we prevented account sharing with MFA
How we prevented account sharing with MFA
 
Heart Disease Classification Report: A Data Analysis Project
Heart Disease Classification Report: A Data Analysis ProjectHeart Disease Classification Report: A Data Analysis Project
Heart Disease Classification Report: A Data Analysis Project
 
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
专业一比一美国俄亥俄大学毕业证成绩单pdf电子版制作修改
 
Identifying Appropriate Test Statistics Involving Population Mean
Identifying Appropriate Test Statistics Involving Population MeanIdentifying Appropriate Test Statistics Involving Population Mean
Identifying Appropriate Test Statistics Involving Population Mean
 
办理(UWIC毕业证书)英国卡迪夫城市大学毕业证成绩单原版一比一
办理(UWIC毕业证书)英国卡迪夫城市大学毕业证成绩单原版一比一办理(UWIC毕业证书)英国卡迪夫城市大学毕业证成绩单原版一比一
办理(UWIC毕业证书)英国卡迪夫城市大学毕业证成绩单原版一比一
 
Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...
Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...
Data Analysis Project : Targeting the Right Customers, Presentation on Bank M...
 
Business Analytics using Microsoft Excel
Business Analytics using Microsoft ExcelBusiness Analytics using Microsoft Excel
Business Analytics using Microsoft Excel
 
INTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTDINTERNSHIP ON PURBASHA COMPOSITE TEX LTD
INTERNSHIP ON PURBASHA COMPOSITE TEX LTD
 
Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...
Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...
Statistics, Data Analysis, and Decision Modeling, 5th edition by James R. Eva...
 
ASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel CanterASML's Taxonomy Adventure by Daniel Canter
ASML's Taxonomy Adventure by Daniel Canter
 
Conf42-LLM_Adding Generative AI to Real-Time Streaming Pipelines
Conf42-LLM_Adding Generative AI to Real-Time Streaming PipelinesConf42-LLM_Adding Generative AI to Real-Time Streaming Pipelines
Conf42-LLM_Adding Generative AI to Real-Time Streaming Pipelines
 
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝DelhiRS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
RS 9000 Call In girls Dwarka Mor (DELHI)⇛9711147426🔝Delhi
 
Student Profile Sample report on improving academic performance by uniting gr...
Student Profile Sample report on improving academic performance by uniting gr...Student Profile Sample report on improving academic performance by uniting gr...
Student Profile Sample report on improving academic performance by uniting gr...
 
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
办理(Vancouver毕业证书)加拿大温哥华岛大学毕业证成绩单原版一比一
 
modul pembelajaran robotic Workshop _ by Slidesgo.pptx
modul pembelajaran robotic Workshop _ by Slidesgo.pptxmodul pembelajaran robotic Workshop _ by Slidesgo.pptx
modul pembelajaran robotic Workshop _ by Slidesgo.pptx
 
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
毕业文凭制作#回国入职#diploma#degree澳洲中央昆士兰大学毕业证成绩单pdf电子版制作修改#毕业文凭制作#回国入职#diploma#degree
 
Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 2Easter Eggs From Star Wars and in cars 1 and 2
Easter Eggs From Star Wars and in cars 1 and 2
 
Real-Time AI Streaming - AI Max Princeton
Real-Time AI  Streaming - AI Max PrincetonReal-Time AI  Streaming - AI Max Princeton
Real-Time AI Streaming - AI Max Princeton
 
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
办理学位证中佛罗里达大学毕业证,UCF成绩单原版一比一
 
NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...
NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...
NLP Data Science Project Presentation:Predicting Heart Disease with NLP Data ...
 

Easy MySQL Replication Setup and Troubleshooting

  • 1. Easy MySQL Replication Setup and Troubleshooting Bob Burgess Salesforce ExactTarget Marketing Cloud (Radian6)
  • 2. • Introduction • Description • Configuration Items • Commands • Setup • Beyond the Basics • Troubleshooting Faults • Gotchas • Closing
  • 3. • Introduction • Description • Configuration Items • Commands • Setup • Beyond the Basics • Troubleshooting Faults • Gotchas • Closing
  • 4. Slides • I will post these slides on the conference site and slideshare • No need to copy them down
  • 5. Who Am I? • MySQL user since 2007 • Radian6: Social Media Monitoring • Now part of Salesforce ExactTarget Marketing Cloud • Large Data Set • Dozens of Databases • Replication is CRUCIAL for us
  • 6. Why Am I Doing This? • Replication isn’t hard • Show simplest replication case • Share how we deal with common problems
  • 7. Our First Replication • Set up a separate database for running reports, to separate back-end from user-facing activity • Alexander Rubin of MySQL Support in 2008
  • 9. Why Replication? • Database Failure • Share Read Traffic (Scale-Out) • Reporting/Analytics Databases • Network Load • Backups
  • 10. Replication Compared • DRBD – Block-level – Replica is unusable until switched to • Galera / Percona Cluster – More complicated – Not WAN-Friendly for High Transaction Rate • Tungsten Replicator • Others..?
  • 11. • Introduction • Description • Configuration Items • Commands • Setup • Beyond the Basics • Troubleshooting Faults • Gotchas • Closing
  • 13. Replication Described Master table1 table2 mysql Update table1 set... Insert into table2... Binlogs: • Events in commit order • Contains timestamps and auto-increment IDs client Replica table1 table2 IO Thread SQL Thread Update table1 set... Insert into table2... mysql
  • 14. • Introduction • Description • Configuration Items • Commands • Setup • Beyond the Basics • Troubleshooting Faults • Gotchas • Closing
  • 15. Replication Described log_bin=/data/log/mysql-bin Config items Master table1 table2 mysql Update table1 set... Insert into table2... client Replica table1 table2 IO Thread SQL Thread Update table1 set... Insert into table2... mysql
  • 16. Replication Described server_id=1 server_id=2 Config items (1) Master table1 table2 mysql Update table1 set... Insert into table2... client Replica (2) table1 table2 IO Thread SQL Thread Update table1 set... Insert into table2... mysql
  • 17. • Introduction • Description • Configuration Items • Commands • Setup • Beyond the Basics • Troubleshooting Faults • Gotchas • Closing
  • 18. Replication Commands • change master to • start slave • stop slave • reset slave • show slave statusG • show master status • mysqlbinlog • grant replication slave
  • 19. Replication Commands change master to... Which server? Port? Credentials? Log file & position? (1) Master table1 table2 mysql client Replica (2) table1 table2 IO Thread SQL Thread Update table1 set... Insert into table2... mysql Update table1 set... Insert into table2...
  • 20. Replication Commands • change master to... Which server? Port? Credentials? Log file & position? • change master to master_host=‘Master’, master_port=3306, master_user=‘repl’, master_password=‘pass’, master_log_file=‘mysql_bin.000001’, master_log_pos=4563744;
  • 21. Replication Commands (1) Master table1 table2 mysql Update table1 set... Insert into table2... client Replica (2) table1 table2 mysql
  • 22. Replication Commands change master to master_host=‘Master’, master_port=3306, master_user=‘repl’, master_password=‘pass’, master_log_file=‘mysql_bin.000001’, master_log_pos=4563744; (1) Master table1 table2 mysql Update table1 set... Insert into table2... client Replica (2) table1 table2 IO Thread Update table1 set... Insert into table2... mysql
  • 23. Replication Commands start slave; (1) Master table1 table2 mysql Update table1 set... Insert into table2... client Replica (2) table1 table2 IO Thread SQL Thread Update table1 set... Insert into table2... mysql
  • 24. Replication Commands stop slave; (1) Master table1 table2 mysql Update table1 set... Insert into table2... client Replica (2) table1 table2 Update table1 set... Insert into table2... mysql
  • 25. Replication Commands reset slave; (1) Master table1 table2 mysql Update table1 set... Insert into table2... client Replica (2) table1 table2 mysql
  • 26. Replication Commands • show slave statusG • Manual troubleshooting • Use in scripts for alarming LAG=$(mysql -s -e’show slave statusG’|grep ‘Seconds_Behind_Master’|cut -f2 -d:| tr -d ‘ ‘) IO_UP=$(mysql -s -e’show slave statusG’|grep ‘Slave_IO_Running’|cut -f2 -d:| tr -d ‘ ‘)
  • 27. Slave_IO_State: Waiting for master to send event Master_Host: Master Master_User: repl Master_Port: 3306 Connect_Retry: 3 Master_Log_File: mysql-bin.000001 Read_Master_Log_Pos: 28762843 Relay_Log_File: relay-bin.000002 Relay_Log_Pos: 548 Relay_Master_Log_File: mysql-bin.000001 Slave_IO_Running: Yes Slave_SQL_Running: Yes 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: 23456234 Relay_Log_Space: 52 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: 8 Master_SSL_Verify_Server_Cert: No Last_IO_Errno: 0 Last_IO_Error: Last_SQL_Errno: 0 Last_SQL_Error: Replicate_Ignore_Server_Ids: 0 Master_Server_Id: 1
  • 28. Slave_IO_State: Waiting for master to send event Master_Host: Master Master_User: repl Master_Port: 3306 Connect_Retry: 3 Master_Log_File: mysql-bin.000001 Read_Master_Log_Pos: 28762843 Relay_Log_File: relay-bin.000002 Relay_Log_Pos: 548 Relay_Master_Log_File: mysql-bin.000001 Slave_IO_Running: Yes Slave_SQL_Running: Yes 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: 23456234 Relay_Log_Space: 52 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: 8 Master_SSL_Verify_Server_Cert: No Last_IO_Errno: 0 Last_IO_Error: Last_SQL_Errno: 0 Last_SQL_Error: Replicate_Ignore_Server_Ids: 0 Master_Server_Id: 1 What it’s doing
  • 29. Slave_IO_State: Waiting for master to send event Master_Host: Master Master_User: repl Master_Port: 3306 Connect_Retry: 3 Master_Log_File: mysql-bin.000001 Read_Master_Log_Pos: 28762843 Relay_Log_File: relay-bin.000002 Relay_Log_Pos: 548 Relay_Master_Log_File: mysql-bin.000001 Slave_IO_Running: Yes Slave_SQL_Running: Yes 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: 23456234 Relay_Log_Space: 52 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: 8 Master_SSL_Verify_Server_Cert: No Last_IO_Errno: 0 Last_IO_Error: Last_SQL_Errno: 0 Last_SQL_Error: Replicate_Ignore_Server_Ids: 0 Master_Server_Id: 1 Where it’s connected
  • 30. Slave_IO_State: Waiting for master to send event Master_Host: Master Master_User: repl Master_Port: 3306 Connect_Retry: 3 Master_Log_File: mysql-bin.000001 Read_Master_Log_Pos: 28762843 Relay_Log_File: relay-bin.000002 Relay_Log_Pos: 548 Relay_Master_Log_File: mysql-bin.000001 Slave_IO_Running: Yes Slave_SQL_Running: Yes 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: 23456234 Relay_Log_Space: 52 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: 8 Master_SSL_Verify_Server_Cert: No Last_IO_Errno: 0 Last_IO_Error: Last_SQL_Errno: 0 Last_SQL_Error: Replicate_Ignore_Server_Ids: 0 Master_Server_Id: 1 Where the IO Thread has read up to
  • 31. Master table1 table2 mysql Update table1 set... Insert into table2... client Replica table1 table2 IO Thread SQL Thread Update table1 set... Insert into table2... mysql Master_Log_File: mysql-bin.000001 Read_Master_Log_Pos: 28762843
  • 32. Slave_IO_State: Waiting for master to send event Master_Host: Master Master_User: repl Master_Port: 3306 Connect_Retry: 3 Master_Log_File: mysql-bin.000001 Read_Master_Log_Pos: 28762843 Relay_Log_File: relay-bin.000002 Relay_Log_Pos: 548 Relay_Master_Log_File: mysql-bin.000001 Slave_IO_Running: Yes Slave_SQL_Running: Yes 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: 23456234 Relay_Log_Space: 52 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: 8 Master_SSL_Verify_Server_Cert: No Last_IO_Errno: 0 Last_IO_Error: Last_SQL_Errno: 0 Last_SQL_Error: Replicate_Ignore_Server_Ids: 0 Master_Server_Id: 1 Where the SQL Thread has executed up to (in relaylog)
  • 33. Master table1 table2 mysql Update table1 set... Insert into table2... client Replica table1 table2 IO Thread SQL Thread Update table1 set... Insert into table2... mysql Relay_Log_File: relay-bin.000002 Relay_Log_Pos: 548
  • 34. Slave_IO_State: Waiting for master to send event Master_Host: Master Master_User: repl Master_Port: 3306 Connect_Retry: 3 Master_Log_File: mysql-bin.000001 Read_Master_Log_Pos: 28762843 Relay_Log_File: relay-bin.000002 Relay_Log_Pos: 548 Relay_Master_Log_File: mysql-bin.000001 Slave_IO_Running: Yes Slave_SQL_Running: Yes 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: 23456234 Relay_Log_Space: 52 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: 8 Master_SSL_Verify_Server_Cert: No Last_IO_Errno: 0 Last_IO_Error: Last_SQL_Errno: 0 Last_SQL_Error: Replicate_Ignore_Server_Ids: 0 Master_Server_Id: 1 Where the SQL Thread has executed up to (corresponding position in Master’s binlog)
  • 35. Master table1 table2 mysql Update table1 set... Insert into table2... client Replica table1 table2 IO Thread SQL Thread Update table1 set... Insert into table2... mysql Relay_Master_Log_File: mysql-bin.000001 Exec_Master_Log_Pos: 23456234
  • 36. Slave_IO_State: Waiting for master to send event Master_Host: Master Master_User: repl Master_Port: 3306 Connect_Retry: 3 Master_Log_File: mysql-bin.000001 Read_Master_Log_Pos: 28762843 Relay_Log_File: relay-bin.000002 Relay_Log_Pos: 548 Relay_Master_Log_File: mysql-bin.000001 Slave_IO_Running: Yes Slave_SQL_Running: Yes 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: 23456234 Relay_Log_Space: 52 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: 8 Master_SSL_Verify_Server_Cert: No Last_IO_Errno: 0 Last_IO_Error: Last_SQL_Errno: 0 Last_SQL_Error: Replicate_Ignore_Server_Ids: 0 Master_Server_Id: 1 If the IO and SQL Threads are running
  • 37. Slave_IO_State: Waiting for master to send event Master_Host: Master Master_User: repl Master_Port: 3306 Connect_Retry: 3 Master_Log_File: mysql-bin.000001 Read_Master_Log_Pos: 28762843 Relay_Log_File: relay-bin.000002 Relay_Log_Pos: 548 Relay_Master_Log_File: mysql-bin.000001 Slave_IO_Running: Yes Slave_SQL_Running: Yes 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: 23456234 Relay_Log_Space: 52 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: 8 Master_SSL_Verify_Server_Cert: No Last_IO_Errno: 0 Last_IO_Error: Last_SQL_Errno: 0 Last_SQL_Error: Replicate_Ignore_Server_Ids: 0 Master_Server_Id: 1 Replication Filters in effect
  • 38. Slave_IO_State: Waiting for master to send event Master_Host: Master Master_User: repl Master_Port: 3306 Connect_Retry: 3 Master_Log_File: mysql-bin.000001 Read_Master_Log_Pos: 28762843 Relay_Log_File: relay-bin.000002 Relay_Log_Pos: 548 Relay_Master_Log_File: mysql-bin.000001 Slave_IO_Running: Yes Slave_SQL_Running: Yes 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: 23456234 Relay_Log_Space: 52 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: 8 Master_SSL_Verify_Server_Cert: No Last_IO_Errno: 0 Last_IO_Error: Last_SQL_Errno: 0 Last_SQL_Error: Replicate_Ignore_Server_Ids: 0 Master_Server_Id: 1 Replication Lag (how long ago was timestamp of latest-processed query?) Can be “NULL”
  • 39. Slave_IO_State: Waiting for master to send event Master_Host: Master Master_User: repl Master_Port: 3306 Connect_Retry: 3 Master_Log_File: mysql-bin.000001 Read_Master_Log_Pos: 28762843 Relay_Log_File: relay-bin.000002 Relay_Log_Pos: 548 Relay_Master_Log_File: mysql-bin.000001 Slave_IO_Running: Yes Slave_SQL_Running: Yes 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: 23456234 Relay_Log_Space: 52 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: 8 Master_SSL_Verify_Server_Cert: No Last_IO_Errno: 0 Last_IO_Error: Last_SQL_Errno: 0 Last_SQL_Error: Replicate_Ignore_Server_Ids: 0 Master_Server_Id: 1 Replication Error (SQL Thread)
  • 40. Slave_IO_State: Waiting for master to send event Master_Host: Master Master_User: repl Master_Port: 3306 Connect_Retry: 3 Master_Log_File: mysql-bin.000001 Read_Master_Log_Pos: 28762843 Relay_Log_File: relay-bin.000002 Relay_Log_Pos: 548 Relay_Master_Log_File: mysql-bin.000001 Slave_IO_Running: Yes Slave_SQL_Running: Yes 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: 23456234 Relay_Log_Space: 52 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: 8 Master_SSL_Verify_Server_Cert: No Last_IO_Errno: 0 Last_IO_Error: Last_SQL_Errno: 0 Last_SQL_Error: Replicate_Ignore_Server_Ids: 0 Master_Server_Id: 1 Replication Error (IO Thread)
  • 41. • Introduction • Description • Configuration Items • Commands • Setup • Beyond the Basics • Troubleshooting Faults • Gotchas • Closing
  • 42. Basic Setup Walk-Through • Unique server_id values my.cnf on master [mysqld] server_id=1 my.cnf on replica [mysqld] server_id=2
  • 43. Basic Setup Walk-Through • Replication User On Master: grant replication slave on *.* to ‘repl’ identified by ‘pass’;
  • 44. Basic Setup Walk-Through • Point to the correct binlog position • On master: show master status; ...once both databases are equal • On Replica: change master to ...
  • 45. Basic Setup Walk-Through • Start it up • On replica: start slave; • Check it • On replica: show slave statusG
  • 47. • Introduction • Description • Configuration Items • Commands • Setup • Beyond the Basics • Troubleshooting Faults • Gotchas • Closing
  • 48. Limiting Tables or Schemas • If you don’t need all the tables • In my.cnf: replicate-do-table=schema.tableName replicate-skip-table=schema.otherTable • If you don’t need all the schemas • In my.cnf replication-do-db=schemaOne replication_skip_db=schemaTwo
  • 49. Limiting Tables replicate-do-table=schema.tableName (1) Master table1 table2 mysql Update table1 set... Insert into table2... client Replica (2) table1 table2 IO Thread SQL Thread with filter Update table1 set... Insert into table2... mysql
  • 50. Limiting Columns or Rows • If you don’t need all columns • Subset of table for reporting or analytics
  • 51. Limiting Columns or Rows • Original table create table x (a int primary key, b int, c int) engine=InnoDB; • Blackhole table on replica like master table create table x (a int, b int, c int) engine=blackhole; • Target table on replica create table y (a int primary key, b int) engine=InnoDB;
  • 52. Limiting Columns or Rows • Before-insert trigger on replica to put data into second “real” table • Only columns a and b, and only for b=1 create trigger x_bi before insert on x for each row insert into y (a, b) select new.a, new.b from dual where new.b=1;
  • 53. Limiting Columns or Rows (1) Master table1 table2 mysql Update table1 set... Insert into table2... client Replica (2) x y IO Thread SQL Thread Update table1 set... Insert into table2... mysql TRG
  • 54. Multi-Level • Local and Remote DR Site • Spreading load over many servers M R M R M R R R R R R R R ...
  • 56. Multi-Level Master Replica table1 table2 table1 table2 mysql IO Thread SQL Thread Update table1 set... Insert into table2... Update table1 set... Insert into table2... Replica table1 table2 IO Thread SQL Thread Update table1 set... Insert into table2... Update table1 set... Insert into table2... mysql
  • 57. Types of Binlogs • Statement-Based – Contains the actual statements run – Data drift is more likely (code modified by triggers, etc) • Row-based – Replicates changes for each row – Mostly unreadable by humans – Unaffected by how the change is done (data drift less likely) – mysqlbinlog -v
  • 58. • Introduction • Description • Configuration Items • Commands • Setup • Beyond the Basics • Troubleshooting Faults • Gotchas • Closing
  • 59. Fault: Lag • Long-running transactions • High concurrency on master becomes single session on replica • show slave statusG • Easy to alarm on
  • 60. Fault: Stopping from Error • Any error stops SQL Thread! • Duplicate Key • Unknown Function • slave_exec_mode=idempotent ...suppresses duplicate-key and no-key-found errors • show slave statusG
  • 61. Faults: Can’t Connect to Master • Fault shows in slave status as soon as you start slave. • Did you create replication slave user? • Correct user/password? • Correct hostname/port? • Master is running and reachable?
  • 62. Fault: Can’t Find Binlog • Clearly stated in the slave status • Can happen if replica has been stopped (or is lagged) and the binlogs are removed from the master • Execute from archive OR • Rebuild replica and restart from a known good binlog position
  • 63. Faults: Configuration • replication-do-table • replication-do-schema • log_slave_updates
  • 64. Faults: server_id • Must be unique! • If equal: “Seconds behind” jumps everywhere.
  • 65. • Introduction • Description • Configuration Items • Commands • Setup • Beyond the Basics • Troubleshooting Faults • Gotchas • Closing
  • 66. Gotcha: functions • Functions will be run on the replica even if only appearing in a select on the master • Make sure all functions exist on replica DB, even if only a dummy version create function myFtn (a int, b int) returns int deterministic return 0;
  • 67. Gotcha: Reconnection • When a replica is stopped and reset, until the database is restarted, replication may reconnect to a master after “reset slave” change master to master_port=1234;
  • 68. Gotcha: Master Crash • Replication becomes unstable if master crashes • Error: unknown instruction at position xxx • Often need to use mysqlbinlog to find a suitable position in the binlog to restart replication from stop slave; reset slave; change master to ...; start slave;
  • 69. Gotcha: MySQL Versions • Replication not completely compatible between versions (especially later=>earlier) • 5.5 master to 5.1 replica: character set error “sometimes” • Stops replication
  • 70. Impossible • One replica can have only one master (until 5.7) • Can’t change table or schema filters dynamically • Can’t put binlogs back on master server, for recovery purposes
  • 71. • Introduction • Description • Configuration Items • Commands • Setup • Beyond the Basics • Troubleshooting Faults • Gotchas • Closing
  • 73. Alternatives • Tungsten Replicator from Continuent • Others?