SlideShare a Scribd company logo
1 of 23
Download to read offline
High Availability with
DRBD & Heartbeat
      Chris Barber
    http://www.cb1inc.com
What is DRBD?
●   Distributed Replicated Block Device
●   RAID 1 mirror across network
●   Realtime replications
●   Linux-only kernel module
●   2 nodes – Primary/Secondary
●   Single/Dual primary mode
●   Open source, free
Visual Overview
          Primary Server                                                          Secondary Server
      Service (MySQL, Apache, etc)                                              Service (MySQL, Apache, etc)



File system                                                                                             File system
                                          OS                          OS

Buffer cache                                                                                           Buffer cache



  DRBD                                                                                                    DRBD



   Disk                            TCP/IP                                  TCP/IP                         Disk
 Scheduler                                                                                              Scheduler



Disk Driver                      NIC Driver                              NIC Driver                     Disk Driver



                        Network Card                            Network Card
   Disk                                                                                                    Disk

                                      Network Card                            Network Card


                        Original chart: http://www.drbd.org/users-guide/ch-fundamentals.html
Uses
●   Database Server( MySQL)
●   Web Server (Apache)
●   File Server (Samba)
●   FTP
●   DNS
●   Email (Postfix)
●   Source Repository (Subversion)
My Setup
●   App 1              ●   App 2
●   AMD Opteron 180    ●   AMD Sempron 2800+
    2.4GHz dual-core   ●   3GB RAM
●   4GB RAM            ●   1 x 250 IDE Hard
●   2 x 250GB SATA         Drive
    Software RAID 1    ●   2 x Gigabit NICs
●   2 x Gigabit NICs
My Setup




App 1                 App 2

   File Server
My Setup




Gigabit
Crossover
Cable
Partitions
●   250GB total
●   20GB Operating system (/)
●   4GB swap
●   226GB DRBD (/mnt/data)
/mnt/data
●   /mnt/data/apache2 – Apache conf, SSL certs,
    htpasswd
●   /mnt/data/mail – Mail directory
    (Postfix/CourierIMAP)
●   /mnt/data/mysql – MySQL conf, database files,
    binlog
●   /mnt/data/svn – Subversion repository
●   /mnt/data/www - Websites
DRBD Install Overview
●   Download source
●   Compile driver
●   modprobe drbd
●   Create /etc/drbd.conf
●   Create meta disk - drbdadm create-md r0
●   Bring up device - drbdadm up r0
●   Become primary
    –   drbdadm -- --overwrite-data-of-peer primary r0
●   mkfs.ext3 /dev/drbd0
●   mount /dev/drbd0 /mnt/data
/etc/drbd.conf
                                         net {
                                           sndbuf-size 512k;
                                           timeout     60; # 6 seconds (unit = 0.1 seconds)
                                           connect-int 10; # 10 seconds (unit = 1 second)
global {
                                           ping-int   10; # 10 seconds (unit = 1 second)
  usage-count no;
                                           ping-timeout 5; # 500 ms (unit = 0.1 seconds)
}
                                           max-buffers 8000;
                                           max-epoch-size 8000;
common {
                                           cram-hmac-alg quot;sha1quot;;
 protocol C;
                                           shared-secret quot;secretquot;;
                                         }
 syncer {
                                     }
   rate 30M;
   al-extents 1801;
                                     resource r0 {
 }
                                      on app1 {
                                        disk    /dev/md2;
 startup {
                                        address 10.10.10.21:7788;
   wfc-timeout 0;
                                        device /dev/drbd0;
   degr-wfc-timeout 15;
                                        meta-disk internal;
 }
                                      }
 disk {
                                         on app2 {
   on-io-error detach;
                                           disk   /dev/sda3;
   # fencing resource-and-stonith;
                                           address 10.10.10.31:7788;
 }
                                           device /dev/drbd0;
                                           meta-disk internal;
                                         }
                                     }
Checking DRBD
 ●   cat /proc/drbd

