우분투 10.04 || Heartbeat 소스 컴파일

 설치 환경 및 버전  

본 글은 Virtualbox 버전 4.1.0 에 우분투를 설치하여 테스트한 내용이다. 

운영체제 : 우분투 10.04
Heartbeat : 3.0.2
cluster-agent : 1.0.3
cluster-glue : 1.0.5

 소스 구하기  

$ wget http://hg.linux-ha.org/dev/archive/STABLE-3.0.2.tar.bz2
$ wget http://hg.linux-ha.org/glue/archive/glue-1.0.5.tar.bz2
$ sudo apt-get source cluster-agents

부득이하게 cluster-agents는 우분투 10.04 에서 apt-get 명령을 사용하여 다운로드 하였다.

소스파일 :
cfile8.uf.147A90494F4AFEF71C0608.bz2cfile2.uf.167259494F4AFEF62EB390.gzcfile29.uf.1106C1494F4AFEF605D313.bz2

 Heartbeat compile  

필요 패키지 설치

$ sudo apt-get install build-essential automake mercurial libglib2.0-dev libxml2-dev libbz2-dev
$ sudo apt-get build-dep btrfs-tools
$ sudo apt-get build-dep pacemaker

glib 소스 버그 수정

$ vi /usr/include/glib-2.0/glib/gatomic.h

다음 소스 코드에서 ‘-‘ 마이너스 부분의 소스라인을 ‘+’ 플러스 부분의 소스라인으로 대체

 #else
 # define g_atomic_int_get(atomic) \
  ((void) sizeof (gchar [sizeof (*(atomic)) == sizeof (gint) ? 1 : -1]), \
–  (g_atomic_int_get) ((volatile gint G_GNUC_MAY_ALIAS *) (void *) (atomic)))
+  (g_atomic_int_get) ((volatile gint G_GNUC_MAY_ALIAS *) (volatile void *) (atomic)))
 # define g_atomic_int_set(atomic, newval) \
  ((void) sizeof (gchar [sizeof (*(atomic)) == sizeof (gint) ? 1 : -1]), \
–  (g_atomic_int_set) ((volatile gint G_GNUC_MAY_ALIAS *) (void *) (atomic), (newval)))
+  (g_atomic_int_set) ((volatile gint G_GNUC_MAY_ALIAS *) (volatile void *) (atomic), (newval)))
 # define g_atomic_pointer_get(atomic) \
  ((void) sizeof (gchar [sizeof (*(atomic)) == sizeof (gpointer) ? 1 : -1]), \
–  (g_atomic_pointer_get) ((volatile gpointer G_GNUC_MAY_ALIAS *) (void *) (atomic)))
+  (g_atomic_pointer_get) ((volatile gpointer G_GNUC_MAY_ALIAS *) (volatile void *) (atomic)))
 # define g_atomic_pointer_set(atomic, newval) \
  ((void) sizeof (gchar [sizeof (*(atomic)) == sizeof (gpointer) ? 1 : -1]), \
–  (g_atomic_pointer_set) ((volatile gpointer G_GNUC_MAY_ALIAS *) (void *) (atomic), (newval)))
+  (g_atomic_pointer_set) ((volatile gpointer G_GNUC_MAY_ALIAS *) (volatile void *) (atomic), (newval)))

heartbeat 계정 등록 및 작업 디렉토리 생성

heartbeat 프로그램이 사용하는 그룹과 계정을 등록

$ groupadd -r haclient
$ useradd -g haclient -r -d /usr/lib/heartbeat -s /bin/false hacluster
$ mkdir /root/heartbeat

Cluster-glue compile

$ tar xjf glue-1.0.5.tar.bz2
$ cd Reusable-Cluster-Components-glue–glue-1.0.5

$ ./autogen.sh
$ ./configure –prefix=/root/heartbeat/
$ vi Makefile
– 314 line, doc 텍스트 제거

$ make && make install

Cluster-agent compile

$ tar xzf cluster-agents_1.0.3.orig.tar.gz
$ cd Cluster-Resource-Agents-agents-1.0.3

$ ./autogen.sh
$ ./configure –prefix=/root/heartbeat/
$ vi Makefile
– 265 line, doc 텍스트 제거

$ make && make install  

Heartbeat compile

$ tar xjf STABLE-3.0.2.tar.bz2
$ cd Heartbeat-3-0-STABLE-3.0.2

$ ./bootstrap.sh
$ ./configure –prefix=/root/heartbeat/
$ vi Makefile
– 397 line, doc 텍스트 제거

$ make && make install

 Heartbeat 환경 설정  

authkeys

$ cd /root/heartbeat/etc/ha.d/
$ vi authkeys

auth 1
1 md5 Hello!

$ chmod 600 authkeys

ha.cf

$ cd /root/heartbeat/etc/ha.d/
$ vi ha.cf

debugfile /var/log/ha-debug
logfile /var/log/ha-log
logfacility     local0
keepalive 2
deadtime 5
warntime 10
initdead 10
udpport 694
bcast   eth0            # Linux
auto_failback on
node    node1
node    node2
uuidfrom nodename

 

keepalive : 두 노드간에 얼마나 자주 heartbeat를 주고 받을 것인가 설정 (sec 단위)
deadtime : 서버가 죽었다고 판단하는 시간 설정 (sec 단위)
initdead : 서버 시작후 대기 시간 (sec 단위)
udpport : heartbeat 를 보내기 위한 통신 포트
bcast : heartbeat를 보낼 NIC 설정
auto_failback : Fail over를 사용할지 여부
node : 마스터 서버 노드 이름(hostname)
node : 슬레이브 서버 노드 이름(hostnmae)
– 적힌 순서로 마스터와 슬레이브를 구분
uuidfrom :  uuid가 중복되어 오류가 생기는 경우 nodename으로 설정

 

haresources

$ cd /root/heartbeat/etc/ha.d/
$ vi haresources

node1 192.168.56.100 apache2

nodename 가상IP 등록서비스

참조하는 서비스 스크립트는 /root/heartbeat/etc/ha.d/resource.d 에 위치한다.

디렉토리 링크와 hostname 변경

$ ln -s /root/heartbeat/etc/ha.d /etc/ha.d
$ vi /etc/hostname

hostname 파일에 사용하고자 하는 호스트 이름 설정. 호스트 이름은 곧 노드 이름이 된다.

$ reboot 

 TEST  

본래는 두 개의 노드를 만들어 테스트해야 하지만 본 글에서는 하나의 노드로만 테스트하여 가상IP가 정상적으로 동작하는지만 테스트 한다. 그리고 서비스 테스트를 위해 apache2를 설치한다.  테스트를 위한 네트워크 설정은 Virtualbox의 ‘호스트 전용 어댑터’ 옵션을 사용하였음을 알린다.  

apahce2 설치

$ sudo apt-get install apache2
$ cp /etc/init.d/apache2 /root/heartbeat/etc/ha.d/resource.d/

heartbeat 동작

$ /etc/init.d/heartbeat start

결과


Leave a Reply