Download - High Availability Server with DRBD in linux
![Page 1: High Availability Server with DRBD in linux](https://reader036.vdocument.in/reader036/viewer/2022081412/54109b028d7f72dd328b4585/html5/thumbnails/1.jpg)
1
HIGH AVAILABILITY WEBSITEWith IP Failover, Heartbeat, Pacemaker on Ubuntu Server
Presented by Ali Rachman
Annual Meeting TS, 7-9 Maret 2012
![Page 2: High Availability Server with DRBD in linux](https://reader036.vdocument.in/reader036/viewer/2022081412/54109b028d7f72dd328b4585/html5/thumbnails/2.jpg)
2Annual Meeting TS, 7-9 Maret 2012
High Availability
High Availability mengacu kepada suatu praktek untuk menjaga agar resource yang ada tetap online atau tersedia karena disebabkan oleh kegagalan suatu node atau sistem
Panduan kali ini, menunjukkan suatu metode untuk menggunakan dua linode untuk menjaga suatu website tetap online. Bahkan ketika node primary dimatikan.
Pada prakteknya, akan menggunakan metode IP Failover, Heartbeat, Pacemaker dan Apache
![Page 3: High Availability Server with DRBD in linux](https://reader036.vdocument.in/reader036/viewer/2022081412/54109b028d7f72dd328b4585/html5/thumbnails/3.jpg)
3Annual Meeting TS, 7-9 Maret 2012
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
![Page 4: High Availability Server with DRBD in linux](https://reader036.vdocument.in/reader036/viewer/2022081412/54109b028d7f72dd328b4585/html5/thumbnails/4.jpg)
4Annual Meeting TS, 7-9 Maret 2012
Terminology :
1. Basic system configuration2. Assign Static IP Address3. Install require Packages4. Configure Apache 25. Configure Heartbeat6. Configure Cluster Resources7. Monitor Cluster Resource
![Page 5: High Availability Server with DRBD in linux](https://reader036.vdocument.in/reader036/viewer/2022081412/54109b028d7f72dd328b4585/html5/thumbnails/5.jpg)
5Annual Meeting TS, 7-9 Maret 2012
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” IP 6. 4321 password untuk authentifikasi7. Tes.ams.id contoh website yang akan di bangun
![Page 6: High Availability Server with DRBD in linux](https://reader036.vdocument.in/reader036/viewer/2022081412/54109b028d7f72dd328b4585/html5/thumbnails/6.jpg)
6Annual Meeting TS, 7-9 Maret 2012
Basic System Configuration :Login dengan ssh ke primary linode
Edit /etc/hosts dan isi sesuai di bawah :
127.0.0.1 localhost.localdomain localhost12.34.56.78 ha1.ams.id ha198.76.54.32 ha2.ams.id ha2
![Page 7: High Availability Server with DRBD in linux](https://reader036.vdocument.in/reader036/viewer/2022081412/54109b028d7f72dd328b4585/html5/thumbnails/7.jpg)
7Annual Meeting TS, 7-9 Maret 2012
Basic System Configuration :Ssh host key syncronization
Ssh host key syncronization ini digunakan untuk mensinkronisasikan login antar dua linode yang berbeda
ssh-keygen -t rsascp ~/.ssh/id_rsa.pub root@ha2:/root/ha1_key.pubssh 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 /rootcat ~/id_rsa.pub >> ~/.ssh/authorized_keys2rm ~/id_rsa.pub scp /etc/ssh/ssh_host* root@ha2:/etc/ssh/rm ~/.ssh/known_hostsssh root@ha2 "/etc/init.d/ssh restart" scp /etc/hosts root@ha2:/etc/hostsecho "ha1" > /etc/hostnamehostname -F /etc/hostnamessh root@ha2 "echo \"ha2\" > /etc/hostname"ssh root@ha2 "hostname -F /etc/hostname"
Lakukan hal berikut dari primary linode :
![Page 8: High Availability Server with DRBD in linux](https://reader036.vdocument.in/reader036/viewer/2022081412/54109b028d7f72dd328b4585/html5/thumbnails/8.jpg)
8Annual Meeting TS, 7-9 Maret 2012
Assign Static IP Address :Primary Linode :
Edit /etc/network/interfaces :
auto loiface lo inet loopback auto eth0iface eth0 inet staticaddress 12.34.56.78netmask 255.255.255.0gateway 12.34.56.1
/etc/init.d/networking restartSecondary Linode :
Edit /etc/network/interfaces :
auto loiface lo inet loopback auto eth0iface eth0 inet staticaddress 98.76.54.32netmask 255.255.255.0gateway 09.76.54.1
/etc/init.d/networking restart
![Page 9: High Availability Server with DRBD in linux](https://reader036.vdocument.in/reader036/viewer/2022081412/54109b028d7f72dd328b4585/html5/thumbnails/9.jpg)
9Annual Meeting TS, 7-9 Maret 2012
Install Required Packages :Primary Linode :
apt-get updateapt-get upgradeapt-get install heartbeat pacemaker apache2/etc/init.d/apache2 stopupdate-rc.d -f apache2 removemkdir -p /srv/www/ams.id/tes/public_htmlmkdir /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"
![Page 10: High Availability Server with DRBD in linux](https://reader036.vdocument.in/reader036/viewer/2022081412/54109b028d7f72dd328b4585/html5/thumbnails/10.jpg)
10Annual Meeting TS, 7-9 Maret 2012
Configure Apache2 :Primary Linode :
NameVirtualHost 44.44.44.44:80Listen 80
Edit /etc/apache2/ports.conf :
Buat 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 [email protected] 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>
![Page 11: High Availability Server with DRBD in linux](https://reader036.vdocument.in/reader036/viewer/2022081412/54109b028d7f72dd328b4585/html5/thumbnails/11.jpg)
11Annual Meeting TS, 7-9 Maret 2012
Configure Apache2 :Primary Linode :
<VirtualHost 44.44.44.44:80> ServerAdmin [email protected] 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>
Lakukan perintah berikut :
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>
![Page 12: High Availability Server with DRBD in linux](https://reader036.vdocument.in/reader036/viewer/2022081412/54109b028d7f72dd328b4585/html5/thumbnails/12.jpg)
12Annual Meeting TS, 7-9 Maret 2012
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.idssh root@ha2 "a2ensite tes.ams.id"
![Page 13: High Availability Server with DRBD in linux](https://reader036.vdocument.in/reader036/viewer/2022081412/54109b028d7f72dd328b4585/html5/thumbnails/13.jpg)
13Annual Meeting TS, 7-9 Maret 2012
Configure Heartbeat :Primary Linode :
Edit /etc/heartbeat/ha.cf :
logfacility daemonkeepalive 2deadtime 15warntime 5initdead 120udpport 694ucast eth0 98.76.54.32auto_failback onnode ha1node ha2use_logd yescrm respawn
![Page 14: High Availability Server with DRBD in linux](https://reader036.vdocument.in/reader036/viewer/2022081412/54109b028d7f72dd328b4585/html5/thumbnails/14.jpg)
14Annual Meeting TS, 7-9 Maret 2012
Configure Heartbeat :Secondary Linode :
Edit /etc/heartbeat/ha.cf :
logfacility daemonkeepalive 2deadtime 15warntime 5initdead 120udpport 694ucast eth0 12.34.56.78auto_failback onnode ha1node ha2use_logd yescrm respawn
![Page 15: High Availability Server with DRBD in linux](https://reader036.vdocument.in/reader036/viewer/2022081412/54109b028d7f72dd328b4585/html5/thumbnails/15.jpg)
15Annual Meeting TS, 7-9 Maret 2012
Configure Heartbeat :Primary Linode :
Edit /etc/heartbeat/authkeys :
auth 11 sha1 4321
Lakukan perintah berikut :
chmod 600 /etc/ha.d/authkeys/etc/init.d/heartbeat startscp /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"
![Page 16: High Availability Server with DRBD in linux](https://reader036.vdocument.in/reader036/viewer/2022081412/54109b028d7f72dd328b4585/html5/thumbnails/16.jpg)
16Annual Meeting TS, 7-9 Maret 2012
Configure Cluster Resources :Primary Linode :
Lakukan perintah berikut :
export EDITOR=/bin/nanoecho "export EDITOR=/bin/nano" >> .bashrc
Secondary Linode :
Lakukan perintah berikut :
export EDITOR=/bin/nanoecho "export EDITOR=/bin/nano" >> .bashrc
![Page 17: High Availability Server with DRBD in linux](https://reader036.vdocument.in/reader036/viewer/2022081412/54109b028d7f72dd328b4585/html5/thumbnails/17.jpg)
17Annual Meeting TS, 7-9 Maret 2012
Configure Cluster Resources :Primary Linode :
Lakukan perintah berikut :
crm configure edit
Akan tampil seperti berikut :
node $id="285a1261-9066-45de-97ac-04b13e5a1f6c" ha1node $id="b4fbb893-55d6-4a33-81fb-34f8d010df7f" ha2property $id="cib-bootstrap-options" \ dc-version="1.0.8-042548a451fce8400660f6031f4da6f0223dd5dd" \ cluster-infrastructure="Heartbeat"
![Page 18: High Availability Server with DRBD in linux](https://reader036.vdocument.in/reader036/viewer/2022081412/54109b028d7f72dd328b4585/html5/thumbnails/18.jpg)
18Annual Meeting TS, 7-9 Maret 2012
Configure Cluster Resources :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 apache2colocation apache_with_ip inf: apache2 ip1colocation web_with_ip inf: ip1 ip1arporder arp_after_ip inf: ip1:start ip1arp:startorder web_after_arp inf: ip1arp:start apache2:start
![Page 19: High Availability Server with DRBD in linux](https://reader036.vdocument.in/reader036/viewer/2022081412/54109b028d7f72dd328b4585/html5/thumbnails/19.jpg)
19Annual Meeting TS, 7-9 Maret 2012
Configure Cluster Resources :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"
![Page 20: High Availability Server with DRBD in linux](https://reader036.vdocument.in/reader036/viewer/2022081412/54109b028d7f72dd328b4585/html5/thumbnails/20.jpg)
20Annual Meeting TS, 7-9 Maret 2012
Configure Cluster Resources :Primary Linode :
Konfigurasi komplitnya akan seperti ini :
node $id="285a1261-9066-45de-97ac-04b13e5a1f6c" ha1node $id="b4fbb893-55d6-4a33-81fb-34f8d010df7f" ha2primitive 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 apache2colocation apache_with_ip inf: apache2 ip1colocation web_with_ip inf: ip1 ip1arporder arp_after_ip inf: ip1:start ip1arp:startorder 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"
![Page 21: High Availability Server with DRBD in linux](https://reader036.vdocument.in/reader036/viewer/2022081412/54109b028d7f72dd328b4585/html5/thumbnails/21.jpg)
21Annual Meeting TS, 7-9 Maret 2012
Monitor Cluster Resources :Untuk memonitor clusternya gunakan perintah crm_mon dan outputnya akan seperti :
============Last updated: Mon Jun 28 16:59:06 2010Stack: HeartbeatCurrent DC: ha2 (b4fbb893-55d6-4a33-81fb-34f8d010df7f) - partition with quorumVersion: 1.0.8-042548a451fce8400660f6031f4da6f0223dd5dd2 Nodes configured, 1 expected votes1 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
![Page 22: High Availability Server with DRBD in linux](https://reader036.vdocument.in/reader036/viewer/2022081412/54109b028d7f72dd328b4585/html5/thumbnails/22.jpg)
22Annual Meeting TS, 7-9 Maret 2012
Monitor Cluster Resources :Untuk memindahkan services ke HA2 gunakan perintah berikut :
crm resource move WebServices ha2
Sebaliknya untuk mengembalikan services ke HA1 gunakan perintah berikut :
crm resource move WebServices ha1