root@app1:/mnt/data# cat /proc/drbd
version: 8.0.11 (api:86/proto:86)
GIT-hash: b3fe2bdfd3b9f7c2f923186883eb9e2a0d3a5b1b build by phil@mescal, 2008-02-12 11:56:43
 0: cs:Connected st:Primary/Secondary ds:UpToDate/UpToDate C r---
   ns:237740648 nr:7160 dw:19725440 dr:242166751 al:2274 bm:17504 lo:0 pe:0 ua:0 ap:0
      resync: used:0/31 hits:13841287 misses:13628 starving:0 dirty:0 changed:13628
      act_log: used:0/1801 hits:4927296 misses:2427 starving:0 dirty:153 changed:2274
Heartbeat
●   Exchange heartbeats
●   When the heartbeat fails, other begins takeover
●   Use 2 NICs (try to prevent split brain)
●   Uses LSB init scripts
●   Version 1
    –   Simple as cake
●   Version 2
    –   GUI, allows more complex situations
Heartbeat Installation Overview
  ●   Install heartbeat (apt-get install heartbeat)
  ●   3 conf files
                                                          /etc/ha.d/ha.cf
                                                                keepalive 2
/etc/ha.d/haresources                                           deadtime 15
      app1                                                     warntime 5
              IPaddr::192.168.1.211/24/eth0                    initdead 30
              IPaddr::192.168.1.212/24/eth0                    autojoin none
              drbddisk::r0                                     bcast eth1
              Filesystem::/dev/drbd0::/mnt/data::ext3          mcast eth0 239.0.0.42 694 1 0
              bind9                                            auto_failback off
              postfix                                          node app1 app2
              courier-imap                                     logfacility local0
              courier-imap-ssl 
              mysql 
              apache2                                    /etc/ha.d/authkeys
              samba                                             auth 1
                                                                1 sha1 secret
Finalizing Heartbeat Install
●   Stop services
    –   /etc/init.d/apache2 stop
●   Disable services (Ubuntu/Debian)
    –   update-rc.d -f apache2 remove
●   Disable mounting of DRBD drive (/etc/fstab)
    –   /dev/drbd0    /mnt/data    ext3 noauto 0 0
Running Heartbeat
●   /etc/init.d/heartbeat start
●   /usr/lib/heartbeat/hb_takeover
●   /usr/lib/heartbeat/hb_standby
Samba

[global]
      log file = /var/log/samba/log.%m
      passwd chat = *EntersnewsUNIXspassword:*
%nn *RetypesnewsUNIXspassword:* %nn                [data]
*passwd:*passwordsupdatedssuccessfully* .                      writeable = yes
      socket options = TCP_NODELAY                               path = /mnt/data
      obey pam restrictions = yes                                force group = root
      encrypt passwords = true                                   force user = root
      passwd program = /usr/bin/passwd %u                        create mode = 664
      passdb backend = tdbsam                                    directory mode = 775
      dns proxy = no
      server string = %h server (Samba, Ubuntu)         [www]
      invalid users = root                                  force user = www-data
      workgroup = WORKGROUP                                 writeable = yes
      os level = 20                                         create mode = 664
      auto services = data                                  path = /mnt/data/www
      security = user                                       directory mode = 775
      syslog = 0                                            force group = www-data
      panic action = /usr/share/samba/panic-action %d
      max log size = 1000
# guest account = nobody
Split Brain
●   Both servers are primary
●   Which one is up-to-date?
●   How do you prevent split brain?
Stonith
            apt-get install stonith

Shoot
The
Other
Node
In
The
Head
        ●   Home made stonith device
        ●   Connects serial port to other server's reset switch
        ●   ~$40 in Radio Shack parts to build 2 of them
        ●   http://www.scl.co.uk/rcd_serial/README.rcd_serial
MySQL
●   For maximum performance, use RAID 10 with
    battery backed cache RAID controller
●   Write transactions to disk so they get replicated
    –   innodb_flush_log_at_trx_commit=1
    –   sync_binlog=1
