리눅스/HA Cluster_Pacemaker

[LINUX] Pacemaker Cluster (CentOS7, KVM, pacemaker) - 1

ㅎㄷㄹㅁㅇ 2023. 8. 29. 22:46
반응형

Pacemaker 구성 1

 

목차

     

    클러스터란 두대 이상의 서버들을 하나로 묶어서 하나의 서버로 동작하게 하는 것을 말합니다.

    클러스터는 고가용성(High-availability, HA), 부하분산(load balance)등이 있습니다.

     

    클라이언트들에게 서버 기반 정보를 지속적이고 더 높은 효율로 제공 받을 수 있게 하는 것에 목적이 있습니다.

    시스템에서의 고가용성이란 운영 성능이 기준치에 맞게 충족되는 것을 말합니다. 특정 서버나 서비스의 종료 없이 지속적인 운영이 가능하게 하는 것을 말합니다. 추가로 문제가 생긴 서버나 서비스의 복구가 가능하고 정상화 할 수 있는 신뢰 높은 시스템을 뜻합니다. 

     

    고가용성 클러스터는 이중화 상태에서 fail-over 기능이 제공되어 한 노드에서의 장애가 발생해도 클러스터링에 의해 서비스의 문제가 없는 것을 말합니다. Pacemaker는 고가용성 클러스터로 아래는 Pacemaker를 구성하는 방법에 대해 소개하고자 합니다. 

    Pacemaker 구성에 필요한 것들

    • KVM(HOST)에서 구성KVM , VMware 등 가상화 장비에서 VM 설치 후 진행 합니다. VM은 iscsi 서버, 클러스터 노드 2대로 구성, 총 3대로 구성합니다.
    • VirtualBox에서도 구성은 가능하나, fencing 동작 추가가 어렵습니다. 
    • VM은 CentOS7.7로 구성되며, 네트워크는 Service, iscsi연동, HeartBeat로  구성했습니다.
    • 순서대로 설치 시 바로 설치가 가능합니다.  

     

    • VM / HOST IP 정보
      eth0 eth1 eth2
    node1(c77_ha01) 192.168.122.184 200.200.10.184 200.200.20.184
    node2(c77_ha02) 192.168.122.185 200.200.10.185 200.200.20.185
    storage(iscsi server)   200.200.10.181  

     

    OS 설정 파일 수정

    - 클러스터 노드로 사용할 node1, node2에 모두 동일하게 구성합니다. 

    [root@c77_ha01 ~]# cat /etc/hosts
    127.0.0.1   localhost localhost.localdomain localhost4 localhost4.localdomain4
    ::1         localhost localhost.localdomain localhost6 localhost6.localdomain6
    
    192.168.122.181 iscsi
    192.168.122.184 c77_ha01
    192.168.122.185 c77_ha02
    
    200.200.10.184 c77_ha01.iscsi
    200.200.10.185 c77_ha02.iscsi
    
    200.200.20.184 c77_ha01.hb
    200.200.20.185 c77_ha02.hb

     

     

    CentOS7 local repo 구성

    - ISO에 포함되어 있는 PKG 사용을 위해 local repo를 구성

    [CentOS 일 경우]

    # vi /etc/yum.repos.d/local.repo 
    
    [Packages]
    name=local
    baseurl=file:///media
    gpgcheck=0
    enabled=1
    
    # vi /etc/yum.repos.d/local.repo 
    [Packages]
    name=Server
    baseurl=file:///media/
    enabled=1
    gpgcheck=0
    
    [ResilientStorage]
    name=Server
    baseurl=file:///media/addons/ResilientStorage/
    enabled=1
    gpgcheck=0
    
    [HighAvailability]
    name=Server
    baseurl=file:///media/addons/HighAvailability/
    enabled=1
    gpgcheck=0

     

    [RHEL 일 경우]

    # vi /etc/yum.repos.d/local.repo 
    [Packages]
    name=Server
    baseurl=file:///media/
    enabled=1
    gpgcheck=0
    
    [ResilientStorage]
    name=Server
    baseurl=file:///media/addons/ResilientStorage/
    enabled=1
    gpgcheck=0
    
    [HighAvailability]
    name=Server
    baseurl=file:///media/addons/HighAvailability/
    enabled=1
    gpgcheck=0

     

    방화벽 / Selinux disable

    -  일반적으로 방화벽/Selinux 미사용을 기준으로 구성합니다. 

    # systemctl status firewalld
    # systemctl disable firewalld
    # systemctl stopfirewalld
    # systemctl status firewalld
    
    
    
    # getenforce
    # cat /etc/sysconfig/selinux  | grep SELINUX
    SELINUX=disabled
    SELINUXTYPE=targeted
    # getenforce

     

    시간 동기화를 위한 NTP 설정

    - 클러스터에서 시간 동기화는 중요합니다. 시간 동기화가 틀어질 경우 서버 간 시간이 틀어져 리소스나 클러스터 연동의 TIME OUT이 발생 할 수 있습니다. 

    # vi /etc/ntp.conf
    …
    server [ntp server]
    
    # systemctl status ntpd
    # systemctl restart ntpd
    # systemctl status ntpd
    
    # ntpq -pn

     

    KVM(HOST) Multicast 설정

    - KVM(HOST) 에서 진행

    HeartBeat 네트워크로 사용하는 대역에서 multicast로 통신이 가능해야합니다. 

    # cat /sys/devices/virtual/net/<virbr_interface>/bridge/multicast_querier
    # echo 1 > /sys/devices/virtual/net/<virbr_interface>/bridge/multicast_querier
    1
    # netstat -g

     

     

     


    클러스터 구성

    • Pacemaker  관련 패키지 설치 및 데몬 활성화 (VM Node 동시 진행)
    # yum install pacemaker corosync pcs lvm2-cluster psmisc policycoreutils-python bash-completion fence-agents-all

     

    • Pacemaker resource 확인
    # systemctl status corosync
    # systemctl status pacemaker
    # systemctl status pcsd

     

    • hacluster 계정 비밀번호 생성
    # echo 'password' | passwd --stdin hacluster

     

    • pcsd 데몬 활성화
    # systemctl enable --now pcsd
    # systemctl status pcsd

     

     

     

    • NODE1 에서  hacluster 사용자 인증 진행 (VM Node1에서만 진행)
    # pcs cluster auth node1.hb node2.hb -u hacluster -p password

     

    • Pacemaker 구성 (UDPU사용)
    # pcs cluster setup --name ha_cluster c77_ha01.hb c77_ha02.hb --transport udpu --token 10000

     

    • Pacemaker Start
    # pcs cluster start --all

     

    • Pacemaker 상태확인
    [root@c77_ha01 ~]# pcs status
    Cluster name: ha_cluster
    Stack: corosync
    Current DC: c77_ha02.hb (version 1.1.20-5.el7-3c4c782f70) - partition with quorum
    Last updated: Thu Apr  4 11:11:04 2024
    Last change: Tue Apr  2 17:28:37 2024 by root via cibadmin on c77_ha01.hb
    
    2 nodes configured
    1 resource configured
    
    Online: [ c77_ha01.hb c77_ha02.hb ]
    
    Full list of resources:
    
     kdump-fence	(stonith:fence_kdump):	Started c77_ha01.hb
    
    Daemon Status:
      corosync: active/disabled
      pacemaker: active/disabled
      pcsd: active/enabled

     

     

    • Corosync 통신 확인 (VM Node 동시 진행)
    [root@c77_ha01 ~]# corosync-cfgtool -s
    Printing ring status.
    Local node ID 1
    RING ID 0
    	id	= 200.200.20.184
    	status	= ring 0 active with no faults
    
    [root@c77_ha02 ~]# corosync-cfgtool -s
    Printing ring status.
    Local node ID 2
    RING ID 0
    	id	= 200.200.20.185
    	status	= ring 0 active with no faults
    
    [root@c77_ha01 ~]# pcs status corosync
    
    Membership information
    ----------------------
        Nodeid      Votes Name
             1          1 c77_ha01.hb (local)
             2          1 c77_ha02.hb

     

     

     

    여기까지 Pacemaker 구성은 완료 됐습니다. 두 노드 간 Corosync를 통해서 클러스터 Member로 등록한 상태입니다. 추가로 Stonith 추가, Resource 추가를 통해서 설정을 완료하면 됩니다. 

     

     

    Ref.

    https://www.redhat.com/ko/topics/linux/what-is-high-availability

     

     

    반응형
    TOP