[환경]
centos6
호스트 1 - test-active
호스트 2 - test-standby
heartbeat을 이용한 이중화 하기
참고로 cent7부터는 heartbeat을 이용하지 않습니다.
1.heartbeat 설치 ( 아래 명령어 순서대로 입력 )
- wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
- rpm -ivh epel-release-latest-6.noarch.rpm
- sed -i -e "s/enabled=1/enabled=0/g" /etc/yum.repos.d/epel.repo
- yum --enablerepo=epel -y install heartbeat
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm --2020-05-31 20:27:20-- https://dl.fedoraproject.org/pub/epel/epel-release-latest-6.noarch.rpm
Resolving dl.fedoraproject.org... 209.132.181.23, 209.132.181.24, 209.132.181.25
Connecting to dl.fedoraproject.org|209.132.181.23|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 14540 (14K) [application/x-rpm]
Saving to: `epel-release-latest-6.noarch.rpm'
100%[==================================================================================================================================================================
2020-05-31 20:27:21 (95.8 KB/s) - `epel-release-latest-6.noarch.rpm' saved [14540/14540]
[root@test-active ~]# rpm -ivh epel-release-latest-6.noarch.rpm
경고: epel-release-latest-6.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 0608b895: NOKEY
준비 중... ########################################### [100%]
1:epel-release ########################################### [100%]
[root@test-active ~]# sed -i -e "s/enabled=1/enabled=0/g" /etc/yum.repos.d/epel.repo
[root@test-active ~]# yum --enablerepo=epel -y install heartbeat
2.heartbeat 설정 복사
- cp /usr/share/doc/heartbeat-*/ha.cf /etc/ha.d/
- cp /usr/share/doc/heartbeat-*/authkeys /etc/ha.d/
- cp /usr/share/doc/heartbeat-*/haresources /etc/ha.d/
[root@test-active ~]# cp /usr/share/doc/heartbeat-*/ha.cf /etc/ha.d/
[root@test-active ~]# cp /usr/share/doc/heartbeat-*/authkeys /etc/ha.d/
[root@test-active ~]# cp /usr/share/doc/heartbeat-*/haresources /etc/ha.d/
3.1. heartbeat 설정(authkeys)
- authkeys 파일은 서로간의 키를 맞춰주는 설정 파일이다. 서로 동일하게 입력하면 된다.
- vi /etc/ha.d/authkeys (아래는 예시이며 원하는 키 입력)
# methods and/or keys.
#
#
# sha1 is believed to be the "best", md5 next best.
#
# crc adds no security, except from packet corruption.
# Use only on physically secure networks.
#
#auth 1
#1 crc
#2 sha1 HI!
#3 md5 Hello!
auth 2
2 sha1 mogi
3.2. heartbeat 설정 (ha.cf)
- ha.cf 파일은 heartbeat 구동방식에대한 전반적인 설정을 하는 파일이다.
- vi /etc/ha.d/ha.cf (아래는 예시이며 원하는 대로 설정)
debugfile /var/log/ha-debug.log #디버그 로그 경로 설정
logfile /var/log/ha.log #로그 경로 설정
keepalive 2 #상대 노드에 신호 보내는 시간텀
deadtime 15 #상대노드가 죽었다고 판단하는 시간
auto_failback off #스탠바이가 기동중일때 액티브가 복구되면 자동으로 active로 vip가 넘어갈지 설정
ucast eth0 192.168.131.3 #신호 보낼 경로
node test-active #master node설정
node test-standby #slave noede 설정
udpport 694 #신호보낼 port 설정
'리눅스' 카테고리의 다른 글
[리눅스/스크립트] 스크립트로 bonding 하기 (0) | 2020.06.21 |
---|---|
[Python] 파이썬으로 첨부파일 메일보내기 feat.리눅스 (0) | 2020.05.24 |
[리눅스] 쉘 스크립트 이용해서 DB백업하기 (0) | 2020.05.17 |
[리눅스] 커맨드 기록하기 (0) | 2020.05.17 |
서버 원격 접속프로그램 추천 [ MobaXterm ] (0) | 2020.05.10 |