서버 클러스터 · 8 min read · Sep 10, 2025

완벽한 로드 밸런싱 및 고가용성 웹 클러스터: Ubuntu 8.04 하디 헤론에서 Xen을 실행하는 2대의 서버

완벽한 로드 밸런싱 및 고가용성 웹 클러스터: Ubuntu 8.04 하디 헤론에서 Xen을 실행하는 2대의 서버

소개

이것은 제 사이트에서 복사한 내용입니다: blogama.org

이 방법에서는 Xen, heartbeat 및 ldirectord를 사용하여 2대의 실제 서버에서 로드 밸런싱 및 고가용성 웹 클러스터를 구축합니다. 이 클러스터는 HTTP, 메일, DNS, MySQL 데이터베이스를 처리하며 완전히 모니터링됩니다. 현재 몇 개의 웹사이트가 있는 프로덕션 서버에서 사용되고 있습니다.

이 튜토리얼의 목표는 가능한 한 적은 실제 서버로 로드 밸런싱 및 고가용성을 달성하는 것이며, 물론 오픈 소스 소프트웨어를 사용합니다. 서버가 많을수록 하드웨어 및 호스팅 비용이 증가합니다.

여기 설치될 서비스 및 애플리케이션의 간단한 목록이 있습니다:

  • Apache
  • MySQL + phpmyadmin
  • Postfix (SMTP) 웹 기반 사용자 구성 및 Spamassassin
  • Courier (IMAP & POP) 및 squirrelmail
  • Bind (DNS 서버)
  • 웹 기반 모니터링을 위한 Munin 및 monit
  • 모니터링을 위한 자작 스크립트

필요한 것

이중 LAN이 있는 2대의 서버, 최소 7개의 IP. IP는 다음과 같이 사용됩니다:

  • dom01.example.com : 192.168.1.100
  • dom02.example.com : 192.168.1.101
  • lb1.example.com : 192.168.1.102
  • lb2.example.com : 192.168.1.103
  • web1.example.com : 192.168.1.104
  • web2.example.com : 192.168.1.105
  • example.com : 192.168.1.106
  • yousite.com (선택 사항) : 192.168.1.107

Dom0는 로드 밸런서 및 웹 서버와 분리됩니다. 시도해 보지는 않았지만, Dom0에 로드 밸런서를 배치하는 것이 가능할 것이라고 생각합니다.

프로덕션 서버를 위해 최소 2GB RAM과 RAID 1 또는 10 하드 드라이브를 권장합니다.

제한 사항

  1. 이것은 저에게 효과적이었습니다. 당신에게도 효과적일 것이라는 의미는 아니지만, 이 방법은 프로덕션 및 테스트 서버에서 100% 테스트되었음을 확신하세요!

  2. 이 설정은 2대의 서버에서 확장 가능하지만, 그렇게 하려면 MySQL 복제를 위한 다른 방법을 찾아야 합니다.

  3. ISPConfig, CPanel 등과 같은 제어판이 없습니다…

  4. 일부 웹사이트는 MySQL Master to Master 복제를 중단할 수 있습니다. Drupal에서 저에게 발생했지만, 캐시를 비활성화하거나 최소 캐시 수명을 설정하여 수정했습니다. 계속 진행하기 전에 이 내용을 읽어보세요:

A: MySQL 복제는 현재 마스터와 슬레이브 간의 원자성을 보장하기 위한 잠금 프로토콜을 지원하지 않습니다. 즉, 클라이언트 A가 공동 마스터 1에 업데이트를 수행하는 동안, 클라이언트 B가 공동 마스터 2에 업데이트를 수행하여 클라이언트 A의 업데이트가 공동 마스터 1에서와는 다르게 작동할 수 있습니다. 따라서 클라이언트 A의 업데이트가 공동 마스터 2에 도달할 때, 공동 마스터 1에서 가지고 있는 것과 다른 테이블이 생성됩니다. 이는 두 서버를 양방향 복제 관계로 연결해서는 안 된다는 것을 의미합니다. 업데이트가 안전하게 어떤 순서로든 발생할 수 있다고 확신하지 않거나 클라이언트 코드에서 잘못된 순서의 업데이트를 처리하지 않는 한 말입니다.

1. Ubuntu 설치

Ubuntu 8.04 LTS 서버 에디션의 기본 설치를 수행합니다.

