ha+drbd+postgres - postgreswest '08

45
Linux‐HA + DRBD + PostgreSQL Jesse Young

Upload: jesse-young

Post on 01-Nov-2014

16.801 views

Category:

Technology


1 download

DESCRIPTION

These are the slides for the HA+DRBD+Postgres talk I gave at PostgresWest '08.

TRANSCRIPT

Page 1: HA+DRBD+Postgres - PostgresWest '08

Linux‐HA+DRBD+PostgreSQL

JesseYoung

Page 2: HA+DRBD+Postgres - PostgresWest '08

TargetAudience

•  SystemAdministrators•  DBAslookingintoreplicaBon

Page 3: HA+DRBD+Postgres - PostgresWest '08

Goals

•  InspiremorereplicaBondiscussions•  InformSystemAdmins/DBAs

•  Describecomponents

•  SimpleSetup

•  DemonstraBon

•  PerformanceTips

Page 4: HA+DRBD+Postgres - PostgresWest '08

Intro

•  ZonarSystems,Inc.– 45,000vehiclessendingdatain24/7andgrowing– 15databaseservers– 5TBdata,growing~25GBdaily– PostgreSQL+PostGIS

Page 5: HA+DRBD+Postgres - PostgresWest '08

WhyuseLinux‐HA+DRBD?

•  SimplereplicaBon•  GPSdatacomingintothesystem24/7

•  MiBgateproblemsfromserverhardware

•  UsersandIntegraBonsoYwareaccess

Page 6: HA+DRBD+Postgres - PostgresWest '08

Linux‐HA

•  “Provide a high availability (clustering) solu6on for Linux which promotes reliability, availability, and serviceability (RAS) through a community development effort.”

•  SystemAdmins:YoucanconBnueto(half)sleep,evenifaserverdies.

Page 7: HA+DRBD+Postgres - PostgresWest '08

DRBD•  DistributedReplicatedBlockDevice

•  Mirroredstorageacrossservers

Imagefromh_p://www.drbd.org

Page 8: HA+DRBD+Postgres - PostgresWest '08

PostgreSQL

•  Databaseengineweallknowandlove

Page 9: HA+DRBD+Postgres - PostgresWest '08

Setup

•  Dual‐procQuad‐[email protected]•  16GBRAM

•  2x74GBSCSI@15kRPM(RAID1‐OS)

•  6x300GBSCSI@10kRPM(RAID10–DRBD)

•  LSIMegaraid–2Channel,512MBCachew/BBU

Page 10: HA+DRBD+Postgres - PostgresWest '08

QuickInstall

•  Versions– heartbeat‐2.0.8– drbd‐8.0.5– PostgreSQL–Anyversion

Page 11: HA+DRBD+Postgres - PostgresWest '08

InstallDRBD

•  Compilefromsourceor

•  yuminstalldrbdkmod‐drbd

Page 12: HA+DRBD+Postgres - PostgresWest '08

ConfigureDRBDresourcepostgres{onnode‐001{device/dev/drbd0;disk/dev/sdb1;address10.40.0.1:7788;meta‐diskinternal;}

onnode‐002{device/dev/drbd0;disk/dev/sdb1;address10.40.0.2:7788;meta‐diskinternal;}}

Page 13: HA+DRBD+Postgres - PostgresWest '08

BeginDRBD

•  Eachnode:– modprobedrbd

– drbdadmcreate‐mdpostgres– drbadmupall

Page 14: HA+DRBD+Postgres - PostgresWest '08

CreateParBBononDRBDDevice

•  Primarynode:– drbdadm‐‐‐‐overwrite‐data‐of‐peerprimaryall

– mke2fs‐j/dev/drbd0– mountdevice– Edit/etc/init.d/postgresql•  PGDATAtoDRBDdevice

–  initdborsync/copyexisBngdatabase

Page 15: HA+DRBD+Postgres - PostgresWest '08

DRBDstatus

•  cat/proc/drbd

version:8.0.5(api:86/proto:86)

SVNRevision:3011buildbyjesse@node‐001.zonarsystems.net,2007‐09‐0223:16:51

0:cs:Connectedst:Primary/Secondaryds:UpToDate/UpToDateCr‐‐‐

ns:191681144nr:108784dw:191798660dr:1228217841al:962834152bm:9054lo:0pe:0ua:0ap:0

resync:used:0/31hits:34633misses:4367starving:0dirty:0changed:4367

act_log:used:0/127hits:11433119293misses:1051777270starving:11558178dirty:81149096changed:962834152

