22.8. ha_cluster 시스템 역할을 사용하여 고가용성 클러스터에서 Apache HTTP 서버 구성
이 절차에서는 ha_cluster
시스템 역할을 사용하여 두 노드 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
시스템 역할은 지정된 노드의 기존 클러스터 구성을 대체합니다. 역할에 지정되지 않은 설정은 모두 손실됩니다.
절차
-
ha_cluster
시스템 역할에 대한 인벤토리 지정에 설명된 대로 클러스터에서 노드를 지정하는 인벤토리파일을 만듭니다. 플레이북 파일(예:
http-cluster.yml
)을 생성합니다.참고프로덕션용 플레이북 파일을 생성할 때 Ansible Vault를 사용하여 콘텐츠 암호화에 설명된 대로 암호를 암호화하는 것이 좋습니다.
다음 예제 플레이북 파일은 활성/수동 두 노드 HA 클러스터에서 이전에 생성된 Apache HTTP 서버를 구성합니다.
이 예에서는 호스트 이름이
zapc.example.com
인 APC 전원 스위치를 사용합니다. 클러스터에서 다른 펜스 에이전트를 사용하지 않는 경우 이 예와 같이ha_cluster_fence_agent_packages
변수를 정의할 때 클러스터에 필요한 펜스 에이전트만 나열할 수 있습니다.- 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_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
- 파일을 저장합니다.
1단계에서 생성한 인벤토리 파일 인벤토리 의 경로를 지정하여 플레이북을 실행합니다.
# ansible-playbook -i inventory http-cluster.yml
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
/var/run/httpd-website.pid를 website
가 Apache 리소스의 이름인 PID 파일 경로로 지정하여 제거한 행을 다음 세 줄로 바꿉니다. 이 예에서 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
검증 단계
클러스터의 노드 중 하나에서 클러스터 상태를 확인합니다. 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
클러스터가 가동되어 실행되면 브라우저에서
IPaddr2
리소스로 정의된 IP 주소를 가리키면 간단한 단어 "Hello"로 구성된 샘플 디스플레이를 볼 수 있습니다.Hello
z1.example.com
에서 실행 중인 리소스 그룹이z2.example.com
노드에 실패했는지 여부를 테스트하려면 노드z1.example.com
을대기
모드로 배치한 후 노드가 더 이상 리소스를 호스트할 수 없습니다.[root@z1 ~]# pcs node standby z1.example.com
노드
z1
을standby
모드로 전환한 후 클러스터의 노드 중 하나에서 클러스터 상태를 확인합니다. 이제 리소스는 모두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 주소의 웹 사이트는 중단 없이 계속 표시되어야 합니다.
대기
모드에서z1
을 제거하려면 다음 명령을 입력합니다.[root@z1 ~]# pcs node unstandby z1.example.com
참고대기
모드에서 노드를 제거하면 리소스가 해당 노드로 다시 실패하지 않습니다. 이는 리소스의resource-stickiness
값에 따라 달라집니다.resource-stickiness
meta 속성에 대한 자세한 내용은 현재 노드를 선호하도록 리소스 구성을 참조하십시오.