|
00:0C:29:19:E7:B9 192.168.8.140 lux5.kgitbank.local
00:0C:29:4E:AB:4B 192.168.8.141 lux4.kgitbank.local
1. To change hostname on each nodes
Node 1 # vi /etc/sysconfig/network 에서 HOSTNAME=lux4.kgitbank.lcoal Node 2 # vi /etc/sysconfig/network 에서 HOSTNAME=lux5.kgitbank.lcoal
2. /etc/hosts 파일 수정
Node 1 # vi /etc/hosts에서 192.168.8.141 lux4.kgitbank.lcoal Node 2 # vi /etc/hosts에서 192.168.8.140 lux5.kgitbank.lcoal
3. 타임서버 동기화
Node 1 # corntab -e 0 01 * * * rdate -s time.bora.net && clock -w Node 2 # crontab -e 0 01 * * * rdate -s time.bora.net && clock -w
4. To set auto mount by restart # chkconfig crond on # yum -y install rdate
5. 저장소 추가후 Heartbeat 설치
Node 1,2 동일 # yum -y install epel-release Node 1,2 동일 # yum -y install heartbeat*
6. 환경설정파일 복사
Node 1,2 동일 # rpm -q heartbeat -d : 하트비트가 설치된 경로 확인
Node 1,2 동일 # cd /usr/share/doc/heartbeat-3.0.4/
Node 1,2 동일 # cp ha.cf haresources authkeys /etc/ha.d/ : 설정파일 샘플 복사
7. Ha.cf 설정
Node 1,2 동일 # vi /etc/ha.d/ha.cf
파일의 끝에 설정하면 된다. 디버깅용 로그 debugfile /var/log/ha-debug.log 기타 로그 logfile /var/log/ha.log 노드간 체크 시간(두 노드간에 얼마나 자주 heartbeat를 주고받을 것인가를 설정) keepalive 2 호스트가 죽었다고 판단하는 시간 deadtime 30 자동 복구 On(한 노드가 서비스 하다가 죽었을 때 새로운 노드로 자원이 이동) auto_failback on 노드간 체크에 사용할 인터페이스(heartbeat 를 보낼 인터페이스 설정) bcast eth0 노드 등록 node lux4.kgitbank.local # master node lux5.kgitbank.local # slave UDP 에 사용할 포트(통신포트 설정) udpport 694
8. 로그를 위한 파일 생성
Node 1,2 동일 # touch /var/log/ha-debug.log Node 1,2 동일 # touch /var/log/ha.log
9. 방화벽 설정
UDP 포트에 대한 방화벽은 해제한다. Node 1,2 동일 # iptables -A INPUT -m state --state NEW -m udp -p udp --dport 694 -j ACCEPT Node 1,2 동일 # service iptables save
Node 1,2 동일 # service iptables restart
10. haresources 설정
Node 1 # vi /etc/ha.d/haresources 파일의 끝에 설정하면 된다.
lux4.kgitbank.local IPaddr2::192.168.8.250/24/eth0:0/192.168.8.255 httpd 자신의 호스트/IPaddr2/가상IP/클래스/인터페이스/브로드캐스트 서비스할 데몬
Node 2 # vi /etc/ha.d/haresources 파일의 끝에 설정하면 된다.
lux5.kgitbank.local IPaddr2::192.168.8.250/24/eth0:0/192.168.8.255 httpd 자신의 호스트/IPaddr2/가상IP/클래스/인터페이스/브로드캐스트 서비스할 데몬
11. authkeys 설정
authkeys : 보안수준을 설정(노트간의 인증방법 지정)
Node 1,2 동일 # vi /etc/ha.d/authkeys auth 2 2 sha1 centos
Node 1,2 동일 # chmod 600 /etc/ha.d/authkeys - 권한변경(필수)
12. 공용 서비스할 데몬 파일의 링크 생성
Node 1,2 동일 # ln -s /etc/rc.d/init.d/httpd /etc/ha.d/resource.d/httpd
13. linux apache 설정
Node 1,2 동일 # vi /etc/httpd/conf/httpd.conf ServerName 192.168.8.250
Node 1,2 동일 # system-config-firewall에서 HTTP 방화벽 열기 Node 1,2 동일 # /etc/rc.d/init.d/httpd start
14. HA 테스트
Node 1 # chkconfig heartbeat on
Node 1 먼저 실행(마스터) # service heartbeat start Node 1 (마스터) # tail -f /var/log/ha-debug Node 1 (마스터) # tail -f /var/log/ha-log heartbeat 실행 하면 위 두개의 로그에서 데몬 및 설정 값이 정상 작동 된것을 확인 할수 있다.
Node 2 # chkconfig heartbeat on
Node 2 실행(슬레이브) # service heartbeat start Node 2 (슬레이브) # tail -f /var/log/ha-debug Node 2 (슬레이브) # tail -f /var/log/ha-log heartbeat 실행 하면 위 두개의 로그에서 데몬 및 설정 값이 정상 작동 된것을 확인 할수 있다.
상태 확인 Node 1,2 동일 # ifconfig eth1:0이 추가된 것을 볼 수 있다.
만약 NIC가 추가되지 않았다면 rebooting 하자.
|