Page 16: HA+DRBD+Postgres - PostgresWest '08

InstallLinux‐HA

•  Compilefromsourceor

•  yuminstallheartbeat

Page 17: HA+DRBD+Postgres - PostgresWest '08

ConfigureLinux‐HA

•  ha.cf•  haresources•  authkeys

Page 18: HA+DRBD+Postgres - PostgresWest '08

ha.cf

deadBme120auto_failbackoff

udpport694

ucasteth110.30.0.10

nodenode‐001.zonarsystems.net

nodenode‐002.zonarsystems.net

Page 19: HA+DRBD+Postgres - PostgresWest '08

haresources

cluster‐001.zonarsystems.netIPaddr::10.30.0.101/24drbddisk::postgres\

Filesystem::/dev/drbd0::/mnt/rod1::ext3\

postgresql\MailTo::[email protected]::'Zonar_Cluster‐001_Switch'

Page 20: HA+DRBD+Postgres - PostgresWest '08

authkeys

auth1

1sha1f93e5e562d430dae92b7fd7b272c13bb0c5de0e2

Page 21: HA+DRBD+Postgres - PostgresWest '08

StartLinux‐HA

•  /etc/init.d/heartbeatstart

Page 22: HA+DRBD+Postgres - PostgresWest '08

DEMO

Page 23: HA+DRBD+Postgres - PostgresWest '08

Problems?

•  Secondaryserveralwaysstand‐by•  Failednodecancauseslowdowns•  Kernelmodule

Page 24: HA+DRBD+Postgres - PostgresWest '08

Performance?

•  ddif=/dev/zeroof=/mnt/drbd/pgwest/testbs=8192count=2000000

•  DRBDdevice– ~85MB/s

•  Diskdevice– 121MB/s

30%write performancedegradaBon

Page 25: HA+DRBD+Postgres - PostgresWest '08

Problems?

Page 26: HA+DRBD+Postgres - PostgresWest '08
Page 27: HA+DRBD+Postgres - PostgresWest '08

PerformanceImprovements

Page 28: HA+DRBD+Postgres - PostgresWest '08

Ethernet

•  Directcrossovercable•  GigE,10GigE•  1500MTUvs9000MTU

Page 29: HA+DRBD+Postgres - PostgresWest '08

RAIDCards

•  CapableofWRITEBACK•  Writecaching

•  Ba_erybackupunit(BBU)

Page 30: HA+DRBD+Postgres - PostgresWest '08

WritebackVS.Writethrough

•  Writeback– 80MB/s–94MB/s

•  Writethrough– 61MB/s–71MB/s

0102030405060708090

100

Run1

Run3

Run5

Run7

Run9

Run11

Run13

Run15

Page 31: HA+DRBD+Postgres - PostgresWest '08

DRBDProtocols

•  ProtocolA– DRBDwaitsforlocaldiskandlocalTCPsendbuffer

•  ProtocolB– DRBDwaitsforlocaldiskandremotebuffercache

•  ProtocolC– DRBDwaitsforbothlocalandremotedisk

– SAFEST

Page 32: HA+DRBD+Postgres - PostgresWest '08

YMMV

•  Remembertotestyourself•  Fedora/e1000networkstackissues•  DRBDissoYwaretoo,bugscomeup

Page 33: HA+DRBD+Postgres - PostgresWest '08

OtherUsesHA‐Linux+DRBD+???

•  Mail•  NFS•  MySQL

Page 34: HA+DRBD+Postgres - PostgresWest '08

QuesBons?

Page 35: HA+DRBD+Postgres - PostgresWest '08

Links

•  Linux‐HA:h_p://www.linux‐ha.org•  DRBD:h_p://www.drbd.org

Page 36: HA+DRBD+Postgres - PostgresWest '08
Page 37: HA+DRBD+Postgres - PostgresWest '08

Demo(backupplan)

Page 38: HA+DRBD+Postgres - PostgresWest '08

Host:c6a

Page 39: HA+DRBD+Postgres - PostgresWest '08

Host:c6a

Page 40: HA+DRBD+Postgres - PostgresWest '08

Host:c6a

Page 41: HA+DRBD+Postgres - PostgresWest '08

Host:c6a

Page 42: HA+DRBD+Postgres - PostgresWest '08

Host:c6a

Page 43: HA+DRBD+Postgres - PostgresWest '08

Host:c6b

Page 44: HA+DRBD+Postgres - PostgresWest '08

Host:c6b

Page 45: HA+DRBD+Postgres - PostgresWest '08

Host:c6a