Oreilly Webcast 01 19 10

Post on 28-Jan-2015

107 views 0 download

description

 

Transcript of Oreilly Webcast 01 19 10

DRBD & MySQL

An HA Match Made In Heaven

April 10, 2023 •• Sean Hull •• <hullsean@gmail.com>

2

What is DRBD?

Distributed replicated block device

Sits between filesystem & hardware dev

Software-based mirroring

April 10, 2023 •• Sean Hull •• <hullsean@gmail.com>

3

HA with MySQL Replication

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

April 10, 2023 •• Sean Hull •• <hullsean@gmail.com>

4

HA with MySQL & DRBD

Active/passive clusterExact copy of mysql dbSmall performance hit

using /dev/drbd0 versus /dev/sda1

April 10, 2023 •• Sean Hull •• <hullsean@gmail.com>

5

Intro to Sun’s Virtualbox

Supports Mac, Windows, Linux

Simple installerBuild VMs easilyAdd virtual external disks

April 10, 2023 •• Sean Hull •• <hullsean@gmail.com>

6

Downloads

Virtualboxvirtualbox.org/wiki/Downloads

CentOSwiki.centos.org/Download

April 10, 2023 •• Sean Hull •• <hullsean@gmail.com>

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

April 10, 2023 •• Sean Hull •• <hullsean@gmail.com>

8

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

April 10, 2023 •• Sean Hull •• <hullsean@gmail.com>

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

April 10, 2023 •• Sean Hull •• <hullsean@gmail.com>

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.

April 10, 2023 •• Sean Hull •• <hullsean@gmail.com>

11

What is meta-disk?

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

different

April 10, 2023 •• Sean Hull •• <hullsean@gmail.com>

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

April 10, 2023 •• Sean Hull •• <hullsean@gmail.com>

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

April 10, 2023 •• Sean Hull •• <hullsean@gmail.com>

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 &

April 10, 2023 •• Sean Hull •• <hullsean@gmail.com>

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

April 10, 2023 •• Sean Hull •• <hullsean@gmail.com>

16

The Whole HA Stack

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

LvsVirtual IPStart, stop servicesheartbeat

April 10, 2023 •• Sean Hull •• <hullsean@gmail.com>

17

Conclusions

Alternative to MySQL Repl.Requires some sysadmin

skillsCombined with Heartbeat

Automatic failoverVirtual IP address for both

servers

April 10, 2023 •• Sean Hull •• <hullsean@gmail.com>

18

Further Reading

ProMySQL: Kruckenberg& Pipes

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

mysqlperformanceblog.complanetmysql.com

April 10, 2023 •• Sean Hull •• <hullsean@gmail.com>

19

About Us

Sean Hullhullsean@gmail.comwww.oracleopensource.comwww.linkedin.com/in/hullsean