●   More info:
    –   http://www.mysqlperformanceblog.com/2008/06/02/how-much-overhead-drdb-could-cause/
Demo
●   Reboot app1
●   App2 become primary
●   App1 comes online, re-syncs
●   Turn off app1's network
●   DRBD on app2 loses connection with app1
●   Run home and enable app1's networking :)
More Info
●   http://www.drbd.org/
●   http://www.cb1inc.com/taxonomy/term/70
Questions?




 Thank you!

More Related Content

What's hot

Share the Experience of Using Embedded Development Board
Share the Experience of Using Embedded Development BoardShare the Experience of Using Embedded Development Board
Share the Experience of Using Embedded Development Board
Jian-Hong Pan
 

What's hot (20)

Linux Kernel Booting Process (2) - For NLKB
Linux Kernel Booting Process (2) - For NLKBLinux Kernel Booting Process (2) - For NLKB
Linux Kernel Booting Process (2) - For NLKB
 
Cours 70 410-1
Cours 70 410-1Cours 70 410-1
Cours 70 410-1
 
Linux Initialization Process (1)
Linux Initialization Process (1)Linux Initialization Process (1)
Linux Initialization Process (1)
 
BPF - in-kernel virtual machine
BPF - in-kernel virtual machineBPF - in-kernel virtual machine
BPF - in-kernel virtual machine
 
Linux Initialization Process (2)
Linux Initialization Process (2)Linux Initialization Process (2)
Linux Initialization Process (2)
 
How A Compiler Works: GNU Toolchain
How A Compiler Works: GNU ToolchainHow A Compiler Works: GNU Toolchain
How A Compiler Works: GNU Toolchain
 
DPDKによる高速コンテナネットワーキング
DPDKによる高速コンテナネットワーキングDPDKによる高速コンテナネットワーキング
DPDKによる高速コンテナネットワーキング
 
SR-IOV+KVM on Debian/Stable
SR-IOV+KVM on Debian/StableSR-IOV+KVM on Debian/Stable
SR-IOV+KVM on Debian/Stable
 
Dataplane programming with eBPF: architecture and tools
Dataplane programming with eBPF: architecture and toolsDataplane programming with eBPF: architecture and tools
Dataplane programming with eBPF: architecture and tools
 
Share the Experience of Using Embedded Development Board
Share the Experience of Using Embedded Development BoardShare the Experience of Using Embedded Development Board
Share the Experience of Using Embedded Development Board
 
Page cache in Linux kernel
Page cache in Linux kernelPage cache in Linux kernel
Page cache in Linux kernel
 
Project ACRN hypervisor introduction
Project ACRN hypervisor introduction Project ACRN hypervisor introduction
Project ACRN hypervisor introduction
 
Jagan Teki - U-boot from scratch
Jagan Teki - U-boot from scratchJagan Teki - U-boot from scratch
Jagan Teki - U-boot from scratch
 
2章 Linuxカーネル - メモリ管理1
2章 Linuxカーネル - メモリ管理12章 Linuxカーネル - メモリ管理1
2章 Linuxカーネル - メモリ管理1
 
malloc & vmalloc in Linux
malloc & vmalloc in Linuxmalloc & vmalloc in Linux
malloc & vmalloc in Linux
 
Linux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKBLinux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKB
 
Linux kernel memory allocators
Linux kernel memory allocatorsLinux kernel memory allocators
Linux kernel memory allocators
 
Kernel Recipes 2017 - Understanding the Linux kernel via ftrace - Steven Rostedt
Kernel Recipes 2017 - Understanding the Linux kernel via ftrace - Steven RostedtKernel Recipes 2017 - Understanding the Linux kernel via ftrace - Steven Rostedt
Kernel Recipes 2017 - Understanding the Linux kernel via ftrace - Steven Rostedt
 
Debug dpdk process bottleneck & painpoints
Debug dpdk process bottleneck & painpointsDebug dpdk process bottleneck & painpoints
Debug dpdk process bottleneck & painpoints
 
