Oreilly Webcast 01 19 10

19
DRBD & MySQL An HA Match Made In Heaven

description

 

Transcript of Oreilly Webcast 01 19 10

Page 1: Oreilly Webcast 01 19 10

DRBD & MySQL

An HA Match Made In Heaven

Page 2: Oreilly Webcast 01 19 10

April 10, 2023 •• Sean Hull •• <[email protected]>

2

What is DRBD?

Distributed replicated block device

Sits between filesystem & hardware dev

Software-based mirroring

Page 3: Oreilly Webcast 01 19 10

April 10, 2023 •• Sean Hull •• <[email protected]>

3

HA with MySQL Replication

Fast & easy setupStatement based problemsNon-deterministic functionsAsynchronous - time lagRequires monitoring error logMaatkit mk-table-checksum

Page 4: Oreilly Webcast 01 19 10

April 10, 2023 •• Sean Hull •• <[email protected]>

4

HA with MySQL & DRBD

Active/passive clusterExact copy of mysql dbSmall performance hit

using /dev/drbd0 versus /dev/sda1

Page 5: Oreilly Webcast 01 19 10

April 10, 2023 •• Sean Hull •• <[email protected]>

5

Intro to Sun’s Virtualbox

Supports Mac, Windows, Linux

Simple installerBuild VMs easilyAdd virtual external disks

Page 6: Oreilly Webcast 01 19 10

April 10, 2023 •• Sean Hull •• <[email protected]>

6

Downloads

Virtualboxvirtualbox.org/wiki/Downloads

CentOSwiki.centos.org/Download

Page 7: Oreilly Webcast 01 19 10

April 10, 2023 •• Sean Hull •• <[email protected]>

7

Create Your VMs

Create vm using GUI User Storage tab - Add 2nd disk - 25m

scsi Config networking interface

Bridged adaptor Download CentOS DVD ISO image Use storage tab - select ISO image Start VM running - boot iso dvd Install CentOS 5.4 Edit /etc/hosts file

Page 8: Oreilly Webcast 01 19 10

April 10, 2023 •• Sean Hull •• <[email protected]>

8

Install DRBD on Both Nodes$ yum install drbd$ yum install kmod-drbd$ yum install emacs

Page 9: Oreilly Webcast 01 19 10

April 10, 2023 •• Sean Hull •• <[email protected]>

9

Configure DRBD

Edit drbd.conf common { protocol C; } resource sean { on adelie { device /dev/drbd0; disk /dev/sda1; meta-disk internal; address 192.168.0.106:7789; } on african { device /dev/drbd0; disk /dev/sda1; meta-disk internal; address 192.168.0.105:7789; } }

Page 10: Oreilly Webcast 01 19 10

April 10, 2023 •• Sean Hull •• <[email protected]>

10

Protocol C?

C - write IO is reported as completed, if we know it has reached _both_ local & remote DISK for critical transactional data.

B - write IO is reported as completed, if it has reached local DISK and remote buffer cache. for most cases.

A - write IO is reported as completed, if it has reached local DISK and local tcp send buffer. for high latency networks

benchmarks have shown that C is actually better than B.

Page 11: Oreilly Webcast 01 19 10

April 10, 2023 •• Sean Hull •• <[email protected]>

11

What is meta-disk?

Drbd stores metadataInternal - end of your volumeExternal - /dev/hda3…Swapping hd is slightly

different

Page 12: Oreilly Webcast 01 19 10

April 10, 2023 •• Sean Hull •• <[email protected]>

12

Start DRBD Be sure iptables is stopped

$ /etc/init.d/iptables stop $ fdisk /dev/sda $ drbdadm create-md sean $ /etc/init.d/drbd start $ drbdadm -- --overwrite-data-of-peer

primary sean $ watch cat /proc/drbd $ mkfs.ext3 /dev/drbd0 $ mount /dev/drbd0 /mnt/mysql

Page 13: Oreilly Webcast 01 19 10

April 10, 2023 •• Sean Hull •• <[email protected]>

13

Configure MySQL & Start

$ yum install mysql-server.x86_64

Edit /etc/my.cnfdatadir=/mnt/mysql

$ mysql_install_db$ mysqld_safe &Login & create test.demo_tbl

Page 14: Oreilly Webcast 01 19 10

April 10, 2023 •• Sean Hull •• <[email protected]>

14

Test Switching Nodes

On adelie do:Stop mysql$ umount /mnt/mysql

On african do:$ drbdadm primary sean$ mount /dev/drbd0 /mnt/mysql$ mysqld_safe &

Page 15: Oreilly Webcast 01 19 10

April 10, 2023 •• Sean Hull •• <[email protected]>

15

Using Heartbeat

/etc/ha.d/ha.cf/etc/ha.d/haresources/etc/ha.d/authkeysStop mysqlumount /mnt/mysql$ /etc/init.d/heartbeat start/var/log/heartbeat-debug.log

Page 16: Oreilly Webcast 01 19 10

April 10, 2023 •• Sean Hull •• <[email protected]>

16

The Whole HA Stack

drbd - mirror fs, software SANmysql - built on drbd volumeHeartbeat

LvsVirtual IPStart, stop servicesheartbeat

Page 17: Oreilly Webcast 01 19 10

April 10, 2023 •• Sean Hull •• <[email protected]>

17

Conclusions

Alternative to MySQL Repl.Requires some sysadmin

skillsCombined with Heartbeat

Automatic failoverVirtual IP address for both

servers

Page 18: Oreilly Webcast 01 19 10

April 10, 2023 •• Sean Hull •• <[email protected]>

18

Further Reading

ProMySQL: Kruckenberg& Pipes

High Perf MySQL: Lentz, Zaitsev, Tkachenko, Sawodny, Balling, Schwartz

mysqlperformanceblog.complanetmysql.com

Page 19: Oreilly Webcast 01 19 10

April 10, 2023 •• Sean Hull •• <[email protected]>

19

About Us

Sean [email protected]/in/hullsean