SlideShare uma empresa Scribd logo
1 de 23
Baixar para ler 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!

Mais conteúdo relacionado

Mais procurados

netfilter and iptables
netfilter and iptablesnetfilter and iptables
netfilter and iptables
Kernel TLV
 
High-Performance Networking Using eBPF, XDP, and io_uring
High-Performance Networking Using eBPF, XDP, and io_uringHigh-Performance Networking Using eBPF, XDP, and io_uring
High-Performance Networking Using eBPF, XDP, and io_uring
ScyllaDB
 
Accelerating Ceph with RDMA and NVMe-oF
Accelerating Ceph with RDMA and NVMe-oFAccelerating Ceph with RDMA and NVMe-oF
Accelerating Ceph with RDMA and NVMe-oF
inside-BigData.com
 
The linux networking architecture
The linux networking architectureThe linux networking architecture
The linux networking architecture
hugo lu
 

Mais procurados (20)

Linux Performance Profiling and Monitoring
Linux Performance Profiling and MonitoringLinux Performance Profiling and Monitoring
Linux Performance Profiling and Monitoring
 
High Availability PostgreSQL with Zalando Patroni
High Availability PostgreSQL with Zalando PatroniHigh Availability PostgreSQL with Zalando Patroni
High Availability PostgreSQL with Zalando Patroni
 
The Linux Block Layer - Built for Fast Storage
The Linux Block Layer - Built for Fast StorageThe Linux Block Layer - Built for Fast Storage
The Linux Block Layer - Built for Fast Storage
 
OVN - Basics and deep dive
OVN - Basics and deep diveOVN - Basics and deep dive
OVN - Basics and deep dive
 
Introduction to Apache ZooKeeper
Introduction to Apache ZooKeeperIntroduction to Apache ZooKeeper
Introduction to Apache ZooKeeper
 
DPDK KNI interface
DPDK KNI interfaceDPDK KNI interface
DPDK KNI interface
 
DPDK in Containers Hands-on Lab
DPDK in Containers Hands-on LabDPDK in Containers Hands-on Lab
DPDK in Containers Hands-on Lab
 
Ansible presentation
Ansible presentationAnsible presentation
Ansible presentation
 
netfilter and iptables
netfilter and iptablesnetfilter and iptables
netfilter and iptables
 
Nick Fisk - low latency Ceph
Nick Fisk - low latency CephNick Fisk - low latency Ceph
Nick Fisk - low latency Ceph
 
Linux Linux Traffic Control
Linux Linux Traffic ControlLinux Linux Traffic Control
Linux Linux Traffic Control
 
Kernel Recipes 2017: Using Linux perf at Netflix
Kernel Recipes 2017: Using Linux perf at NetflixKernel Recipes 2017: Using Linux perf at Netflix
Kernel Recipes 2017: Using Linux perf at Netflix
 
High-Performance Networking Using eBPF, XDP, and io_uring
High-Performance Networking Using eBPF, XDP, and io_uringHigh-Performance Networking Using eBPF, XDP, and io_uring
High-Performance Networking Using eBPF, XDP, and io_uring
 
Linux Systems Performance 2016
Linux Systems Performance 2016Linux Systems Performance 2016
Linux Systems Performance 2016
 
gRPC Overview
gRPC OverviewgRPC Overview
gRPC Overview
 
DPDK In Depth
DPDK In DepthDPDK In Depth
DPDK In Depth
 
Ceph Block Devices: A Deep Dive
Ceph Block Devices:  A Deep DiveCeph Block Devices:  A Deep Dive
Ceph Block Devices: A Deep Dive
 
Accelerating Ceph with RDMA and NVMe-oF
Accelerating Ceph with RDMA and NVMe-oFAccelerating Ceph with RDMA and NVMe-oF
Accelerating Ceph with RDMA and NVMe-oF
 
The linux networking architecture
The linux networking architectureThe linux networking architecture
The linux networking architecture
 
Where is my bottleneck? Performance troubleshooting in Flink
Where is my bottleneck? Performance troubleshooting in FlinkWhere is my bottleneck? Performance troubleshooting in Flink
Where is my bottleneck? Performance troubleshooting in Flink
 

Destaque

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
 

Destaque (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
 

Semelhante a 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
 

Semelhante a 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
 

Mais de 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
 

Mais de 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
 

Último

EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
Earley Information Science
 

Último (20)

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
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
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
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Evaluating the top large language models.pdf
Evaluating the top large language models.pdfEvaluating the top large language models.pdf
Evaluating the top large language models.pdf
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
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
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Strategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a FresherStrategies for Landing an Oracle DBA Job as a Fresher
Strategies for Landing an Oracle DBA Job as a Fresher
 
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
 

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