콜라비 HA 구성방법

How to install

HA(High Availability)?

* 가이드는 KT클라우드 설치를 위한 가이드로, 사이트별(고객사) 설치 방법이 다를 수 있음을 알고 계시기 바랍니다.

세부적인 설치 및 사양은 담당 영업사원에게 문의를 해주시기 바랍니다.

1 Pacemaker, corosync?


- corosync : 노드 간의 멤버쉽, 쿼럼, 메시징 기능. corosync 클러스터 내의 노드 Discovery, 통신, 동기화 작업 등을 담당한다

                   Mesh 형태로 동작.


-pacemaker : corosync 기능을 이용해 클러스터의 리소스 제어 관리를 수행하며, 사용자 입장에서 클러스터의 특정 기능을 사용할 때는 대부분

                     pacemaker 호출. 예를 들어, Virtual IP 리소스를 생성하려면 pacemaker CLI 사용하지만, pacemaker 

                               Virtual IP 리소스 할당을 위해 내부적으로 corosync 인프라 정보를 사용.

-pcs: pacemaker, corosync를 쉽게 다루기위한 명령어 집합(pcs명령어가 없어도 pacemaker, corosync 명령어로 가능. 하지만 pcs명령어가 쉬움)


https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/high_availability_add-on_reference/ch-clusteradmin-haar#s1-clustercreate-HAAR

Step 1

-iptables에 IP 대역 등록

-ssh 서버 동기화(ssh-keygen -t rsa)

-/etc/hosts에 서버 호스트명 입력

-서버별 고정아이피 입력(dhcp절대 안됨)


Step 2

[설명]

[ha1,ha2] ➡︎ 표기는 서버 양쪽 모두 명령어 실행 필요

ha1 ➡︎ 표기는 서버 1번에서만 명령어 실행

1. 패키지 설치 및 의존성 처리

[ha1,ha2]#yum -y install corosync pcs pacemaker

[ha1,ha2]#yum -y groupinstall 'High Availability'

[ha1,ha2]#systemctl disable asterisk

[ha1,ha2]#chkconfig --del asterisk

[ha1,ha2]#kill -9 PID(asterisk)

[ha1,ha2]#cd /etc/init.d/ && mv asterisk asterisk_bak    ➡︎ asterisk 이름을 변경하여 asterisk가 실행되지 않게함.
                                                                                            (이후 asterisk는 이중화 데몬에서 관리)

[ha1,ha2]#reboot

Step 3

➡︎pcs데몬 자동실행 등록

[ha1,ha2]#systemctl start pcsd.service && systemctl enable pcsd.service

Step 4

➡︎HA 클러스트용 자동생성된 아이디 패스워드 변경(이중화 데몬을 설치하면 hacluster 계정이 자동 생성됨)

[ha1,ha2]# passwd hacluster     ➡︎ 패스워드 klcns8081

Step 5

➡︎Cluster 인증

[ha1]# pcs cluster auth ha1 ha2  ➡︎ 호스트이름은 설치되는 시스템에 맞게 수정할것!

Step 6

➡︎ Cluster 네임 설정

[ha1]# pcs cluster setup --name cluster_asterisk ha1 ha2

Step 7

➡︎ Cluster 시작

[ha1]# pcs cluster start --all

[ha1]# pcs property set stonith-enabled=false

강제로 노드 재설정 및 System Shutdown을 끈다.

[ha1]# pcs property set no-quorum-policy=ignore

Quorum Policy를 끈다. (노드가 2개일 때는 Quorum 정책이 오히려 비효율적)

[설명]

-STONITH: Shoot The Other Node In The Head, Fencing을 통해 Failed Node를 고립시켜 클러스터에 방해를 일으키지 않게 함. 

기본적으로 Node Reset이나 Shutdown을 시켜버림. 디폴트 설정 되어있음.

-Quorum: 클러스터에 허용되는 오류를 의사 결정하는 정책

Step 8

➡︎ Cluster AST script 복사하기

[ha1,ha2]# cp -f /root/callrabi_distribution/config/ha/asterisk /usr/lib/ocf/resource.d/heartbeat ⬅︎ git에서 받은 콜라비 원본 소스가 있어야함
(원본 소스가 없다면 다시 소스를 받아야함)

[ha1,ha2]# chmod u=rwx,g=rx,o=rx /usr/lib/ocf/resource.d/heartbeat/asterisk

Step 9

➡︎ Cluster resource 설정(Asterisk)

[ha1]# pcs resource create VirtualIP ocf:heartbeat:IPaddr2 ip=192.168.101.69 cidr_netmask=23 op monitor interval=30 on-fail=restart
      
➡︎ 가상 아이피 192.168.101.69 설정 OCF(Open Cluster Framework) 규격의 Heartbeat 체크, Netmask를 CIDR에 맞게 설정(24 = 255.255.255.0) 모니터링 주기 5초

[ha1]# pcs resource create asterisk ocf:heartbeat:asterisk op monitor timeout=30

[ha1]# pcs constraint colocation add asterisk with VirtualIP score=INFINITY