Zynq mp勉強会資料
Zynq mp勉強会資料Zynq mp勉強会資料
Zynq mp勉強会資料
 

Viewers also liked

High Availability Setup with Heartbeat and Floating IP
High Availability Setup with Heartbeat and Floating IPHigh Availability Setup with Heartbeat and Floating IP
High Availability Setup with Heartbeat and Floating IP
ayman diab
 
WordPress for Beginners Create Professional Websites
WordPress for Beginners Create Professional WebsitesWordPress for Beginners Create Professional Websites
WordPress for Beginners Create Professional Websites
ayman diab
 
أساسيات لغة Php بالعربي
أساسيات لغة Php بالعربيأساسيات لغة Php بالعربي
أساسيات لغة Php بالعربي
tahsal99
 

Viewers also liked (20)

High Availability Server with DRBD in linux
High Availability Server with DRBD in linuxHigh Availability Server with DRBD in linux
High Availability Server with DRBD in linux
 
High Availability Setup with Heartbeat and Floating IP
High Availability Setup with Heartbeat and Floating IPHigh Availability Setup with Heartbeat and Floating IP
High Availability Setup with Heartbeat and Floating IP
 
WordPress for Beginners Create Professional Websites
WordPress for Beginners Create Professional WebsitesWordPress for Beginners Create Professional Websites
WordPress for Beginners Create Professional Websites
 
brief introduction of drbd in SLE12SP2
brief introduction of drbd in SLE12SP2brief introduction of drbd in SLE12SP2
brief introduction of drbd in SLE12SP2
 
Accomplishing redundancy on Lustre based PFS with DRBD
Accomplishing redundancy on Lustre based PFS with DRBDAccomplishing redundancy on Lustre based PFS with DRBD
Accomplishing redundancy on Lustre based PFS with DRBD
 
What is new in Leap42.2 and SLE12SP2
What is new in Leap42.2 and SLE12SP2What is new in Leap42.2 and SLE12SP2
What is new in Leap42.2 and SLE12SP2
 
BlackStor - World's fastest & most reliable Cloud Native Software Defined Sto...
BlackStor - World's fastest & most reliable Cloud Native Software Defined Sto...BlackStor - World's fastest & most reliable Cloud Native Software Defined Sto...
BlackStor - World's fastest & most reliable Cloud Native Software Defined Sto...
 
Introduction to DRBD
Introduction to DRBDIntroduction to DRBD
Introduction to DRBD
 
DRBD + OpenStack (Openstack Live Prague 2016)
DRBD + OpenStack (Openstack Live Prague 2016)DRBD + OpenStack (Openstack Live Prague 2016)
DRBD + OpenStack (Openstack Live Prague 2016)
 
Alfio Muñoz - Alta disponibilidad con Elastix
Alfio Muñoz - Alta disponibilidad con ElastixAlfio Muñoz - Alta disponibilidad con Elastix
Alfio Muñoz - Alta disponibilidad con Elastix
 
Elastix4.0 High Availability without ElastixHA module
Elastix4.0 High Availability without ElastixHA moduleElastix4.0 High Availability without ElastixHA module
Elastix4.0 High Availability without ElastixHA module
 
أساسيات لغة Php بالعربي
أساسيات لغة Php بالعربيأساسيات لغة Php بالعربي
أساسيات لغة Php بالعربي
 
Drbd
DrbdDrbd
Drbd
 
High Availability Asterisk and FreePBX on Microsoft Azure
High Availability Asterisk and FreePBX on Microsoft AzureHigh Availability Asterisk and FreePBX on Microsoft Azure
High Availability Asterisk and FreePBX on Microsoft Azure
 
MySQL with DRBD/Pacemaker/Corosync on Linux
 MySQL with DRBD/Pacemaker/Corosync on Linux MySQL with DRBD/Pacemaker/Corosync on Linux
MySQL with DRBD/Pacemaker/Corosync on Linux
 