소프트웨어 RAID 1로 설치하려면 제가 작성한 이 방법을 읽어보세요:

Ubuntu 8.04 소프트웨어 RAID 1로 설치하기

2. Xen 설치

Xen은 이미지 파일 또는 전용 파티션에서 실행할 수 있습니다. 두 가지 모두 장단점이 있습니다.

이미지 파일에서 디스크 I/O는 느리지만 백업 및 관리가 더 쉽습니다. 파티션에서 작업할 때는 그 반대입니다.

제가 제안하는 것은 이미지 파일로 시작하고 설정이 완료되면 파티션으로 끝내는 것입니다. 이렇게 하면 이미지 파일의 백업을 수행하고 테스트할 때 필요할 경우 롤백할 수 있습니다.

이미지 파일에 설치하려면 다음의 훌륭한 튜토리얼을 참조하세요:

Ubuntu 저장소에서 Ubuntu 8.04 (하디 헤론) 서버에 Xen 설치하기

전용 파티션에 직접 설치하려면 (Falko의 방법을 수정한 버전):

Ubuntu 하디 헤론 (8.04) 서버 시스템 AMD64 또는 i386에서 고성능 XEN

각 서버에서 2개의 Xen 도메인을 생성해야 합니다 (dom01 및 dom02는 Dom0 또는 VM 컨트롤러):

서버 #1 - dom01.example.com

lb1.example.com (256MB RAM - 5GB HD면 충분함)
ip : 192.168.1.102

web1.example.com

(더 많은 RAM이 좋습니다, Dom0를 위해 512MB 유지)

ip : 192.168.1.104

서버 #2 - dom02.example.com

lb2.example.com (256MB RAM - 5GB HD면 충분함)
ip : 192.168.1.103

web2.example.com (더 많은 RAM이 좋습니다, Dom0를 위해 512MB 유지)
ip : 192.168.1.105

3. 로컬 데이터 전송을 위한 Xen 브리지 생성 (선택 사항)

기본적으로 Xen이 있는 가상 머신에서 하나의 네트워크 카드만 활성화됩니다. rsync, MySQL 복제 및 백업과 같은 로컬 전송을 위해 2대의 서버 간에 기가비트 크로스오버 케이블을 사용합니다. 필수는 아니지만 대역폭 비용을 절약하고 복제가 더 빨라집니다.

Xen 브리지를 생성하기 위한 방법을 참조하세요:

Ubuntu 8.04에서 새로운 xen 브리지 만들기

이 방법에서는 두 번째 네트워크 카드 (크로스오버)에서 사용되는 IP는 다음과 같습니다:

  • dom01.example.com : 192.168.0.100
  • dom02.example.com : 192.168.0.101
  • lb1.example.com : 192.168.0.102
  • lb2.example.com : 192.168.0.103
  • web1.example.com : 192.168.0.104
  • web2.example.com : 192.168.0.105

4. 노드 준비 (dom01, dom02, lb1, lb2, web1, web2)

4.1 openssh 서버 및 VIM 설치

실행:

sudo su apt-get install vim ssh openssh-server

4.2 저장소 업데이트

mv /etc/apt/sources.list /etc/apt/sources.list.bak
vi /etc/apt/sources.list

sources.list를 다음과 같이 설정합니다:

#
# deb cdrom:[Ubuntu-Server 8.04 _Hardy Heron_ - Release i386 (20080423.2)]/ hardy main restricted
#deb cdrom:[Ubuntu-Server 8.04 _Hardy Heron_ - Release i386 (20080423.2)]/ hardy main restricted
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
# newer versions of the distribution.
deb http://de.archive.ubuntu.com/ubuntu/ hardy main restricted
deb-src http://de.archive.ubuntu.com/ubuntu/ hardy main restricted
## Major bug fix updates produced after the final release of the
## distribution.
deb http://de.archive.ubuntu.com/ubuntu/ hardy-updates main restricted
deb-src http://de.archive.ubuntu.com/ubuntu/ hardy-updates main restricted
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## universe WILL NOT receive any review or updates from the Ubuntu security
## team.
deb http://de.archive.ubuntu.com/ubuntu/ hardy universe
deb-src http://de.archive.ubuntu.com/ubuntu/ hardy universe
deb http://de.archive.ubuntu.com/ubuntu/ hardy-updates universe
deb-src http://de.archive.ubuntu.com/ubuntu/ hardy-updates universe
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
## team, and may not be under a free licence. Please satisfy yourself as to
## your rights to use the software. Also, please note that software in
## multiverse WILL NOT receive any review or updates from the Ubuntu
## security team.
deb http://de.archive.ubuntu.com/ubuntu/ hardy multiverse
deb-src http://de.archive.ubuntu.com/ubuntu/ hardy multiverse
deb http://de.archive.ubuntu.com/ubuntu/ hardy-updates multiverse
deb-src http://de.archive.ubuntu.com/ubuntu/ hardy-updates multiverse
## Uncomment the following two lines to add software from the 'backports'
## repository.
## N.B. software from this repository may not have been tested as
## extensively as that contained in the main release, although it includes
## newer versions of some applications which may provide useful features.
## Also, please note that software in backports WILL NOT receive any review
## or updates from the Ubuntu security team.
# deb http://de.archive.ubuntu.com/ubuntu/ hardy-backports main restricted universe multiverse
# deb-src http://de.archive.ubuntu.com/ubuntu/ hardy-backports main restricted universe multiverse
## Uncomment the following two lines to add software from Canonical's
## 'partner' repository. This software is not part of Ubuntu, but is
## offered by Canonical and the respective vendors as a service to Ubuntu
## users.
# deb http://archive.canonical.com/ubuntu hardy partner
# deb-src http://archive.canonical.com/ubuntu hardy partner
deb http://security.ubuntu.com/ubuntu hardy-security main restricted
deb-src http://security.ubuntu.com/ubuntu hardy-security main restricted
deb http://security.ubuntu.com/ubuntu hardy-security universe
deb-src http://security.ubuntu.com/ubuntu hardy-security universe
deb http://security.ubuntu.com/ubuntu hardy-security multiverse
deb-src http://security.ubuntu.com/ubuntu hardy-security multiverse

이제 다음을 수행합니다:

apt-get update
apt-get upgrade

4.3 수정 사항

/bin/sh는 /bin/dash에 대한 심볼릭 링크입니다. 그러나 우리는 /bin/dash가 아닌 /bin/bash가 필요합니다. 따라서 다음과 같이 수행합니다:

ln -sf /bin/bash /bin/sh

다음과 같이 AppArmor를 비활성화합니다 (dom01 및 dom02에서):

/etc/init.d/apparmor stop
update-rc.d -f apparmor remove

5. 네트워크 구성 (dom01, dom02, lb1, lb2, web1, web2)

5.1 IP 설정

Ubuntu에서 네트워크 구성을 편집하려면:

vi /etc/network/interfaces

이제 각 네트워크 구성을 하나씩 수행합니다. 2개의 네트워크 카드를 사용한다고 가정하며, eth0는 인터넷에 연결되고 eth1은 크로스오버 케이블이 연결된 것입니다. 구성 파일을 개별적으로 작성하지 않고 dom01.example.com에 대해서만 작성하겠습니다. 이 목록에 따라 수정하세요:

dom01.example.com

eth0 : 192.168.1.100
eth1 : 192.168.0.100

dom02.example.com

eth0 : 192.168.1.101
eth1 : 192.168.0.101

lb1.example.com

eth0 : 192.168.1.102
eth1 : 192.168.0.102

lb2.example.com

eth0 : 192.168.1.103
eth1 : 192.168.0.103

web1.example.com

eth0 : 192.168.1.104
eth1 : 192.168.0.104

web2.example.com

eth0 : 192.168.1.105
eth1 : 192.168.0.105

dom01.example.com의 예시 네트워크 구성:

파일 /etc/network/interfaces를 다음과 같이 설정합니다:

# 이 파일은 시스템에서 사용 가능한 네트워크 인터페이스와
# 이를 활성화하는 방법을 설명합니다. 자세한 내용은 interfaces(5)를 참조하세요.
# 루프백 네트워크 인터페이스
auto lo
iface lo inet loopback
# 인터넷에 연결된 기본 네트워크 인터페이스
auto eth0
iface eth0 inet static
        address 192.168.1.100
        netmask 255.255.255.0
        network 192.168.1.0
        broadcast 192.168.1.255
        gateway 192.168.1.1
