본문 바로가기

엔지니어/Linux

How to make High Available Load Balancer(L4/L7) with haproxy and Pacemaker - 3/4

728x90
반응형

4. High Availability "Pacemaker" Install & Configuration


Active/Standby Node에 아래와 같은 과정을 통해 Pacemaker를 설치한다.


  • Install libraries
    • # yum update
    • # yum install libtool-ltdl.x86_64 openhpi-libs.x86_64 libibverbs.x86_64 librdmacm.x86_64



  • Install
    • # rpm -Uvh ./*.rpm




  • make /etc/ha.d/authkeys
    • # chmod 600 /etc/ha.d/authkeys
    • ClusterPasswordHere에는 Cluster(Active/Standby Node)가 인증에 사용할 적절한 Password를 입력한다.

    auth 2 1 crc 2 sha1 ClusterPasswordHere


  • make /etc/ha.d/ha.cf
    • Pacemaker는 Cluster Communication(Health Check/Configuration 등)을 위해 Messaging Layer로 heartbeat 또는 corosync를 사용한다. 본 문서에서는 heartbeat을 사용하였다.

    # Active Node

    logfile /var/log/ha-log keepalive 1 # 1초 간격으로 Health Check. deadtime 3 # 3초 안에 Health Check에 대한 응답이 없으면 상대 Node Failed로 판단. ucast eth0 192.168.0.12 # 상대편 Node의 IP Address crm yes # Pacemaker 실행 node ACT node STD

    # Standby Node

    logfile /var/log/ha-log
    
    keepalive 1
    deadtime 3
    ucast eth0 192.168.0.11
    crm yes
    
    node ACT
    node STD


  • edit /etc/hosts

    # Do not remove the following line, or various programs
    # that require network functionality will fail.
    127.0.0.1localhost.localdomain localhost
    
    192.168.0.11 ACT
    192.168.0.12 STD


  • Start Pacemaker
    • Active/Standby Node 양쪽 모두에서 Pacemaker를 실행한다.

    # /etc/init.d/heartbeat start
    Starting High-Availability services:                       [  OK  ]

  • Pacemaker Configuration
    • Cluster Node 중 한곳에서만 설정하면 전체 Cluster에 적용된다.

        # crm
        crm(live)# configure
        crm(live)configure# property stonith-enabled=false
        crm(live)configure# property no-quorum-policy=ignore
        crm(live)configure# rsc_defaults resource-stickiness=100
        crm(live)configure# rsc_defaults failure-timeout=0
          -> Resource가 다른 Node로 Failover 됐을 때 원래 Node로 Auto failback 하지 않도록(수동 failback) 설정
        crm(live)configure# rsc_defaults migration-threshold=10
          -> Resource의 강제 migration을 결정하는 임계값 설정.
        crm(live)configure# primitive VIP_192.168.0.10 ocf:heartbeat:IPaddr params ip=192.168.0.10 cidr_netmask=24 op monitor interval=5s
          -> Cluster는 Resource(VIP)의 상태를 5초 간격으로 Health Check 한다. Timeout 기본값은 15초.
          -> Health Check Failed이면 fail-count를 횟수만큼 증가 시킨다.
          -> fail-count > migration-threshold이면 Node의 상태에 상관없이 다른 Node에서 Resource를 Failover 한다.
        crm(live)configure# primitive haproxy lsb:haproxy op monitor interval=5s
          -> haproxy도 Pacemaker의 Resource로 등록. Health Check Interval은 5초.
        crm(live)configure# group Service_Name VIP haproxy
          -> VIP와 haproxy를 하나의 Resource로 Grouping.
        crm(live)configure# location Service_Name_on_ACT Service_Name 100: ACT
          -> Resource의 Preference Node를 지정, 여기서는 Active Node. 
        crm(live)configure# verify
          -> Configuration 검증.
        crm(live)configure# commit
          -> Configuration 적용.

  • Cluster 상태 확인

      # crm_mon -1nfr
      ============
      Last updated: Wed Feb 20 18:53:12 2013
      Stack: Heartbeat
      Current DC: ACT (07e78f2b-c4cc-42e6-b058-d7e0bd3a91e5)	- partition with quorum
      Version: 1.0.12-unknown
      2 Nodes configured, unknown expected votes
      1 Resources configured.
      ============
      
      Node ACT (07e78f2b-c4cc-42e6-b058-d7e0bd3a91e5): online
              haproxy (lsb:haproxy) Started
              VIP_192.168.0.10        (ocf::heartbeat:IPaddr) Started
      Node STD (7b640fc0-0089-4db9-8c83-e34476c5e065): online
      
      Inactive resources:
      
      
      Migration summary:
      * Node ACT:
      * Node STD:
반응형