DRBD & HEARTBEAT (High Availability Cluster)


Percobaan dilakukan pada virtualbox dengan mencreate 2 oS centos 5.5 32 bit dan mencreate  hardisk virtual di masing-masing node. Untuk kali hanya di testing fungsi dari si heartbeat dan next akan di uraikan lagi secara detail fungsi si DRBD.

Case I
Service yang akan di failover adalah httpd,mysql maka pastikan di kedua server sudah terinstall apache dan pastikan bisa diakses dari jaringan, dalam kasus ini http://192.168.137.200 & http://192.168.137.201

1. Config /etc/hosts

[root@node1 ~]# vim /etc/hosts
127.0.0.1 localhost.localdomain localhost
#::1 localhost6.localdomain6 localhost6
192.168.137.200 node1.intelix.co.id node1
192.168.137.201 node2.intelix.co.id node2

[root@node2~]# vim /etc/hosts
127.0.0.1 localhost.localdomain localhost
#::1 localhost6.localdomain6 localhost6
192.168.137.200 node1.intelix.co.id node1
192.168.137.201 node2.intelix.co.id node2

Config /etc/sysctl.conf


[root@node1 ~]# echo “kernel.hostname = node1” >> /etc/sysctl.conf
[root@node1 ~]# sysctl –p

[root@node2 ~]# echo “kernel.hostname = node2” >> /etc/sysctl.conf
[root@node1 ~]# sysctl -p

2. Paket yang harus di install di kedua node
[root@node1 ]yum -y install heartbeat.i386 OpenIPMI-libs heartbeat-pils.i386 heartbeat-stonith.i386 libnet.i386
[root@node2 ]yum -y install heartbeat.i386 OpenIPMI-libs heartbeat-pils.i386 heartbeat-stonith.i386 libnet.i386

3. File configuration
[root@node1 ~]# cd /usr/share/doc/heartbeat-2.1.4/
[root@node1 heartbeat-2.1.4]# cp authkeys ha.cf haresources /etc/ha.d/
a. authkeys
[root@node1 ha.d]# vim /etc/ha.d/authkeys
Tambahkan isi di baris paling bawah
auth 2
2 sha1 intelix-ha-igc
b. ha.cf
[root@node1 ha.d]# vim /etc/ha.d/ha.cf
logfile /var/log/ha-log
logfacility local0
keepalive 2
deadtime 30
initdead 120
udpport 694
bcast eth0
auto_failback on
node node1
node node2
c. haresources
[root@node1 ha.d]# vim /etc/ha.d/ haresources
node1 192.168.137.100 httpd

4. Copy semua file config /etc/ha.d/ ke node2
[root@node1 ha.d]# cd /etc/ha.d/
[root@node1 ha.d]# scp -r authkeys ha.cf haresources root@192.168.137.201:/etc/ha.d/

5. Rubah configurasi file httpd.conf di kedua node
[root@node1 ~]# vim /etc/httpd/conf/httpd.conf
Option Listen harus dalam format sbb:
Listen 192.168.137.100:80

[root@node2 ~]# vim /etc/httpd/conf/httpd.conf
Option Listen harus dalam format sbb:
Listen 192.168.137.100:80

6. Stop service httpd dengan menggunakan command “chkconfig” sehingga ketika boot service itu tidak “up”
[root@node1 ~]# chkconfig httpd off
[root@node2~]# chkconfig httpd off

7. Restart Service heartbeat di kedua node
[root@node1 ~]# /etc/init.d/heartbeat start
Starting High-Availability services:
2011/11/03_20:57:00 INFO: Resource is stopped
[ OK ]

[root@node2 ~]# /etc/init.d/heartbeat stop
Stopping High-Availability services:
[ OK ]

[root@node2 ~]# /etc/init.d/heartbeat start
Starting High-Availability services:
2011/11/03_20:57:42 INFO: Resource is stopped

8. Pengujian
Untuk menguji apakah system yang sudah di setup berjalan dengan benar maka buka masing-masing 3 terminal untuk node1 dan node2