[ha1]# pcs constraint order VirtualIP then asterisk

➡︎ Cluster resource 설정 변(Asterisk)

-버추얼 IP 변경 방법 (버추얼 IP를 변경하면 step 8번의 작업을 다시 아래 예제처럼 해줘야함.

[ha1]# pcs resource delete VirtualIP

[ha1]# pcs resource create VirtualIP ocf:heartbeat:IPaddr2 ip=192.168.101.70 cidr_netmask=23 op monitor interval=5s on-fail=restart

[ha1]# pcs resource create asterisk ocf:heartbeat:asterisk op monitor timeout="5"

[ha1]# pcs constraint colocation add asterisk with VirtualIP score=INFINITY

[ha1]# pcs constraint order VirtualIP then asterisk

Step 10

➡︎ Cluster 서버 우선순위

[ha1]# pcs constraint location asterisk prefers ha1

Step 11

➡︎ Cluster 상태 확인

[ha1]# pcs status

[ha1]# pcs status cluster

[ha1]# pcs status nodes

Step 12

➡︎ Cluster 리소스 설정 완료 후 서비스 재시작 및 활성화

[ha1,ha2]# systemctl restart pcsd && systemctl restart pacemaker && systemctl restart corosync

[ha1,ha2]# systemctl enable pcsd && systemctl enable pacemaker && systemctl enable corosync

Step 13

➡︎ 콜라비 Asterisk sip_general.conf 파라메타 수정

[ha1,ha2] 서버 2대 모두

bindaddr = 10.60.1.15:5060  ➡︎ 고객사 네트워크에따라 수정

externip = 221.168.47.154  ➡︎ 외부 최종 IP(curl ifconfig.me  명령어로 확인)

localnet = 10.60.1.0/24 ➡︎ 콜라비 내부 사설 IP 대역(라우팅 포함)

초기화 방법

➡︎ 이중화를 잘못 구성했을시 파괴하고 다시 설정 방법.

# pcs cluster stop --all

# pcs cluster destroy --all

이중화 테스트 방법

➡︎ PCS cluster standby 설정 (on/off)

장애테스트 방법. standby 로 설정하면 해당 노드의 상태가 Online에서 standby로 되며 서비스에서 빠짐.


# pcs cluster standby $CLUSTER_NAME

# pcs cluster unstandby $CLUSTER_NAME

➡︎ asterisk 백업 테스트 방법

#kill -9 명령으로 asterisk프로세스 킬 (grep으로 pid를 찾아야함)

이중화 리부팅 방법

➡︎ 이중화된 서버를 리부팅 하기 위해서는 아래처럼 진행 해야함

1. 리부팅 할려는 서버를 대기상태로 만들어야함

#pcs cluster standby test-ha2

**리부팅 이후 서버의 대기에서 활성화로 상태를 바꿔야함.

#pcs cluster unstandby test-ha2

기타 조치사항

➡︎ Cluster 리소스 설정 완료 후 서비스 재시작 및 활성화

[ha1]# pcs resource cleanup


➡︎ vip 이동

pcs resource move VirtualIP ha1  ➡︎ ha2가 vip를 가지고 있으면 ha1로 이동시키는 명령(약간의 몇초정도 시간이 걸림. pcs status로 확인)


➡︎ 노드 추가

pcs cluster auth

pcs cluster node add 추가호스트


➡︎만약 아래 이미지와 같이 비정상적일때에는...

➡︎ 아래 이미지처럼 /etc/hosts 의 로컬도메인을 맞춰줌

이중화 명령어

[코로싱크 확인 명령어]

# corosync-cmapctl | grep members


[상태 조회명령어]

- 설정 조회

# pcs config


- 클러스터 서비스 정상여부 조회

# pcs cluster status


- 리소스 조회

# pcs resource show [resource_id]


- 펜싱(Stonith) 조회

# pcs stonith show


[클러스터 시작명령어]

- 시작

# pcs cluster start [node명]


- 중지

# pcs cluster stop [node명]


- 클러스터 대기 모드

# pcs cluster standby [node 명]


- 클러스터 대기모드 비활성화

# pcs cluster unstandby [node명]


[클러스터 리소스 명령어]

- 리소스 이동

# pcs resource move [resource_id] [destination node명]


- 리소스 재배치

# pcs resource relocate run [resource1] [reousrce2]

이중화후 아래 링크 동기화 설정

이중화 구성시 체크사항

   1.    nginx폴더 동기화(/etc/nginx/nginx.conf,  /etc/nginx/conf.d/virtual.conf)

    2.    php.init 동기화(/etc/php.ini)

    3.    iptables 동기화(/etc/sysconfig/iptables)

    4.    /var/log/asterisk 폴더 동기화

    5.    /klpbx 폴더 동기화

    6.    DB 설정파일 동기화(/etc/my.cnf)

    7.    /klrec폴더 동기화

    8.    /etc/fstab 백업 스토리지 설정



고객센터
070-7919-8081

사용시 궁금한 내용이 있으시면 연락 주십시요.


mail to: support@klcns.co.kr