What you need to know about ceph
What you need to know about cephWhat you need to know about ceph
What you need to know about ceph
 
Storage tiering and erasure coding in Ceph (SCaLE13x)
Storage tiering and erasure coding in Ceph (SCaLE13x)Storage tiering and erasure coding in Ceph (SCaLE13x)
Storage tiering and erasure coding in Ceph (SCaLE13x)
 
Ceph: Open Source Storage Software Optimizations on Intel® Architecture for C...
Ceph: Open Source Storage Software Optimizations on Intel® Architecture for C...Ceph: Open Source Storage Software Optimizations on Intel® Architecture for C...
Ceph: Open Source Storage Software Optimizations on Intel® Architecture for C...
 
Ceph Introduction 2017
Ceph Introduction 2017  Ceph Introduction 2017
Ceph Introduction 2017
 
Drbd9 and drbdmanage_june_2016
Drbd9 and drbdmanage_june_2016Drbd9 and drbdmanage_june_2016
Drbd9 and drbdmanage_june_2016
 

Similar to High Availability With DRBD & Heartbeat

High Availability != High-cost
High Availability != High-costHigh Availability != High-cost
High Availability != High-cost
normanmaurer
 
Oreilly Webcast 01 19 10
Oreilly Webcast 01 19 10Oreilly Webcast 01 19 10
Oreilly Webcast 01 19 10
Sean Hull
 
import rdma: zero-copy networking with RDMA and Python
import rdma: zero-copy networking with RDMA and Pythonimport rdma: zero-copy networking with RDMA and Python
import rdma: zero-copy networking with RDMA and Python
groveronline
 

Similar to High Availability With DRBD & Heartbeat (20)

High Availability != High-cost
High Availability != High-costHigh Availability != High-cost
High Availability != High-cost
 
DUG'20: 12 - DAOS in Lenovo’s HPC Innovation Center
DUG'20: 12 - DAOS in Lenovo’s HPC Innovation CenterDUG'20: 12 - DAOS in Lenovo’s HPC Innovation Center
DUG'20: 12 - DAOS in Lenovo’s HPC Innovation Center
 
Oreilly Webcast 01 19 10
Oreilly Webcast 01 19 10Oreilly Webcast 01 19 10
Oreilly Webcast 01 19 10
 
10 things i wish i'd known before using spark in production
10 things i wish i'd known before using spark in production10 things i wish i'd known before using spark in production
10 things i wish i'd known before using spark in production
 
testing-nfs
testing-nfstesting-nfs
testing-nfs
 
Analyze corefile and backtraces with GDB for Mysql/MariaDB on Linux - Nilanda...
Analyze corefile and backtraces with GDB for Mysql/MariaDB on Linux - Nilanda...Analyze corefile and backtraces with GDB for Mysql/MariaDB on Linux - Nilanda...
Analyze corefile and backtraces with GDB for Mysql/MariaDB on Linux - Nilanda...
 
Web Server Free Bsd
Web Server Free BsdWeb Server Free Bsd
Web Server Free Bsd
 
Multipath
MultipathMultipath
Multipath
 
Distributed replicated block device
Distributed replicated block deviceDistributed replicated block device
Distributed replicated block device
 
Dev ops
Dev opsDev ops
Dev ops
 
[OpenInfra Days Korea 2018] Day 1 - T4-7: "Ceph 스토리지, PaaS로 서비스 운영하기"
[OpenInfra Days Korea 2018] Day 1 - T4-7: "Ceph 스토리지, PaaS로 서비스 운영하기"[OpenInfra Days Korea 2018] Day 1 - T4-7: "Ceph 스토리지, PaaS로 서비스 운영하기"
[OpenInfra Days Korea 2018] Day 1 - T4-7: "Ceph 스토리지, PaaS로 서비스 운영하기"
 
XS Japan 2008 Xen Mgmt English
XS Japan 2008 Xen Mgmt EnglishXS Japan 2008 Xen Mgmt English
XS Japan 2008 Xen Mgmt English
 