# 다른 서버의 크로스오버 케이블로 연결된 보조 네트워크 인터페이스
auto eth1
iface eth1 inet static
        address 192.168.0.100
        netmask 255.255.255.0
        network 192.168.0.0
        broadcast 192.168.0.255

이제 파일을 저장하고 다음을 수행합니다:

/etc/init.d/networking restart

5.2 호스트 이름

vi /etc/hosts

다음과 같이 설정하세요. 그렇지 않으면 나중에 ldirectord에서 문제가 발생합니다:

dom01.example.com

127.0.0.1       localhost.localdomain   localhost
127.0.1.1       dom01.example.com dom01
192.168.1.101   dom02.example.com     dom02
192.168.1.102   lb1.example.com     lb1
192.168.1.103   lb2.example.com     lb2
192.168.1.104   web1.example.com     web1
192.168.1.105   web2.example.com     web2
# 다음 줄은 IPv6 지원 호스트에 대해 바람직합니다
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

echo dom01.example.com > /etc/hostname
/etc/init.d/hostname.sh start

dom02.example.com

127.0.0.1       localhost.localdomain   localhost
127.0.1.1       dom02.example.com dom02
192.168.1.100   dom01.example.com     dom01
192.168.1.102   lb1.example.com     lb1
192.168.1.103   lb2.example.com     lb2
192.168.1.104   web1.example.com     web1
192.168.1.105   web2.example.com     web2
# 다음 줄은 IPv6 지원 호스트에 대해 바람직합니다
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

echo dom02.example.com > /etc/hostname
/etc/init.d/hostname.sh start

lb1.example.com

127.0.0.1       localhost.localdomain   localhost
127.0.1.1       lb1.example.com lb1
192.168.1.100   dom01.example.com     dom01
192.168.1.101   dom02.example.com     dom02
192.168.1.103   lb2.example.com     lb2
192.168.1.104   web1.example.com     web1
192.168.1.105   web2.example.com     web2
# 다음 줄은 IPv6 지원 호스트에 대해 바람직합니다
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

echo lb1.example.com > /etc/hostname
/etc/init.d/hostname.sh start

lb2.example.com

127.0.0.1       localhost.localdomain   localhost
127.0.1.1       lb2.example.com lb2
192.168.1.100   dom01.example.com     dom01
192.168.1.101   dom02.example.com     dom02
192.168.1.102   lb1.example.com     lb1
192.168.1.104   web1.example.com     web1
192.168.1.105   web2.example.com     web2
# 다음 줄은 IPv6 지원 호스트에 대해 바람직합니다
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

echo lb2.example.com > /etc/hostname
/etc/init.d/hostname.sh start

web1.example.com

127.0.0.1       localhost.localdomain   localhost
127.0.1.1       web1.example.com web1
192.168.1.100   dom01.example.com     dom01
192.168.1.101   dom02.example.com     dom02
192.168.1.102   lb1.example.com     lb1
192.168.1.103   lb2.example.com     lb2
192.168.1.105   web2.example.com     web2
# 다음 줄은 IPv6 지원 호스트에 대해 바람직합니다
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

echo web1.example.com > /etc/hostname
/etc/init.d/hostname.sh start

web2.example.com

127.0.0.1       localhost.localdomain   localhost
127.0.1.1       web2.example.com web2
192.168.1.100   dom01.example.com     dom01
192.168.1.101   dom02.example.com     dom02
192.168.1.102   lb1.example.com     lb1
192.168.1.103   lb2.example.com     lb2
192.168.1.104   web1.example.com     web1
# 다음 줄은 IPv6 지원 호스트에 대해 바람직합니다
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
ff02::3 ip6-allhosts

echo web2.example.com > /etc/hostname
/etc/init.d/hostname.sh start

6. 소프트웨어 설치 (dom01, dom02, lb1, lb2, web1, web2)

실행:

apt-get install binutils cpp fetchmail flex gcc libarchive-zip-perl libc6-dev libcompress-zlib-perl libdb4.3-dev libpcre3 libpopt-dev lynx m4 make ncftp nmap openssl perl perl-modules unzip zip zlib1g-dev autoconf automake1.9 libtool bison autotools-dev g++ build-essential

Share: X/Twitter LinkedIn

새 게시물을 받은 편지함에서 받기

스팸은 없습니다. 언제든지 구독 해지 가능합니다.