11

Click here to load reader

Linux Load Balancing and MySQL Replication

Embed Size (px)

DESCRIPTION

Slides from Shohei Azuma's talk on CSU East Bay LUG on 2008-03-15

Citation preview

Page 1: Linux Load Balancing and MySQL Replication

Linux Load Balancing andMySQL Replication

Shohei Azuma

Page 2: Linux Load Balancing and MySQL Replication

Load Balancing

Ultramonkey Layer 4 / Layer 7 http://sourceforge.jp/projects/ultramonkey-l7 OSI Model Layer 4

TCP, UDP, SPX, NetBEUI

OSI Model Layer 7 HTTP, SMTP, SNMP, FTP, Telnet

Requirements Two identical Linux Servers

Page 3: Linux Load Balancing and MySQL Replication

Ultramonkey Layer4

Technology Linux Virtual Server Heartbeat Ldirectord ipvsadmin

Types of Load Balancing rr, wrr, lc, wlc masq , gate

http://enterprisezine.jp/article/detail/228?p=2

Page 4: Linux Load Balancing and MySQL Replication

Ultramonkey Layer 7

Technology Linux Virtual Server Heartbeat l7directord l7vsadmin

Types of Load Balancing rr, lc masq (gate no longer works)

Page 5: Linux Load Balancing and MySQL Replication

Cont.d

Layer 7 Specific character string

if *.php go to server1, esle -> server2 Session persistence

shopping carts, payments, etc SSL Cockie Replication

Sample configuration http://ultramonkey-l7.sourceforge.jp/index_en.html

Page 6: Linux Load Balancing and MySQL Replication

MySQL Replication

Why replication Failover, Backup, load balancing, etc

Terms Binary logs, master, slave, ndb, position, Cluster

Cluster more than 2 storage nodes, one manager, and more than

two API nodes http://dev.mysql.com/doc/refman/5.1/ja/images/cluster-replication-overview.png Requires a lot of memory Require very fast connections. (Gigabit reccomended)

Page 7: Linux Load Balancing and MySQL Replication

One Way Replication

Master -> Slave Replication One Master DB server, and slave DB server When Master is updated, slave will be updated Apps only writes to master server

Page 8: Linux Load Balancing and MySQL Replication

Multi Way Replication

Server 1 :Master1, Slave 1 Server 2 :Master2, Slave 2

Master1 -> Slave2 replication, Master2 -> slave2 replication, Must be careful not to be in race cond.

Better if one is read only

Page 9: Linux Load Balancing and MySQL Replication

Configuration

Issues Only writable to one of the hosts to avoid

inconsistent tables Loads will be based on the web server's loads Moving to cluster will be too costly

MySQL Multi Master Configuration http://www.onlamp.com/pub/a/onlamp/2006/04/20/advanced-mysql-replication.html Multi-Master with cluster for remote sites

http://dev.mysql.com/doc/refman/5.1/ja/images/cluster-replication-overview.png

Page 10: Linux Load Balancing and MySQL Replication

Ultramonkey + MySQL

Two web servers with 2 NICs

Two MySQL servers Scalable on separete

layer Move Muti-Master to

cluster when adding many more nodes

Page 11: Linux Load Balancing and MySQL Replication

References

Ultramonkey Project Download http://sourceforge.jp/projects/ultramonkey-l7

masquerading/Gating http://enterprisezine.jp/article/detail/228?p=2

MySQL Cluster Diagram http://dev.mysql.com/doc/refman/5.1/ja/images/cluster-replication-overview.png