Docker and friends at Linux Days 2014 in Prague
Docker and friends at Linux Days 2014 in PragueDocker and friends at Linux Days 2014 in Prague
Docker and friends at Linux Days 2014 in Prague
 
Debug generic process
Debug generic processDebug generic process
Debug generic process
 
Advanced administration and problem determination
Advanced administration and problem determinationAdvanced administration and problem determination
Advanced administration and problem determination
 
Linux fundamental - Chap 12 Hardware Management
Linux fundamental - Chap 12 Hardware ManagementLinux fundamental - Chap 12 Hardware Management
Linux fundamental - Chap 12 Hardware Management
 
Kernel Recipes 2015 - Kernel dump analysis
Kernel Recipes 2015 - Kernel dump analysisKernel Recipes 2015 - Kernel dump analysis
Kernel Recipes 2015 - Kernel dump analysis
 
Linux lv ms step by step
Linux lv ms step by stepLinux lv ms step by step
Linux lv ms step by step
 
import rdma: zero-copy networking with RDMA and Python
import rdma: zero-copy networking with RDMA and Pythonimport rdma: zero-copy networking with RDMA and Python
import rdma: zero-copy networking with RDMA and Python
 
Hands on Virtualization with Ganeti
Hands on Virtualization with GanetiHands on Virtualization with Ganeti
Hands on Virtualization with Ganeti
 

More from Chris Barber

Cassandra - Say Goodbye to the Relational Database (5-6-2010)
Cassandra - Say Goodbye to the Relational Database (5-6-2010)Cassandra - Say Goodbye to the Relational Database (5-6-2010)
Cassandra - Say Goodbye to the Relational Database (5-6-2010)
Chris Barber
 

More from Chris Barber (11)

Remote IP Power Switches
Remote IP Power SwitchesRemote IP Power Switches
Remote IP Power Switches
 
Node.js/io.js Native C++ Addons
Node.js/io.js Native C++ AddonsNode.js/io.js Native C++ Addons
Node.js/io.js Native C++ Addons
 
Titanium 3.2 CLI - TiAppCamp2 - 11/2/2013
Titanium 3.2 CLI - TiAppCamp2 - 11/2/2013Titanium 3.2 CLI - TiAppCamp2 - 11/2/2013
Titanium 3.2 CLI - TiAppCamp2 - 11/2/2013
 
Exploring the Titanium CLI - Codestrong 2012
Exploring the Titanium CLI - Codestrong 2012Exploring the Titanium CLI - Codestrong 2012
Exploring the Titanium CLI - Codestrong 2012
 
Intro to PECL/mysqlnd_ms (4/7/2011)
Intro to PECL/mysqlnd_ms (4/7/2011)Intro to PECL/mysqlnd_ms (4/7/2011)
Intro to PECL/mysqlnd_ms (4/7/2011)
 
Cassandra - Say Goodbye to the Relational Database (5-6-2010)
Cassandra - Say Goodbye to the Relational Database (5-6-2010)Cassandra - Say Goodbye to the Relational Database (5-6-2010)
Cassandra - Say Goodbye to the Relational Database (5-6-2010)
 
Debugging Dojo Applications (2/10/2010)
Debugging Dojo Applications (2/10/2010)Debugging Dojo Applications (2/10/2010)
Debugging Dojo Applications (2/10/2010)
 
Titanium Powered Desktop & Mobile Apps (11/21/2009)
Titanium Powered Desktop & Mobile Apps (11/21/2009)Titanium Powered Desktop & Mobile Apps (11/21/2009)
Titanium Powered Desktop & Mobile Apps (11/21/2009)
 
Dojo - Javascript's Swiss Army Knife (7/15/2009)
Dojo - Javascript's Swiss Army Knife (7/15/2009)Dojo - Javascript's Swiss Army Knife (7/15/2009)
Dojo - Javascript's Swiss Army Knife (7/15/2009)
 
