Top Banner
MySQL Replication MySQL Replication & & Scaling Scaling Presenter: Avishek Kumar Sharma Mindfire Solutions Date: 29/10/2014
20
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: My SQL Replication and Scaling

MySQL Replication MySQL Replication & &

ScalingScaling

Presenter: Avishek Kumar SharmaMindfire Solutions

Date: 29/10/2014

Page 2: My SQL Replication and Scaling

OCP MySQL 5.0 - Oracle Certified Professional

Connect Me :Facebook: https://www.facebook.com/avishekkumar.sharma.5LinkedIn: http://in.linkedin.com/pub/avishek-kumar-sharma/31/798/509

Twitter: https://twitter.com/sharma_avishekGoogle+: https://plus.google.com/103775319893123886681/posts

Blog:http://avisheksharma.wordpress.com

Contact Me :Email: [email protected]: mfsi_avisheks

About Me

Page 3: My SQL Replication and Scaling

3

Today's Talk

1. Replication- brief introduction2. Multiple MySQL Instances3. Replication Topology4. Setting up Replication (Demo) - Master Configurations - Binlog - Replication User - Slave Configurations - Relaylog - Replication Thread - Start Slave5. Trouble Shooting Replication6. Replication Compatibility and Upgrading7. Replication and Scaling-out8. Backup and replication(HA/Fault Tolerance)

Page 4: My SQL Replication and Scaling

4

Replication- brief intro

- Capability that allows the databases on one server(the master) to be made available on another servers(the slaves).

- Replication was introduced in MySQL version 3 and matured to a robust, stable technology as of MySQL 4.0.2.

Page 5: My SQL Replication and Scaling

5

Multiple MySQL Instances

Multiple MySQL server instances on a single host. - new release testing - administrative work

Caution: - separate data-dir(unless readonly) - separate network interfaces - TCP/IP port - socket files - separate log/PID file

Page 6: My SQL Replication and Scaling

6

Replication Topology

Page 7: My SQL Replication and Scaling

7

Setting up Replication (demo)- Sync both databases.- Master Configurations - Enable binlog

- set log_bin = /var/log/mysql/mysql-bin.log - Replication User

- CREATE USER `replicator`@localhost IDENTIFIED BY `mindfire`;- GRANT REPLICATION SLAVE ON *.* TO replicator@localhost;

- Slave Configurations - Relaylog(optional)

- relay-log = /var/lib/mysql/slave-relay.log- Set Master host

- CHANGE MASTER TOMASTER_HOST = 'localhost',MASTER_USER = 'replicator',MASTER_PORT = 3306,MASTER_PASSWORD = "mindfire",MASTER_LOG_FILE = 'mysql-bin.000001',MASTER_LOG_POS = 120;

- Start Slave- START SLAVE;

Page 8: My SQL Replication and Scaling

8

Trouble Shooting Replication

- If slave is running ?

- SHOW SLAVE [IO_THREAD/SQL_THREAD] STATUS;

if not, issue:

- START SLAVE [IO_THREAD/SQL_THREAD];

- monitor slave log.

- master/slave have unique server-ids ?

- binary_logging enabled on master ?

- SHOW VARIABLES LIKE "log_bin";

- connect master host from mysql client ?

- error information for “SHOW SLAVE STATUS”

Page 9: My SQL Replication and Scaling

9

Replication Compatibility and Upgrading

- Slave trouble parsing binary log file sent from master.

- replication compatibility is the best when both master and slave run on same server version.

- as a general rule “upgrade slave before upgrading master”

Page 10: My SQL Replication and Scaling

10

Replication and “Scaling-out”

Page 11: My SQL Replication and Scaling

11

Page 12: My SQL Replication and Scaling

12

reads = 1200 - 2 * writes

Page 13: My SQL Replication and Scaling

13

Backup and replication(HA/Fault Tolerance)

Page 14: My SQL Replication and Scaling

14

before redundancy:

Page 15: My SQL Replication and Scaling

15

Master went down, Slave 1 as new Master.(monitor replication heartbeat)

1. On each slave, - STOP SLAVE IO_THREAD(check the output of SHOW PROCESSLIST until you see Has read all relay log)

2. On the slave Slave 1,- STOP SLAVE- RESET MASTER.

3. On the other slaves Slave 2 and Slave 3, - STOP SLAVE - CHANGE MASTER TO MASTER_HOST='Slave1'- START SLAVE

4. tell each Web Client to direct its statements to Slave 1.

NB: Slaves must be running with --log-bin and without –log-slave-updates.

Page 16: My SQL Replication and Scaling

16

after redundancy:

NB: after the master being available again, it has to become slave of “Slave 1” first for being updated with all missed events before it become Master again.

Page 17: My SQL Replication and Scaling

17

References

http://dev.mysql.com/doc/refman/5.6/en/replication.html

http://dev.mysql.com/doc/refman/5.6/en/replication-solutions-scaleout.html

http://dev.mysql.com/doc/refman/5.6/en/replication-solutions-switch.html

Page 18: My SQL Replication and Scaling

www.mindfiresolutions.com

SAMPLE CASE STUDY

The client firm had a couple of social networking – video sharing community websites that were hosted using a freely available open source codebase that the client had acquired on the web and wanted to enhance. Contracting work to another firm and that too, another country was a double-challenge for the client firm. Mindfire's immense experience in video streaming and community/social application development, helped establish the initial trust. This was well supported by the different business engagement models Mindfire proposed to the client firm. Two dedicated resources were assigned for the first two months and this later became a long and healthy relationship resulting in a full scale virtual team setup on the video sharing community application development. Mindfire delivered a full scale, extensible team setup, with experienced resources involved in multiple technologies for both client and server side application design and development.

Click to get detai led info >>

Page 19: My SQL Replication and Scaling

19

Thank you :)Thank you :)

Page 20: My SQL Replication and Scaling

20

https://www.facebook.com/MindfireSolutions

http://www.linkedin.com/company/mindfire-solutions

http://twitter.com/mindfires

www.mindfiresolutions.com

Contact Us @