Heartbeat Version2 with DRBD
DRBD + Heartbeat version2
OS = centos5
Kernel version = 2.6.9-55.EL
DRBD version = v0.7
Heartbeat version = v2
Cluster Nodes = 3
Apache service
=========================
Node1 = Active
– Disk = 8G
– Partition
/dev/sdb1 = meta device 1024M
/dev/sdb2 = resource
– IP address
210.220.224.151
210.220.224.153
Node2 = Passive
– Disk = 8G
– Partition
/dev/sdb1 = meta device 1024M
/dev/sdb2 = resource
– IP address
210.220.224.152
210.220.224.154
Mysql service
=========================
Node2 = Active
– Disk = 8G
– Partition
/dev/sdb1 = meta device 1024M
/dev/sdb2 = resource
– IP address
210.220.224.152
210.220.224.154
Node1 = Passive
– Disk = 8G
– Partition
/dev/sdb1 = meta device 1024M
/dev/sdb2 = resource
– IP address
210.220.224.151
210.220.224.153
Install Sequence
========================
1. DRBD
2. Kernel Module(DRBD)
3. Libnet
4. Heartbeat
– heartbeat-pils
– OpenIPMI / devel
– openhpi / devel
– heartbeat-stonith
– heartbeat
– heartbeat-gui
Special Setting
=======================
1. Heartbeat GUI used.. = GUI를 이용하려면 hacluster 유저의 패스워드를 지정한다.
1. DRBD 설정
==============================================================================================
>>Node2 도 동일한 작업을 해주고, 마지막에 ‘rsc’자원을 ‘Primary’로 설정하면 된다.
// #drbdsetup /dev/drbd1 primary –do-what-I-say
>>Node1
# vi /etc/drbd.conf
# ‘drbd0’ is the identifier of this drbd instance. You will need it to configure the resource
# in the CIB correctly. This name is arbitrary, but I chose to name it after the device node.
resource app {
protocol C;
incon-degr-cmd “echo ‘!DRBD! pri on incon-degr’ | wall ; sleep 60 ; halt -f”;
startup {
degr-wfc-timeout 120; # 2 minutes.
}
disk {
on-io-error pass_on;
}
net {
# TODO: Should these timeouts be relative to some heartbeat settings?
# timeout 60; # 6 seconds (unit = 0.1 seconds)
# connect-int 10; # 10 seconds (unit = 1 second)
# ping-int 10; # 10 seconds (unit = 1 second)
on-disconnect reconnect;
}
syncer {
rate 100M;
group 1;
al-extents 257;
}
on Node1 {
device /dev/drbd0;
disk /dev/sdb2;
address 210.220.224.151:7789;
meta-disk /dev/sdb1[0];
}
on Node2 {
device /dev/drbd0;
disk /dev/sdb2;
address 210.220.224.152:7789;
meta-disk /dev/sdb1[0];
}
}
resource rsc {
protocol C;
incon-degr-cmd “echo ‘!DRBD! pri on incon-degr’ | wall ; sleep 60 ; halt -f”;
startup {
degr-wfc-timeout 120; # 2 minutes.
}
disk {
on-io-error pass_on;
}
net {
# TODO: Should these timeouts be relative to some heartbeat settings?
# timeout 60; # 6 seconds (unit = 0.1 seconds)
# connect-int 10; # 10 seconds (unit = 1 second)
# ping-int 10; # 10 seconds (unit = 1 second)
on-disconnect reconnect;
}
syncer {
rate 100M;
group 1;
al-extents 257;
}
on Node1 {
device /dev/drbd1;
disk /dev/sdc2;
address 210.220.224.151:7788;
meta-disk /dev/sdc1[0];
}
on Node2 {
device /dev/drbd1;
disk /dev/sdc2;
address 210.220.224.152:7788;
meta-disk /dev/sdc1[0];
}
}
# drbdadm -d adjust app
drbdsetup /dev/drbd0 disk /dev/sdb2 /dev/sdb1 1 –on-io-error=detach
drbdsetup /dev/drbd0 syncer –rate=60M –group=1 –al-extents=257
drbdsetup /dev/drbd0 net 210.220.224.152:7789 210.220.224.151:7789 C
# drbdadm -d adjust rsc
# drbd adjust app
# drbd adjust rsc
# drbdsetup /dev/drbd0 primary –do-what-I-say
version: 0.7.23 (api:79/proto:74)
SVN Revision: 2686 build by buildcentos@build-i386, 2007-05-23 09:30:50
0: cs:Connected st:Secondary/Primary ld:Consistent
ns:1216 nr:39260 dw:40476 dr:9845 al:6 bm:2355 lo:0 pe:0 ua:0 ap:0
1: cs:Connected st:Primary/Secondary ld:Consistent
ns:210200 nr:4524 dw:214724 dr:70572 al:83 bm:1200 lo:0 pe:0 ua:0 ap:0
2. 파일시스템 생성 및 Apache 설치
==============================================================================================
>>Node2 에서는 ‘drbd1’에 파일시스템을 생성하고 Mysql을 설치하면 된다.
>>Node1
# mkfs -j /dev/drbd0
mke2fs 1.35 (28-Feb-2004)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
922944 inodes, 1845466 blocks
92273 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1891631104
57 block groups
32768 blocks per group, 32768 fragments per group
16192 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632
Writing inode tables: done
Creating journal (8192 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 24 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
# tune2fs -c -1 -i 0 /dev/drbd0
tune2fs 1.35 (28-Feb-2004)
Setting maximal mount count to -1
Setting interval between check 0 seconds
# mkdir /APP
# mount /dev/drbd0 /APP
# cd /SRC/httpd-2.0.59
# vi conf
./configure –prefix=/APP/apache \\
–enable-modules=so \\
–enable-so \\
–enable-rule=SHARED_CODE \\
–enable-file-cache \\
–enable-cache \\
–enable-disk-cache \\
–enable-headers \\
–enable-mods-shared=most
# sh conf
# make && make install
3. Heartbeat Version 2 설정
==============================================================================================
>>Node1 & Node2 동일하게 설정.
# cp /usr/share/doc/heartbeat-2.1.2/authkeys /etc/ha.d/
# cp /usr/share/doc/heartbeat-2.1.2/ha.cf /etc/ha.d/
# vi /etc/ha.d/ha.cf
debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility local0
keepalive 2
deadtime 30
udpport 694
ucast eth0 210.220.224.152
auto_failback off
node Node1
node Node2
apiauth stonithd uid=root
respawn root /usr/lib/heartbeat/stonithd
apiauth cibmon uid=hacluster
respawn hacluster /usr/lib/heartbeat/cibmon -d
crm on
# vi /etc/ha.d/authkeys
auth 1
1 crc
# chmod 600 /etc/ha.d/authkeys
4. HA GUI를 통한 Configuration
==============================================================================================
>>Node1
// ‘X 환경에서 실행한다.’
// Node1 + Node2 : # service heartbeat start
Node1 /RSC Mysql
/DRBD1
210.220.224.154
Node2 /APP Apache
/DRBD0
210.220.224.153
# hb_gui &
최종 셋팅
********************************************************************************************
+ linux-ha
+ Nodes
+ Node2
+ Node1
+ Resources
+ group_APP resouce_stickness ‘0’
– resource_IP1
ip 210.220.224.153
nic eth0
– resource_DRBD0
1 app
– resource_FS_APP
fstype ext3
device /dev/drbd0
directory /APP
– resource_Apache
configfile /APP/apache/conf/httpd.conf
httpd /APP/apache/bin/httpd
monitor interval(10) timeout(20) startdelay(0) disabled(false) role prereq on fail
+ group_RSC resouce_stickness ‘0’
– resource_IP2
ip 210.220.224.154
nic eth0
– resource_DRBD1
1 rsc
– resource_FS_RSC
fstype ext3
device /dev/drbd1
directory /RSC
– resource_Mysql
binary /RSC/mysql/bin/mysqld_safe
conffig /etc/my.cnf
user mysql
group mysql
monitor interval(10) timeout(20) startdelay(0) disabled(false) role prereq on fail
+ Constraints
+ Place
– place_Node1 #uname eq Node2
– place_Node2 #uname eq Node1
********************************************************************************************
>> 아파치 자원을 ‘LSB’타입으로 실행하고자 하는 경우..
‘group_APP’의 ‘resouce_Apache’는 ‘ocf’타입으로 설정했으며, 이것을 ‘lsb’타입으로 사용하고자
할 경우에는 다음과 같이 한다.
1. 아파치의 ‘LSB’타입 스크립트로 아파치 프로세스가 정상적으로 동작하는지 확인한다.
# cp /APP/apache/bin/apachectl /etc/init.d/httpd
# service httpd start
# service httpd status
2. 다음의 순서로 아파치관련 자원을 ‘LSB’타입으로 생성한다.
+ ‘Add New Item’
– Resource ID : resource_Apache
– Belong to Group : group_APP
– Type
httpd lsb httpd
//이 스크립트의 위치는 ‘/etc/init.d/’ 디렉토리 안에 존재해야 한다.
3. ‘hb_gui’ 화면에서 위에서 생성한 자원을 동작시킨다.
4. 정상적으로 아파치가 동작하면 아파치 프로세스를 모니터링하는 ‘Operations’를 추가한다.
# vi /APP/apache/conf/httpd.conf
…
SetHandler server-status
Order allow,deny
Allow from all
– resource_Apache
– Operations
Name : Monitor
Interval : 10
Timeout : 15
Disabled : false
Name Description Interval Timeout Start Delay Disabled Role Prereq On Fail
=================================================================================================
Monitor 10 15 0 false Started
5. 모니터링 관련 ‘Operations’를 추가한 뒤에 아파치 서비스를 중지시키고 지정된 시간내에 아파치 프로세스가
정상적으로 재시작 되는지 확인한다.
>> Mysql 자원을 ‘LSB’타입으로 실행하고자 하는 경우..
‘group_RSC’의 ‘resouce_Mysql’는 ‘ocf’타입으로 설정했으며, 이것을 ‘lsb’타입으로 사용하고자
할 경우에는 다음과 같이 한다.
1. Mysql의 ‘LSB’타입 스크립트로 아파치 프로세스가 정상적으로 동작하는지 확인한다.
# cp /RSC/mysql/share/mysql/mysql.server /etc/init.d/mysqld
# service mysqld start
# service mysqld status
2. 다음의 순서로 Mysql관련 자원을 ‘LSB’타입으로 생성한다.
+ ‘Add New Item’
– Resource ID : resource_Mysql
– Belong to Group : group_RSC
– Type
mysqld lsb mysqld
//이 스크립트의 위치는 ‘/etc/init.d/’ 디렉토리 안에 존재해야 한다.
3. ‘hb_gui’ 화면에서 위에서 생성한 자원을 동작시킨다.
4. 정상적으로 Mysql이 동작하면 아파치 프로세스를 모니터링하는 ‘Operations’를 추가한다.
– resource_Mysql
– Operations
Name : Monitor
Interval : 10
Timeout : 15
Disabled : false
Name Description Interval Timeout Start Delay Disabled Role Prereq On Fail
=================================================================================================
Monitor 10 15 0 false Started
5. 모니터링 관련 ‘Operations’를 추가한 뒤에 아파치 서비스를 중지시키고 지정된 시간내에 Mysql 프로세스가 정상적으로 재시작 되는지 확인한다.
2 Responses
… [Trackback]
[…] Find More on to that Topic: nblog.syszone.co.kr/archives/3018 […]
… [Trackback]
[…] Read More Information here to that Topic: nblog.syszone.co.kr/archives/3018 […]