Node 1
Terminal 1
[root@node1 ~]# echo “node01 apache test server” > /var/www/html/index.html
Terminal 2
[root@node1~]# tail –f /var/log/ha-log
Terminal 3
[root@node1~]# for i in `seq 1 199`; do ifconfig eth0:0; sleep 5; done

Node2
[root@node2 ~]# echo “node02 apache test server” > /var/www/html/index.html
Terminal 2
[root@node2~]# tail –f /var/log/ha-log
Terminal 3
[root@node2~]# for i in `seq 1 199`; do ifconfig eth0:0; sleep 5; done

Buka url via browser , http://192.168.137.100/
Maka jika muncul tulisan “node01 apache test server” maka config anda sudah benar

Stop service heartbeat di node1 dan amati masing-masing log + status eth0:0 di terminal masing-masing node
[root@node1~]# /etc/init.d/heartbeat stop
Buka kembali url http://192.168.137.100/
Maka jika muncul tulisan “node02 apache test server” maka config anda sudah benar

Start Service hearbeat di node1
[root@node1~]# /etc/init.d/heartbeat start
Buka kembali url http://192.168.137.100/
Maka jika muncul tulisan “node01 apache test server” maka config anda sudah benar berjalan 100%

MYSQL
Untuk mengimplementasikan di mysql maka pastikan di masing-masing node sudah terinstall msysql. Caranya adalah sbb:

1. Edit file /etc/ha.d/resources di node1 & node2
Sebelum
[root@node1 ]# vim /etc/ha.d/ haresources
node1 192.168.137.100 httpd

Sesudah
[root@node1d]# vim /etc/ha.d/ haresources
node1 192.168.137.100 httpd mysqld

2. Stop runlevel service mysql sehingga tidak up ketika boot

[root@node1 ]# chkconfig mysqld off
[root@node2 ]# chkconfig mysqld off

3. Restart Service heartbeat
[root@node1 ]# /etc/init.d/heartbeat restart
[root@node2 ]# /etc/init.d/heartbeat restart

4. Grant privilege di node1 sehingga bisa di remote via mysqlyog or front
[root@node1 ]# mysql -uroot –p
enter
mysql> select user,password,host from user;
mysql> update user set user=’root’,host=’%’ where user=” and host=’localhost’;
mysql> flush privileges;
mysql> exit;

5. Stop service hearbeat di node1
[root@node1 ]# /etc/init.d/heartbeat stop

6. Grant privilege di node2 sehingga bisa di remote via mysqlyog or front
[root@node2 ]# mysql -uroot –p
enter
mysql> select user,password,host from user;
mysql> update user set user=’root’,host=’%’ where user=” and host=’localhost’;
mysql> flush privileges;
mysql> exit;

7. Start Service heartbeat di node1
[root@node1 ]# /etc/init.d/heartbeat start

8. Akses ip 192.168.137.100 via mysqlfront or mysqlyog dan create 1 database
9. Stop Service heartbeat di node1
10. Akses ip 192.168.137.100 via mysqlfront or mysqlyog dan harusnya masih tetap ada nanum database yang anda create sebelumnya tidak akan muncul , itu disebabkan belum ada syncronisasi data antar node. Nah agar data tetap ada maka diperlukanlah :

“Si -DRBD(Distributed Replicated Block Device)”

Tampilan drbd.conf yang menggunakan lvm (/dev/vgdata/lvdata)

drbd.conf

ASTERISK

Bagaimana dengan service yang lain seperti ssh, asterisk,ecentrix???? Mari kita coba bersama dan persiapkan alat-alat yang kita butuhkan untuk mensimulasikan sesuai dengan “dilapangan”

Created by moses tambunan

http://dev.centos.org/centos/5/testing/i386/RPMS/

Advertisements

One thought on “DRBD & HEARTBEAT (High Availability Cluster)

  1. no_unplag November 12, 2011 at 2:50 pm Reply

    mantap bangat buat guru opensource….

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

shisdew

Listens until think alike

moses.spaceku@yahoo.com / voip ipbx

Hosted PBX, IP-PBX SOHO/ CALL CENTER, VOICE GATEWAY, VOICE CARD, COST EFECTIVE SOLUTIONS (LCR), GSM/CDMA GATEWAY

%d bloggers like this: