High Availability Server with DRBD in linux

1,135 views
1,012 views

Published on

This is sort presentation about How to build High Availability Website with apache and mysql in linux

Published in: Economy & Finance
1 Comment
1 Like
Statistics
Notes
  • DRBD®, the DRBD logo, LINBIT®, and the LINBIT logo are trademarks or registered trademarks of LINBIT in Austria, the United States and other countries.
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
No Downloads
Views
Total views
1,135
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
43
Comments
1
Likes
1
Embeds 0
No embeds

No notes for slide

High Availability Server with DRBD in linux

  1. 1. With IP Failover, Heartbeat, Pacemaker on Ubuntu Server Presented by Ali Rachman Annual Meeting TS, 7-9 Maret 2012 1
  2. 2. High AvailabilityHigh Availability mengacu kepada suatu praktek untuk menjaga agarresource yang ada tetap online atau tersedia karena disebabkan olehkegagalan suatu node atau sistemPanduan kali ini, menunjukkan suatu metode untuk menggunakan dualinode untuk menjaga suatu website tetap online. Bahkan ketika nodeprimary dimatikan.Pada prakteknya, akan menggunakan metode IPFailover, Heartbeat, Pacemaker dan Apache Annual Meeting TS, 7-9 Maret 2012 2
  3. 3. Catatan :1. Metode yang digunakan mungkin tidak sesuai dengan beberapa kasus High Availability yang ada.2. Diharapkan metode yang digunakan dalam praktek ini bisa memberikan gambaran yang jelas tentang HA guna pengembangan di kasus-kasus yang lain.3. Konfigurasi yang ada dalam metode ini hanya bekerja untuk situs yang statis Annual Meeting TS, 7-9 Maret 2012 3
  4. 4. Terminology :1. Basic system configuration2. Assign Static IP Address3. Install require Packages4. Configure Apache 25. Configure Heartbeat6. Configure Cluster Resources7. Monitor Cluster Resource Annual Meeting TS, 7-9 Maret 2012 4
  5. 5. Konfigurasi yang digunakan:1. HA1  Primary Linode2. HA2  Secondary Linode3. 12.34.56.78  Static IP untuk Primary Linode4. 98.76.54.32  Static IP untuk Secondary Linode5. 44.44.44.44  “floating” IP6. 4321  password untuk authentifikasi7. Tes.ams.id  contoh website yang akan di bangun Annual Meeting TS, 7-9 Maret 2012 5
  6. 6. Basic System Configuration:Login dengan ssh ke primary linodeEdit /etc/hosts dan isi sesuai di bawah : 127.0.0.1 localhost.localdomain localhost 12.34.56.78 ha1.ams.id ha1 98.76.54.32 ha2.ams.id ha2 Annual Meeting TS, 7-9 Maret 2012 6
  7. 7. Basic System Configuration:Ssh host key syncronizationSsh host key syncronization ini digunakan untuk mensinkronisasikan loginantar dua linode yang berbedaLakukan hal berikut dari primary linode : ssh-keygen -t rsa scp ~/.ssh/id_rsa.pub root@ha2:/root/ha1_key.pub ssh root@ha2 "ssh-keygen -t rsa" ssh root@ha2 "echo `cat ~/ha1_key.pub` >> ~/.ssh/authorized_keys2" ssh root@ha2 "rm ~/ha1_key.pub" scp root@ha2:/root/.ssh/id_rsa.pub /root cat ~/id_rsa.pub >> ~/.ssh/authorized_keys2 rm ~/id_rsa.pub scp /etc/ssh/ssh_host* root@ha2:/etc/ssh/ rm ~/.ssh/known_hosts ssh root@ha2 "/etc/init.d/ssh restart" scp /etc/hosts root@ha2:/etc/hosts echo "ha1" > /etc/hostname hostname -F /etc/hostname ssh root@ha2 "echo "ha2" > /etc/hostname" ssh root@ha2 "hostname -F /etc/hostname" Annual Meeting TS, 7-9 Maret 2012 7
  8. 8. Assign Static IP Address :Primary Linode : Edit /etc/network/interfaces : auto lo iface lo inet loopback auto eth0 iface eth0 inet static address 12.34.56.78 netmask 255.255.255.0 gateway 12.34.56.1 Secondary Linode : /etc/init.d/networking restart Edit /etc/network/interfaces : auto lo iface lo inet loopback auto eth0 iface eth0 inet static address 98.76.54.32 netmask 255.255.255.0 gateway 09.76.54.1 /etc/init.d/networking restart Annual Meeting TS, 7-9 Maret 2012 8
  9. 9. Install Required Packages :Primary Linode : apt-get update apt-get upgrade apt-get install heartbeat pacemaker apache2 /etc/init.d/apache2 stop update-rc.d -f apache2 remove mkdir -p /srv/www/ams.id/tes/public_html mkdir /srv/www/ams.id/tes/logs ssh root@ha2 "apt-get update" ssh root@ha2 "apt-get upgrade" ssh root@ha2 "apt-get install heartbeat pacemaker apache2" ssh root@ha2 "/etc/init.d/apache2 stop" ssh root@ha2 "update-rc.d -f apache2 remove" ssh root@ha2 "mkdir -p /srv/www/ams.id/tes/public_html" ssh root@ha2 "mkdir /srv/www/ams.id/tes/logs" Annual Meeting TS, 7-9 Maret 2012 9
  10. 10. Configure Apache2 :Primary Linode : Edit /etc/apache2/ports.conf : NameVirtualHost 44.44.44.44:80 Listen 80Buat file untuk website tes.ams.id yang akan dibuat HA : Edit /etc/apache2/sites-available/tes.ams.id : <VirtualHost 44.44.44.44:80> ServerAdmin support@ams.id ServerName tes.ams.id DocumentRoot /srv/www/ams.id/tes/public_html/ ErrorLog /srv/www/ams.id/tes/logs/error.log CustomLog /srv/www/ams.id/tes/logs/access.log combined </VirtualHost> Annual Meeting TS, 7-9 Maret 2012 10
  11. 11. Configure Apache2 :Primary Linode : Lakukan perintah berikut : <VirtualHost 44.44.44.44:80> ServerAdmin support@ams.id ServerName tes.ams.id DocumentRoot /srv/www/ams.id/tes/public_html/ ErrorLog /srv/www/ams.id/tes/logs/error.log CustomLog /srv/www/ams.id/tes/logs/access.log combined </VirtualHost>Buat tes page di primary :Buat file di /srv/www/ams.id/tes/public_html/index.html : <html> <head> <title>Test page served from ha1</title> </head> <body> <h1>Test page served from ha1</h1> </body> </html> Annual Meeting TS, 7-9 Maret 2012 11
  12. 12. Configure Apache2 :Secondary Linode : Buat tes page di secondary : Buat file di /srv/www/ams.id/tes/public_html/index.html : <html> <head> <title>Test page served from ha2</title> </head> <body> <h1>Test page served from ha2</h1> </body> </html>Primary Linode : Lakukan hal berikut untuk meng-enable site : a2ensite tes.ams.id ssh root@ha2 "a2ensite tes.ams.id" Annual Meeting TS, 7-9 Maret 2012 12
  13. 13. Configure Heartbeat :Primary Linode : Edit /etc/heartbeat/ha.cf : logfacility daemon keepalive 2 deadtime 15 warntime 5 initdead 120 udpport 694 ucast eth0 98.76.54.32 auto_failback on node ha1 node ha2 use_logd yes crm respawn Annual Meeting TS, 7-9 Maret 2012 13
  14. 14. Configure Heartbeat :Secondary Linode : Edit /etc/heartbeat/ha.cf : logfacility daemon keepalive 2 deadtime 15 warntime 5 initdead 120 udpport 694 ucast eth0 12.34.56.78 auto_failback on node ha1 node ha2 use_logd yes crm respawn Annual Meeting TS, 7-9 Maret 2012 14
  15. 15. Configure Heartbeat :Primary Linode : Edit /etc/heartbeat/authkeys : auth 1 1 sha1 4321 Lakukan perintah berikut : chmod 600 /etc/ha.d/authkeys /etc/init.d/heartbeat start scp /etc/ha.d/authkeys root@ha2:/etc/ha.d/ ssh root@ha2 "chmod 600 /etc/ha.d/authkeys" ssh root@ha2 "/etc/init.d/heartbeat start" Annual Meeting TS, 7-9 Maret 2012 15
  16. 16. Configure ClusterResources :Primary Linode : Lakukan perintah berikut : export EDITOR=/bin/nano echo "export EDITOR=/bin/nano" >> .bashrcSecondary Linode : Lakukan perintah berikut : export EDITOR=/bin/nano echo "export EDITOR=/bin/nano" >> .bashrc Annual Meeting TS, 7-9 Maret 2012 16
  17. 17. Configure ClusterResources :Primary Linode : Lakukan perintah berikut : crm configure edit Akan tampil seperti berikut : node $id="285a1261-9066-45de-97ac-04b13e5a1f6c" ha1 node $id="b4fbb893-55d6-4a33-81fb-34f8d010df7f" ha2 property $id="cib-bootstrap-options" dc-version="1.0.8- 042548a451fce8400660f6031f4da6f0223dd5dd" cluster-infrastructure="Heartbeat" Annual Meeting TS, 7-9 Maret 2012 17
  18. 18. Configure ClusterResources :Primary Linode : Insert perintah berikut di antara baris kedua setelah “node” dengan “property” : primitive apache2 lsb:apache2 op monitor interval="5s" primitive ip1 ocf:heartbeat:IPaddr2 params ip=“44.44.44.44" nic="eth0:0" primitive ip1arp ocf:heartbeat:SendArp params ip=“44.44.44.44" nic="eth0:0" group WebServices ip1 ip1arp apache2 colocation apache_with_ip inf: apache2 ip1 colocation web_with_ip inf: ip1 ip1arp order arp_after_ip inf: ip1:start ip1arp:start order web_after_arp inf: ip1arp:start apache2:start Annual Meeting TS, 7-9 Maret 2012 18
  19. 19. Configure ClusterResources :Primary Linode : Tambahkan “expected-quorum-votes”, “stonith-enabled” dan “no- quorum-policy”, dan jangan lupa menambahkan “” setelah “cluster- infrastructure” sehingga seperti berikut : property $id="cib-bootstrap-options" dc-version="1.0.8-042548a451fce8400660f6031f4da6f0223dd5dd" cluster-infrastructure="Heartbeat" expected-quorum-votes="1" stonith-enabled="false" no-quorum-policy="ignore" Tambahkan baris berikut setelah “property” section : rsc_defaults $id="rsc-options" resource-stickiness="100" Annual Meeting TS, 7-9 Maret 2012 19
  20. 20. Configure ClusterResources :Primary Linode : Konfigurasi komplitnya akan seperti ini : node $id="285a1261-9066-45de-97ac-04b13e5a1f6c" ha1 node $id="b4fbb893-55d6-4a33-81fb-34f8d010df7f" ha2 primitive apache2 lsb:apache2 op monitor interval="5s" primitive ip1 ocf:heartbeat:IPaddr2 params ip=“44.44.44.44" nic="eth0:0" primitive ip1arp ocf:heartbeat:SendArp params ip=“44.44.44.44" nic="eth0:0" group WebServices ip1 ip1arp apache2 colocation apache_with_ip inf: apache2 ip1 colocation web_with_ip inf: ip1 ip1arp order arp_after_ip inf: ip1:start ip1arp:start order web_after_arp inf: ip1arp:start apache2:start property $id="cib-bootstrap-options" dc-version="1.0.8-042548a451fce8400660f6031f4da6f0223dd5dd" cluster-infrastructure="Heartbeat" expected-quorum-votes="1" stonith-enabled="false" no-quorum-policy="ignore" rsc_defaults $id="rsc-options" resource-stickiness="100" Annual Meeting TS, 7-9 Maret 2012 20
  21. 21. Monitor Cluster Resources :Untuk memonitor clusternya gunakan perintah crm_mondan outputnya akan seperti : ============ Last updated: Mon Jun 28 16:59:06 2010 Stack: Heartbeat Current DC: ha2 (b4fbb893-55d6-4a33-81fb-34f8d010df7f) - partition with quorum Version: 1.0.8-042548a451fce8400660f6031f4da6f0223dd5dd 2 Nodes configured, 1 expected votes 1 Resources configured. ============ Online: [ ha1 ha2 ] Resource Group: WebServices ip1 (ocf::heartbeat:IPaddr2): Started ha1 ip1arp (ocf::heartbeat:SendArp): Started ha1 apache2 (lsb:apache2): Started ha1 Annual Meeting TS, 7-9 Maret 2012 21
  22. 22. Monitor Cluster Resources :Untuk memindahkan services ke HA2 gunakan perintah berikut : crm resource move WebServices ha2Sebaliknya untuk mengembalikan services ke HA1 gunakan perintahberikut : crm resource move WebServices ha1 Annual Meeting TS, 7-9 Maret 2012 22

×