26.11. ha_cluster 시스템 역할을 사용하여 고가용성 클러스터에서 Apache HTTP 서버 구성

이 절차에서는 ha_cluster 시스템 역할을 사용하여 2노드 Red Hat Enterprise Linux High Availability Add-On 클러스터에서 활성/수동 Apache HTTP 서버를 구성합니다.

사전 요구 사항

  • 플레이북을 실행할 노드에 ansible-core 가 설치되어 있어야 합니다.

    참고

    클러스터 멤버 노드에 ansible-core 를 설치할 필요가 없습니다.

  • 플레이북을 실행하려는 시스템에 rhel-system-roles 패키지가 설치되어 있습니다.
  • 클러스터 구성원에게 RHEL 및 RHEL 고가용성 애드온에 대한 활성 서브스크립션 적용 범위로 사용할 시스템이 있습니다.
  • 시스템에 Apache에 필요한 공용 가상 IP 주소가 포함되어 있습니다.
  • 시스템에는 iSCSI, 파이버 채널 또는 기타 공유 네트워크 블록 장치를 사용하여 클러스터의 노드에 대한 공유 스토리지가 포함됩니다.
  • Pacemaker 클러스터에서 XFS 파일 시스템으로 LVM 볼륨 구성에 설명된 대로 XFS 파일 시스템으로 LVM 논리 볼륨을 구성했습니다.
  • Apache HTTP 서버 구성에 설명된 대로 Apache HTTP 서버를 구성했습니다.
  • 시스템에는 클러스터 노드를 펜싱하는 데 사용할 APC 전원 스위치가 포함되어 있습니다.
주의

ha_cluster 시스템 역할은 지정된 노드의 기존 클러스터 구성을 대체합니다. 역할에 지정되지 않은 모든 설정은 손실됩니다.

절차

  1. ha_cluster 시스템 역할에 대한 인벤토리 지정에 설명된 대로 클러스터의 노드를 지정하는 인벤토리 파일을 생성합니다.
  2. 플레이북 파일(예: http-cluster.yml )을 생성합니다.

    참고

    프로덕션용 플레이북 파일을 생성할 때 자격 증명 모음은 Ansible Vault로 콘텐츠 암호화에 설명된 대로 암호를 암호화합니다.

    다음 예제 플레이북 파일은 firewalldselinux 서비스를 실행하는 활성/패시브 2-노드 HA 클러스터에 이전에 생성된 Apache HTTP 서버를 구성합니다.

    이 예에서는 호스트 이름이 zapc.example.com 인 APC 전원 스위치를 사용합니다. 클러스터에서 다른 펜싱 에이전트를 사용하지 않는 경우, 이 예제와 같이 클러스터에 ha_cluster_fence_agent_packages 변수를 정의할 때 필요한 fence 에이전트만 나열할 수 있습니다.

    - hosts: z1.example.com z2.example.com
      roles:
        - rhel-system-roles.ha_cluster
      vars:
        ha_cluster_hacluster_password: password
        ha_cluster_cluster_name: my_cluster
        ha_cluster_manage_firewall: true
        ha_cluster_manage_selinux: true
        ha_cluster_fence_agent_packages:
          - fence-agents-apc-snmp
        ha_cluster_resource_primitives:
          - id: myapc
            agent: stonith:fence_apc_snmp
            instance_attrs:
              - attrs:
                  - name: ipaddr
                    value: zapc.example.com
                  - name: pcmk_host_map
                    value: z1.example.com:1;z2.example.com:2
                  - name: login
                    value: apc
                  - name: passwd
                    value: apc
          - id: my_lvm
            agent: ocf:heartbeat:LVM-activate
            instance_attrs:
              - attrs:
                  - name: vgname
                    value: my_vg
                  - name: vg_access_mode
                    value: system_id
          - id: my_fs
            agent: Filesystem
            instance_attrs:
              - attrs:
                  - name: device
                    value: /dev/my_vg/my_lv
                  - name: directory
                    value: /var/www
                  - name: fstype
                    value: xfs
          - id: VirtualIP
            agent: IPaddr2
            instance_attrs:
              - attrs:
                  - name: ip
                    value: 198.51.100.3
                  - name: cidr_netmask
                    value: 24
          - id: Website
            agent: apache
            instance_attrs:
              - attrs:
                  - name: configfile
                    value: /etc/httpd/conf/httpd.conf
                  - name: statusurl
                    value: http://127.0.0.1/server-status
        ha_cluster_resource_groups:
          - id: apachegroup
            resource_ids:
              - my_lvm
              - my_fs
              - VirtualIP
              - Website
  3. 파일을 저장합니다.
  4. 1단계에서 생성한 인벤토리 파일 인벤토리 의 경로를 지정하여 플레이북을 실행합니다.

    # ansible-playbook -i inventory http-cluster.yml
  5. apache 리소스 에이전트를 사용하여 Apache를 관리하는 경우 systemd 를 사용하지 않습니다. 따라서 Apache를 다시 로드하는 데 systemctl 을 사용하지 않도록 Apache와 함께 제공된 10.0.0.1 스크립트를 편집해야 합니다.

    클러스터의 각 노드의 /etc/logrotate.d/httpd 파일에서 다음 행을 제거합니다.

    /bin/systemctl reload httpd.service > /dev/null 2>/dev/null || true
    • RHEL 8.6 이상에서는 제거한 행을 다음 세 줄로 교체하여 /var/run/httpd-website.pid 를 PID 파일 경로로 지정합니다. 여기서 website 는 Apache 리소스의 이름입니다. 이 예에서 Apache 리소스 이름은 website 입니다.

      /usr/bin/test -f /var/run/httpd-Website.pid >/dev/null 2>/dev/null &&
      /usr/bin/ps -q $(/usr/bin/cat /var/run/httpd-Website.pid) >/dev/null 2>/dev/null &&
      /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf -c "PidFile /var/run/httpd-Website.pid" -k graceful > /dev/null 2>/dev/null || true
    • RHEL 8.5 이하의 경우 제거한 행을 다음 세 줄로 교체합니다.

      /usr/bin/test -f /run/httpd.pid >/dev/null 2>/dev/null &&
      /usr/bin/ps -q $(/usr/bin/cat /run/httpd.pid) >/dev/null 2>/dev/null &&
      /usr/sbin/httpd -f /etc/httpd/conf/httpd.conf -c "PidFile /run/httpd.pid" -k graceful > /dev/null 2>/dev/null || true

