Thursday, January 19, 2012

Cluster Ubuntu - DRBD

Before I start sharing my knowledge here, I would like to give my best reward to Bro John who teach me and sis salina.. :)

Hoyeee... let start writing..

What is cluster.. ???
A group of the same or similar elements gathered or occurring closely together.

Why need cluster..
Because it is for backup purposes and will reduce the possibility for a site to down since the both server are working together.


update the package
#apt-get update

Untuk install cluster, kena ada 2 server at least... Kalu nk buat all the steps... Make sure do it the both server for each step before go to another step :

1. Install apache2
#apt-get install apache2
-> check idup ke tk -> pi browser //ip

2. Install php5
#apt-get install php5

3. Install libapache2-mod-php5

4. Restart Apache
#/etc/init.d/apache2 restart

5. Check package info
#dpkg --get-selection

6. Install php extension
#apt-get -y install php5-cli php5-common php5... etc
-y untuk dia terus pilih yes..
tambah jerk php extension yang lain untuk install serentak


Untuk Present Hardisk
pi kat vmware - add hardisk
7. #fdisk -l
kalau tak jumpa #reboot

8. Install drbd
#apt-get install drbd8-utils
check samada yang nih yang paling update kat web dia atau browsing pasal drbd

9. nano /etc/drbd.conf

- install drbd file refer here http://dev.mysql.com/doc/mysql-ha-scalability/en/ha-drbd-install-drbd.html

- now ubuntu 10.04 using only this apt-get install drbd8-utils
example on drbd.conf :

global {
usage-count no;
}
resource r0 {
protocol C;
startup {
become-primary-on both;
}
net {
allow-two-primaries;
cram-hmac-alg "sha1";
shared-secret "k3n4Tuk4r";
after-sb-0pri discard-least-changes;
after-sb-1pri violently-as0p;
after-sb-2pri violently-as0p;
rr-conflict violently;
}
syncer {
verify-alg md5;
al-extents 257;
rate 40M;
}

on pm-vst-drbd01 {
device /dev/drbd0;
disk /dev/sdb;
address 172.18.33.33:7788;
flexible-meta-disk internal;
}

on pm-vst-drbd02 {
device /dev/drbd0;
disk /dev/sdb;
address 172. 18.33.34:7788;
flexible-meta-disk internal;
}
}

10. Install OCFS (Oracle Cluster Site System)
#apt-get -y install ocfs2-tools ocfs2console
create folder ocfs2 and touch cluster.conf inside the folder

example :

#nano /etc/ocfs2/cluster.conf
cluster:
node_count = 2
name = mysqlocfs

node:
ip_port = 7777
ip_address = 172.18.33.33
number = 0
name = pm-vst-drbd01
cluster = mysqlocfs
node:
ip_port = 7777
ip_address = 172. 18.33.34
number = 1
name = pm-vst-drbd02
cluster = mysqlocfs

11. Check status ocfs2
#/etc/init.d/o2cb status

12. add HDD to each server and reboot the server to detect the HDD but do not format it just leave it.

13. Run OCFS
#dpkg-reconfigure -p medium -f readline ocfs2-tools

example :
Would you like to start an OCFS2 cluster (O2CB) at boot time? yes
Name of the cluster to start at boot time: ocfs2
The O2CB heartbeat threshold sets up the maximum time in seconds that a node
awaits for an I/O operation. After it, the node "fences" itself, and you will
probably see a crash.

It is calculated as the result of: (threshold - 1) x 2.

Its default value is 31 (60 seconds).

Raise it if you have slow disks and/or crashes with kernel messages like:

o2hb_write_timeout: 164 ERROR: heartbeat write timeout to device XXXX after NNNN
milliseconds
O2CB Heartbeat threshold: 31
Loading filesystem "configfs": OK
Mounting configfs filesystem at /sys/kernel/config: OK
Loading stack plugin "o2cb": OK
Loading filesystem "ocfs2_dlmfs": OK
Mounting ocfs2_dlmfs filesystem at /dlm: OK
Setting cluster stack "o2cb": OK
Starting O2CB cluster ocfs2: OK

14. Buat DRBD partition
#drbdadm create-md all
- run drbdadm create-md all (If you see error please check your drbd.conf and edit disk conf. Make sure you have invalid HDD path)

15. Start DRBD
#/etc/init.d/drbd start -> yang nih kena buat serentak utk dua2 server.. sbb nnti dia akan cari yang lg satu

16. Overwrite data
#drbdadm -- --overwrite-data-of-peer primary all

17.Format hardisk (p/s: JANGAN BUAT SERENTAK.. buat satu2... !!!!!!!!!!)
#mkfs -t ocfs2 -N 2 -L ocfs2_drbd0 /dev/drbd0
- create drbd filesystem mkfs.ext3 /dev/drbd0 or mkfs -t ocfs2 -N 2 -L ocfs2_drbd0 /dev/drbd0

18. ada lg step... to be continued.. :)












No comments:

Post a Comment