My SQL Replication and Scaling

Preview:

Citation preview

MySQL Replication MySQL Replication & &

ScalingScaling

Presenter: Avishek Kumar SharmaMindfire Solutions

Date: 29/10/2014

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: avisheks@mindfiresolutions.comSkype: mfsi_avisheks

About Me

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)

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.

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

6

Replication Topology

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;

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”

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”

10

Replication and “Scaling-out”

11

12

reads = 1200 - 2 * writes

13

Backup and replication(HA/Fault Tolerance)

14

before redundancy:

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.

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.

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

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 >>

19

Thank you :)Thank you :)

20

https://www.facebook.com/MindfireSolutions

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

http://twitter.com/mindfires

www.mindfiresolutions.com

Contact Us @

Recommended