검증 단계

  1. 클러스터의 노드 중 하나에서 클러스터 상태를 확인합니다. 4개의 리소스 모두 동일한 노드 z1.example.com 에서 실행되고 있습니다.

    구성한 리소스가 실행되고 있지 않은 경우 pcs resource debug-start resource명령을 실행하여 리소스 구성을 테스트할 수 있습니다.

    [root@z1 ~]# pcs status
    Cluster name: my_cluster
    Last updated: Wed Jul 31 16:38:51 2013
    Last change: Wed Jul 31 16:42:14 2013 via crm_attribute on z1.example.com
    Stack: corosync
    Current DC: z2.example.com (2) - partition with quorum
    Version: 1.1.10-5.el7-9abe687
    2 Nodes configured
    6 Resources configured
    
    Online: [ z1.example.com z2.example.com ]
    
    Full list of resources:
     myapc  (stonith:fence_apc_snmp):       Started z1.example.com
     Resource Group: apachegroup
         my_lvm     (ocf::heartbeat:LVM-activate):   Started z1.example.com
         my_fs      (ocf::heartbeat:Filesystem):    Started z1.example.com
         VirtualIP  (ocf::heartbeat:IPaddr2):       Started z1.example.com
         Website    (ocf::heartbeat:apache):        Started z1.example.com
  2. 클러스터가 가동되어 실행되면 브라우저에서 IPaddr2 리소스로 정의한 IP 주소를 가리켜 간단한 단어 "Hello"로 구성된 샘플 디스플레이를 볼 수 있습니다.

    Hello
  3. z1.example.com 에서 실행 중인 리소스 그룹이 z2.example.com 노드로 장애 조치(failover)되는지 여부를 테스트하려면 노드 z1.example.com 을 준비 모드로 배치한 후 노드가 더 이상 리소스를 호스팅할 수 없게 됩니다.

    [root@z1 ~]# pcs node standby z1.example.com
  4. 노드 z1일괄 모드로 전환한 후 클러스터의 노드 중 하나에서 클러스터 상태를 확인합니다. 이제 리소스가 모두 z2 에서 실행되어야 합니다.

    [root@z1 ~]# pcs status
    Cluster name: my_cluster
    Last updated: Wed Jul 31 17:16:17 2013
    Last change: Wed Jul 31 17:18:34 2013 via crm_attribute on z1.example.com
    Stack: corosync
    Current DC: z2.example.com (2) - partition with quorum
    Version: 1.1.10-5.el7-9abe687
    2 Nodes configured
    6 Resources configured
    
    Node z1.example.com (1): standby
    Online: [ z2.example.com ]
    
    Full list of resources:
    
     myapc  (stonith:fence_apc_snmp):       Started z1.example.com
     Resource Group: apachegroup
         my_lvm     (ocf::heartbeat:LVM-activate):   Started z2.example.com
         my_fs      (ocf::heartbeat:Filesystem):    Started z2.example.com
         VirtualIP  (ocf::heartbeat:IPaddr2):       Started z2.example.com
         Website    (ocf::heartbeat:apache):        Started z2.example.com

    정의된 IP 주소에 있는 웹 사이트는 중단 없이 계속 표시되어야 합니다.

  5. CloudEvent 모드에서 z1 제거하려면 다음 명령을 입력합니다.

    [root@z1 ~]# pcs node unstandby z1.example.com
    참고

    reliability 모드에서 노드를 제거해 도 리소스가 해당 노드로 다시 장애 조치되지 않습니다. 이는 리소스의 resource-stickiness 값에 따라 달라집니다. resource-stickiness meta 속성에 대한 자세한 내용은 현재 노드를 선호하도록 리소스 구성을 참조하십시오.