2008 MySQL Conference Recap
2008 MySQL Conference Recap2008 MySQL Conference Recap
2008 MySQL Conference Recap
 
Memcached And MySQL
Memcached And MySQLMemcached And MySQL
Memcached And MySQL
 

Recently uploaded

Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 

Recently uploaded (20)

Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
Navigating the Deluge_ Dubai Floods and the Resilience of Dubai International...
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
Apidays New York 2024 - Passkeys: Developing APIs to enable passwordless auth...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Cyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdfCyberprint. Dark Pink Apt Group [EN].pdf
Cyberprint. Dark Pink Apt Group [EN].pdf
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 

High Availability With DRBD & Heartbeat

  • 1. High Availability with DRBD & Heartbeat Chris Barber http://www.cb1inc.com
  • 2. What is DRBD? ● Distributed Replicated Block Device ● RAID 1 mirror across network ● Realtime replications ● Linux-only kernel module ● 2 nodes – Primary/Secondary ● Single/Dual primary mode ● Open source, free
  • 3. Visual Overview Primary Server Secondary Server Service (MySQL, Apache, etc) Service (MySQL, Apache, etc) File system File system OS OS Buffer cache Buffer cache DRBD DRBD Disk TCP/IP TCP/IP Disk Scheduler Scheduler Disk Driver NIC Driver NIC Driver Disk Driver Network Card Network Card Disk Disk Network Card Network Card Original chart: http://www.drbd.org/users-guide/ch-fundamentals.html
  • 4. Uses ● Database Server( MySQL) ● Web Server (Apache) ● File Server (Samba) ● FTP ● DNS ● Email (Postfix) ● Source Repository (Subversion)
  • 5. My Setup ● App 1 ● App 2 ● AMD Opteron 180 ● AMD Sempron 2800+ 2.4GHz dual-core ● 3GB RAM ● 4GB RAM ● 1 x 250 IDE Hard ● 2 x 250GB SATA Drive Software RAID 1 ● 2 x Gigabit NICs ● 2 x Gigabit NICs
  • 6. My Setup App 1 App 2 File Server
  • 8. Partitions ● 250GB total ● 20GB Operating system (/) ● 4GB swap ● 226GB DRBD (/mnt/data)
  • 9. /mnt/data ● /mnt/data/apache2 – Apache conf, SSL certs, htpasswd ● /mnt/data/mail – Mail directory (Postfix/CourierIMAP) ● /mnt/data/mysql – MySQL conf, database files, binlog ● /mnt/data/svn – Subversion repository ● /mnt/data/www - Websites
  • 10. DRBD Install Overview ● Download source ● Compile driver ● modprobe drbd ● Create /etc/drbd.conf ● Create meta disk - drbdadm create-md r0 ● Bring up device - drbdadm up r0 ● Become primary – drbdadm -- --overwrite-data-of-peer primary r0 ● mkfs.ext3 /dev/drbd0 ● mount /dev/drbd0 /mnt/data
  • 11. /etc/drbd.conf net { sndbuf-size 512k; timeout 60; # 6 seconds (unit = 0.1 seconds) connect-int 10; # 10 seconds (unit = 1 second) global { ping-int 10; # 10 seconds (unit = 1 second) usage-count no; ping-timeout 5; # 500 ms (unit = 0.1 seconds) } max-buffers 8000; max-epoch-size 8000; common { cram-hmac-alg quot;sha1quot;; protocol C; shared-secret quot;secretquot;; } syncer { } rate 30M; al-extents 1801; resource r0 { } on app1 { disk /dev/md2; startup { address 10.10.10.21:7788; wfc-timeout 0; device /dev/drbd0; degr-wfc-timeout 15; meta-disk internal; } } disk { on app2 { on-io-error detach; disk /dev/sda3; # fencing resource-and-stonith; address 10.10.10.31:7788; } device /dev/drbd0; meta-disk internal; } }
  • 12. Checking DRBD ● cat /proc/drbd root@app1:/mnt/data# cat /proc/drbd version: 8.0.11 (api:86/proto:86) GIT-hash: b3fe2bdfd3b9f7c2f923186883eb9e2a0d3a5b1b build by phil@mescal, 2008-02-12 11:56:43 0: cs:Connected st:Primary/Secondary ds:UpToDate/UpToDate C r--- ns:237740648 nr:7160 dw:19725440 dr:242166751 al:2274 bm:17504 lo:0 pe:0 ua:0 ap:0 resync: used:0/31 hits:13841287 misses:13628 starving:0 dirty:0 changed:13628 act_log: used:0/1801 hits:4927296 misses:2427 starving:0 dirty:153 changed:2274
  • 13. Heartbeat ● Exchange heartbeats ● When the heartbeat fails, other begins takeover ● Use 2 NICs (try to prevent split brain) ● Uses LSB init scripts ● Version 1 – Simple as cake ● Version 2 – GUI, allows more complex situations
  • 14. Heartbeat Installation Overview ● Install heartbeat (apt-get install heartbeat) ● 3 conf files /etc/ha.d/ha.cf keepalive 2 /etc/ha.d/haresources deadtime 15 app1 warntime 5 IPaddr::192.168.1.211/24/eth0 initdead 30 IPaddr::192.168.1.212/24/eth0 autojoin none drbddisk::r0 bcast eth1 Filesystem::/dev/drbd0::/mnt/data::ext3 mcast eth0 239.0.0.42 694 1 0 bind9 auto_failback off postfix node app1 app2 courier-imap logfacility local0 courier-imap-ssl mysql apache2 /etc/ha.d/authkeys samba auth 1 1 sha1 secret
  • 15. Finalizing Heartbeat Install ● Stop services – /etc/init.d/apache2 stop ● Disable services (Ubuntu/Debian) – update-rc.d -f apache2 remove ● Disable mounting of DRBD drive (/etc/fstab) – /dev/drbd0 /mnt/data ext3 noauto 0 0
  • 16. Running Heartbeat ● /etc/init.d/heartbeat start ● /usr/lib/heartbeat/hb_takeover ● /usr/lib/heartbeat/hb_standby
  • 17. Samba [global] log file = /var/log/samba/log.%m passwd chat = *EntersnewsUNIXspassword:* %nn *RetypesnewsUNIXspassword:* %nn [data] *passwd:*passwordsupdatedssuccessfully* . writeable = yes socket options = TCP_NODELAY path = /mnt/data obey pam restrictions = yes force group = root encrypt passwords = true force user = root passwd program = /usr/bin/passwd %u create mode = 664 passdb backend = tdbsam directory mode = 775 dns proxy = no server string = %h server (Samba, Ubuntu) [www] invalid users = root force user = www-data workgroup = WORKGROUP writeable = yes os level = 20 create mode = 664 auto services = data path = /mnt/data/www security = user directory mode = 775 syslog = 0 force group = www-data panic action = /usr/share/samba/panic-action %d max log size = 1000 # guest account = nobody
  • 18. Split Brain ● Both servers are primary ● Which one is up-to-date? ● How do you prevent split brain?
  • 19. Stonith apt-get install stonith Shoot The Other Node In The Head ● Home made stonith device ● Connects serial port to other server's reset switch ● ~$40 in Radio Shack parts to build 2 of them ● http://www.scl.co.uk/rcd_serial/README.rcd_serial
  • 20. MySQL ● For maximum performance, use RAID 10 with battery backed cache RAID controller ● Write transactions to disk so they get replicated – innodb_flush_log_at_trx_commit=1 – sync_binlog=1 ● More info: – http://www.mysqlperformanceblog.com/2008/06/02/how-much-overhead-drdb-could-cause/
  • 21. Demo ● Reboot app1 ● App2 become primary ● App1 comes online, re-syncs ● Turn off app1's network ● DRBD on app2 loses connection with app1 ● Run home and enable app1's networking :)
  • 22. More Info ● http://www.drbd.org/ ● http://www.cb1inc.com/taxonomy/term/70